Skip to content

Commit

Permalink
fb_dnf: add support for managing the perfmetrics plugin
Browse files Browse the repository at this point in the history
Differential Revision: D62315076

fbshipit-source-id: f5ee750871a74b40668db65ba8ef466ae8c7f448
  • Loading branch information
davide125 authored and facebook-github-bot committed Sep 9, 2024
1 parent ead9d5c commit 89640b9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cookbooks/fb_dnf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Attributes
* node['fb_dnf']['disable_makecache_timer']
* node['fb_dnf']['manage_packages']
* node['fb_dnf']['modules'][$MODULE][$CONFIG]
* node['fb_dnf']['perfmetrics']
* node['fb_dnf']['repos'][$GROUP]['repos'][$REPO][$KEY][$VALUE]

Usage
Expand Down Expand Up @@ -86,3 +87,9 @@ node.default['fb_dnf']['modules']['nodejs'] = {
'stream' => 13,
}
```

### Perfmetrics
Setting `node['fb_dnf']['perfmetrics']` to `true` will install and enable the
[Performance Metrics plugin](https://github.com/filbranden/dnf-plugins-perfmetrics),
which will record performance metrics for DNF and store them in JSON files
under `/var/log/dnf/perfmetrics`.
1 change: 1 addition & 0 deletions cookbooks/fb_dnf/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
'manage_packages' => true,
'modules' => {},
'repos' => {},
'perfmetrics' => false,
}
46 changes: 46 additions & 0 deletions cookbooks/fb_dnf/recipes/perfmetrics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Cookbook Name:: fb_dnf
# Recipe:: perfmetrics
#
# Copyright (c) 2024-present, Facebook, Inc.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

package 'python3-dnf-plugin-perfmetrics' do
only_if { node['fb_dnf']['perfmetrics'] }
action :upgrade
end

config = '/etc/dnf/plugins/perfmetrics.conf'

directory '/var/log/dnf' do
only_if { node['fb_dnf']['perfmetrics'] }
owner node.root_user
group node.root_group
mode '0755'
end

template config do
only_if { node['fb_dnf']['perfmetrics'] }
source 'perfmetrics.conf.erb'
owner node.root_user
group node.root_group
mode '0644'
end

file config do
not_if { node['fb_dnf']['perfmetrics'] }
action :delete
end
5 changes: 5 additions & 0 deletions cookbooks/fb_dnf/templates/default/perfmetrics.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is maintained by Chef. Do not edit, all changes will be
# overwritten. See fb_dnf/README.md

[main]
enabled=<%= node['fb_dnf']['perfmetrics'] ? '1' : '0' %>

0 comments on commit 89640b9

Please sign in to comment.