1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Update DOP and code cleanup

This commit is contained in:
Martin Gebhardt 2022-03-12 00:52:12 +01:00
parent ba142817c7
commit 1f61b7235a
No known key found for this signature in database
GPG key ID: 5472B866EA6CD3DD

View file

@ -1,75 +1,68 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
@dummyvar = <<-'=cut' =begin
=head2 Description =head1 puppet_runtime
puppet_runtime - Munin plugin that reports the duration of puppet runs. A munin plugin that reports the duration of puppet runs.
=head2 Compatibility =head2 Compatibility
This Plugin is tested with the following configurations: This Plugin is tested with the following configurations:
Debian: { ---
version => 11 { Linux:
Puppet: { Debian:
version => 5.5.22, - 11
version => 7.14.0, - Puppet:
} - 5.5.22
} - 7.14.0
} Redhat:
Redhat: { - 8
version => 8 { - Puppet:
Puppet: { - 6.4.0
version => 6.4.0, - 6.19.1
version => 6.19.1, - 7.9.2
version => 7.9.2, Fedora:
} - 35
} - Puppet:
} - 7.12.1
Fedora: { - 7.14.0
version => 35 {
Puppet: {
version => 7.12.1,
version => 7.14.0,
}
}
}
=head2 Configuration =head2 Configuration
The following configuration is mandatory. It must be ensured that It must be ensured that the plugin is executed by root. For
the plugin is executed by the root user. this create the follwing file:
$ cat /etc/munin/plugin-conf.d/puppet.conf $ cat /etc/munin/plugin-conf.d/puppet.conf
[puppet_runtime] [puppet_runtime]
user root user root
Further configurations are not necessary. If it does not work, Further configurations are not necessary.
then run "puppet config print lastrunreport" and make sure that
the specified file is readable. =head2 How it works
Puppet generates a YAML file on each run which contains all
information of the last run, the 'facts'.
Where your puppet-agent stores the file, the plugin finds out
with the following commansd:
$ puppet config print lastrunreport $ puppet config print lastrunreport
/opt/puppetlabs/puppet/cache/state/last_run_report.yaml
To check the function, perform the following: =head3 Run it!
To check the plugins function, perform the following:
$ munin-run puppet_runtime $ munin-run puppet_runtime
An example Output: An example Output:
$ munin-run puppet_runtime $ munin-run puppet_runtime
total.value 6.952583373 total.value 9.571794571
fact_generation.value 4.8415459030075 fact_generation.value 6.210164764896035
catalog_application.value 1.060418801032938 catalog_application.value 2.0418781149201095
plugin_sync.value 0.6275155210169032 plugin_sync.value 0.6617366508580744
The duration of the Puppet run is determined from the Puppet report. =head3 Tips & Tricks
This information can be found in the file last_run_report.yaml.
The location of the file is determined via the Puppet client, for example:
$ puppet config print lastrunreport
/opt/puppetlabs/puppet/cache/state/last_run_report.yaml
=head2 Tips & Tricks
Since you want to integrate the runtime of a puppet run into Munin, Since you want to integrate the runtime of a puppet run into Munin,
you will most likely use puppet as well. Here you can find an you will most likely use puppet as well. Here you can find an
@ -96,26 +89,26 @@ In this case, a simple link is enough to fix this issue:
ensure => 'link', ensure => 'link',
target => '/opt/puppetlabs/bin/puppet', target => '/opt/puppetlabs/bin/puppet',
} }
=end
=cut
require 'yaml' require 'yaml'
report = YAML.load(File.read(`puppet config print lastrunfile`.strip)) def output
time_report = report["time"] report = YAML.load(File.read(`puppet config print lastrunfile`.strip))
time_report = report["time"]
if time_report.is_a?(Hash) if time_report.is_a?(Hash)
total, fact_generation, catalog_application, plugin_sync = time_report.values_at( total, fact_generation, catalog_application, plugin_sync = time_report.values_at(
"total", "fact_generation", "catalog_application", "plugin_sync" "total", "fact_generation", "catalog_application", "plugin_sync"
) )
puts "total.value #{total}" if total
puts "total.value #{total}" if total puts "fact_generation.value #{fact_generation}" if fact_generation
puts "fact_generation.value #{fact_generation}" if fact_generation puts "catalog_application.value #{catalog_application}" if catalog_application
puts "catalog_application.value #{catalog_application}" if catalog_application puts "plugin_sync.value #{plugin_sync}" if plugin_sync
puts "plugin_sync.value #{plugin_sync}" if plugin_sync end
end end
case ARGV[0] def config
when 'config'
puts 'graph_category system' puts 'graph_category system'
puts 'graph_args --base 1000 -l 0' puts 'graph_args --base 1000 -l 0'
puts 'graph_scale no' puts 'graph_scale no'
@ -125,13 +118,10 @@ when 'config'
puts 'fact_generation.label Fact generation runtime' puts 'fact_generation.label Fact generation runtime'
puts 'catalog_application.label Catalog application runtime' puts 'catalog_application.label Catalog application runtime'
puts 'plugin_sync.label Plugin sync runtime' puts 'plugin_sync.label Plugin sync runtime'
exit 0 end
when 'autoconf'
puts 'yes' if (ARGV.length == 1) && (ARGV[0] == 'config')
exit 0 config
else else
total output
fact_generation
catalog_application
plugin_sync
end end