diff --git a/cookbooks/fb_dnf/README.md b/cookbooks/fb_dnf/README.md index d53eebe63..2e960ff9c 100644 --- a/cookbooks/fb_dnf/README.md +++ b/cookbooks/fb_dnf/README.md @@ -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 @@ -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`. diff --git a/cookbooks/fb_dnf/attributes/default.rb b/cookbooks/fb_dnf/attributes/default.rb index da80a8719..ad1fd2faa 100644 --- a/cookbooks/fb_dnf/attributes/default.rb +++ b/cookbooks/fb_dnf/attributes/default.rb @@ -31,4 +31,5 @@ 'manage_packages' => true, 'modules' => {}, 'repos' => {}, + 'perfmetrics' => false, } diff --git a/cookbooks/fb_dnf/recipes/perfmetrics.rb b/cookbooks/fb_dnf/recipes/perfmetrics.rb new file mode 100644 index 000000000..8bd314505 --- /dev/null +++ b/cookbooks/fb_dnf/recipes/perfmetrics.rb @@ -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 diff --git a/cookbooks/fb_dnf/templates/default/perfmetrics.conf.erb b/cookbooks/fb_dnf/templates/default/perfmetrics.conf.erb new file mode 100644 index 000000000..5b1ddce94 --- /dev/null +++ b/cookbooks/fb_dnf/templates/default/perfmetrics.conf.erb @@ -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' %>