From f34ff5e44d61edef9c7a5e243c623b4524012121 Mon Sep 17 00:00:00 2001 From: Simon Josi Date: Wed, 27 Jan 2010 17:07:42 +0100 Subject: upgrade to 0.25 --- manifests/plugins/interfaces.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index 99b85ba..0062678 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,19 +1,19 @@ # handle if_ and if_err_ plugins class munin::plugins::interfaces inherits munin::plugins::base { - $ifs = gsub(split($interfaces, " |,"), "(.+)", "if_\\1") + $ifs = regsubst(split($interfaces, " |,"), "(.+)", "if_\\1") munin::plugin { $ifs: ensure => "if_"; } case $operatingsystem { openbsd: { - $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") + $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") munin::plugin{ $if_errs: ensure => "if_errcoll_"; } } default: { - $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_err_\\1") + $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_err_\\1") munin::plugin{ $if_errs: ensure => "if_err_"; } -- cgit v1.2.3 From 87b7e02eaa1ee305d1ea2192873446ba479546b5 Mon Sep 17 00:00:00 2001 From: Matthias Imsand Date: Tue, 2 Feb 2010 11:29:09 +0100 Subject: replaced legace gsub method --- manifests/plugins/interfaces.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index 0062678..35ef648 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,6 +1,7 @@ # handle if_ and if_err_ plugins class munin::plugins::interfaces inherits munin::plugins::base { + # replaced gsub with regsubst $ifs = regsubst(split($interfaces, " |,"), "(.+)", "if_\\1") munin::plugin { $ifs: ensure => "if_"; -- cgit v1.2.3 From 286859e3957f1c64ec583d274903b1ca2a47ea67 Mon Sep 17 00:00:00 2001 From: Simon Josi Date: Thu, 4 Feb 2010 11:04:13 +0100 Subject: syntax --- manifests/plugin.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 1fa4651..e688a39 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -3,8 +3,6 @@ # See LICENSE for the full license granted to you. # adapted and improved by admin(at)immerda.ch -### defines - define munin::plugin ( $ensure = "present", $script_path_in = '', -- cgit v1.2.3 From fd64c0039b427bb568730988ecfa816f86f94b84 Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Wed, 2 Jun 2010 15:16:05 +0200 Subject: adjust module to fit plugins to 0.25 style --- lib/facter/acpi_available.rb | 10 ++++++++++ lib/facter/interfaces.rb | 13 +++++++++++++ plugins/facter/acpi_available.rb | 10 ---------- plugins/facter/interfaces.rb | 13 ------------- 4 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 lib/facter/acpi_available.rb create mode 100755 lib/facter/interfaces.rb delete mode 100644 plugins/facter/acpi_available.rb delete mode 100755 plugins/facter/interfaces.rb diff --git a/lib/facter/acpi_available.rb b/lib/facter/acpi_available.rb new file mode 100644 index 0000000..9a0474f --- /dev/null +++ b/lib/facter/acpi_available.rb @@ -0,0 +1,10 @@ +# return whether acpi is available -- used for deciding whether to install the munin plugin +Facter.add("acpi_available") do + setcode do + if not File.exist? `which acpi 2>/dev/null`.chomp or `acpi -t -B -A 2>/dev/null`.match(/\d/).nil? + "absent" + else + "present" + end + end +end diff --git a/lib/facter/interfaces.rb b/lib/facter/interfaces.rb new file mode 100755 index 0000000..a498d64 --- /dev/null +++ b/lib/facter/interfaces.rb @@ -0,0 +1,13 @@ +# return the set of active interfaces as an array +Facter.add("interfaces") do + setcode do + `ip -o link show`.split(/\n/).collect do |line| + value = nil + matches = line.match(/^\d*: ([^:]*): <(.*,)?UP(,.*)?>/) + if !matches.nil? + value = matches[1] + end + value + end.compact.sort.join(" ") + end +end diff --git a/plugins/facter/acpi_available.rb b/plugins/facter/acpi_available.rb deleted file mode 100644 index 9a0474f..0000000 --- a/plugins/facter/acpi_available.rb +++ /dev/null @@ -1,10 +0,0 @@ -# return whether acpi is available -- used for deciding whether to install the munin plugin -Facter.add("acpi_available") do - setcode do - if not File.exist? `which acpi 2>/dev/null`.chomp or `acpi -t -B -A 2>/dev/null`.match(/\d/).nil? - "absent" - else - "present" - end - end -end diff --git a/plugins/facter/interfaces.rb b/plugins/facter/interfaces.rb deleted file mode 100755 index a498d64..0000000 --- a/plugins/facter/interfaces.rb +++ /dev/null @@ -1,13 +0,0 @@ -# return the set of active interfaces as an array -Facter.add("interfaces") do - setcode do - `ip -o link show`.split(/\n/).collect do |line| - value = nil - matches = line.match(/^\d*: ([^:]*): <(.*,)?UP(,.*)?>/) - if !matches.nil? - value = matches[1] - end - value - end.compact.sort.join(" ") - end -end -- cgit v1.2.3 From 015b7262e4b0bedad9500e982350197160a4ad1d Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Tue, 21 Sep 2010 17:25:49 +0200 Subject: refactor module to the new standard --- manifests/client/openbsd.pp | 2 +- manifests/host.pp | 10 +++++----- manifests/host/cgi.pp | 10 +++++----- manifests/plugin/deploy.pp | 2 +- manifests/plugins/base.pp | 2 +- manifests/snmp_collector.pp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp index 17abdbf..4c2807c 100644 --- a/manifests/client/openbsd.pp +++ b/manifests/client/openbsd.pp @@ -2,7 +2,7 @@ # :( class munin::client::openbsd inherits munin::client::base { file{'/usr/src/munin_openbsd.tar.gz': - source => "puppet://$server/munin/openbsd/package/munin_openbsd.tar.gz", + source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", owner => root, group => 0, mode => 0600; } package{ [ 'p5-Compress-Zlib', 'p5-Crypt-SSLeay', 'p5-HTML-Parser', diff --git a/manifests/host.pp b/manifests/host.pp index 9251516..734eea6 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -9,11 +9,11 @@ class munin::host File <<| tag == 'munin' |>> file{'/etc/munin/munin.conf.header': - source => [ "puppet://$server/files/munin/config/host/${fqdn}/munin.conf.header", - "puppet://$server/files/munin/config/host/munin.conf.header.$operatingsystem", - "puppet://$server/files/munin/config/host/munin.conf.header", - "puppet://$server/munin/config/host/munin.conf.header.$operatingsystem", - "puppet://$server/munin/config/host/munin.conf.header" ], + source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", + "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/site-munin/config/host/munin.conf.header", + "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/munin/config/host/munin.conf.header" ], notify => Exec['concat_/etc/munin/munin.conf'], owner => root, group => 0, mode => 0644; } diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 7fdb281..6fd50df 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -6,11 +6,11 @@ class munin::host::cgi { } file{'/etc/logrotate.d/munin': - source => [ "puppet://$server/files/munin/config/host/${fqdn}/logrotate", - "puppet://$server/files/munin/config/host/logrotate.$operatingsystem", - "puppet://$server/files/munin/config/host/logrotate", - "puppet://$server/munin/config/host/logrotate.$operatingsystem", - "puppet://$server/munin/config/host/logrotate" ], + source => [ "puppet:///modules/site-munin/config/host/${fqdn}/logrotate", + "puppet:///modules/site-munin/config/host/logrotate.$operatingsystem", + "puppet:///modules/site-munin/config/host/logrotate", + "puppet:///modules/munin/config/host/logrotate.$operatingsystem", + "puppet:///modules/munin/config/host/logrotate" ], owner => root, group => 0, mode => 0644; } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 47bf796..eb4e3da 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -11,7 +11,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { include munin::plugin::scriptpaths file { "munin_plugin_${name}": path => "$munin::plugin::scriptpaths::script_path/${name}", - source => "puppet://$server/$real_source", + source => "puppet:///$real_source", mode => 0755, owner => root, group => 0; } diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index 1bfed48..80a957e 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -1,7 +1,7 @@ class munin::plugins::base { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: - source => "puppet://$server/common/empty", + source => "puppet:///modules/common/empty", ignore => [ '\.ignore', 'snmp_*' ], ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, diff --git a/manifests/snmp_collector.pp b/manifests/snmp_collector.pp index 53a860f..60fd573 100644 --- a/manifests/snmp_collector.pp +++ b/manifests/snmp_collector.pp @@ -1,7 +1,7 @@ class munin::snmp_collector{ file { "/var/lib/puppet/modules/munin/create_snmp_links": - source => "puppet://$server/munin/create_snmp_links.sh", + source => "puppet:///modules/munin/create_snmp_links.sh", mode => 755, owner => root, group => 0; } -- cgit v1.2.3 From 334b4a3ba627ddf481d68f8f29c925895470de62 Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 12:10:02 +0200 Subject: use better snmp register define --- manifests/register/snmp.pp | 22 ++++++++++++++++++++++ manifests/register_snmp.pp | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 manifests/register/snmp.pp delete mode 100644 manifests/register_snmp.pp diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp new file mode 100644 index 0000000..c0d9279 --- /dev/null +++ b/manifests/register/snmp.pp @@ -0,0 +1,22 @@ +define munin::register::snmp ( + $community = 'public', + $description = 'absent' +) +{ + $fhost = $name + $munin_host_real = $fqdn + $client_type = 'snmp' + $config = [ 'use_node_name no' ] + + exec { "munin_register_snmp_${fhost}": + command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} | sh", + unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", + } + + @@file { "munin_snmp_${fhost}": + ensure => present, + path => "/var/lib/puppet/modules/munin/nodes/${fhost}", + content => template("munin/client.erb"), + tag => 'munin', + } +} diff --git a/manifests/register_snmp.pp b/manifests/register_snmp.pp deleted file mode 100644 index e74ba44..0000000 --- a/manifests/register_snmp.pp +++ /dev/null @@ -1,21 +0,0 @@ -# snmp_testplugin: the plugin we use to test if it's set -define munin::register_snmp( - $snmpd_testplugin = 'load' -) -{ - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => '*', - 'fqdn' => '*', - default => $munin_host - } - exec{"register_snmp_munin_for_${name}": - command => "munin-node-configure-snmp ${name} | sh", - unless => "test -e /etc/munin/plugins/snmp_${name}_${snmpd_testplugin}", - } - @@file { "munin_snmp_${name}": path => "/var/lib/puppet/modules/munin/nodes/${name}", - ensure => present, - content => template("munin/snmpclient.erb"), - tag => 'munin', - } -} -- cgit v1.2.3 From e27e74f81274d35d3873c6b5b5fa8816138212ed Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 12:13:10 +0200 Subject: code style for darwin class --- manifests/client/darwin.pp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/manifests/client/darwin.pp b/manifests/client/darwin.pp index f6fc95f..4004f74 100644 --- a/manifests/client/darwin.pp +++ b/manifests/client/darwin.pp @@ -1,21 +1,21 @@ class munin::client::darwin { - file { "/usr/share/snmp/snmpd.conf": - mode => 744, - content => template("munin/darwin_snmpd.conf.erb"), - group => 0, - owner => root, - } - delete_matching_line{"startsnmpdno": - file => "/etc/hostconfig", - pattern => "SNMPSERVER=-NO-", - } - line { "startsnmpdyes": - file => "/etc/hostconfig", - line => "SNMPSERVER=-YES-", - notify => Exec["/sbin/SystemStarter start SNMP"], - } - exec{"/sbin/SystemStarter start SNMP": - noop => false, - } - munin::register_snmp { $fqdn: } + file { "/usr/share/snmp/snmpd.conf": + mode => 744, + content => template("munin/darwin_snmpd.conf.erb"), + group => 0, + owner => root, + } + delete_matching_line{"startsnmpdno": + file => "/etc/hostconfig", + pattern => "SNMPSERVER=-NO-", + } + line { "startsnmpdyes": + file => "/etc/hostconfig", + line => "SNMPSERVER=-YES-", + notify => Exec["/sbin/SystemStarter start SNMP"], + } + exec{"/sbin/SystemStarter start SNMP": + noop => false, + } + munin::register::snmp { $fqdn: } } -- cgit v1.2.3 From 88fec38166f51bf8edabba6769a198016b799f1e Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 12:19:21 +0200 Subject: update templates to the new way --- manifests/register.pp | 43 ++++++++++++++++++++++++++++++------------- templates/client.erb | 18 ++++++++++++++++++ templates/defaultclient.erb | 15 --------------- templates/snmpclient.erb | 10 ---------- 4 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 templates/client.erb delete mode 100644 templates/defaultclient.erb delete mode 100644 templates/snmpclient.erb diff --git a/manifests/register.pp b/manifests/register.pp index e1271e1..21f1d35 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -1,17 +1,34 @@ -define munin::register() +define munin::register ( + $host = 'absent', + $port = 'absent', + $description = 'absent', + $config = [] +) { - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => $fqdn, - 'fqdn' => $fqdn, - default => $munin_host - } + $fhost = $name + $client_type = 'client' - @@file { "/var/lib/puppet/modules/munin/nodes/${name}_${munin_port_real}": - ensure => present, - content => template("munin/defaultclient.erb"), - tag => 'munin', - } -} + $munin_port_real = $port ? { + 'absent' => $munin_port ? { + '' => 4949, + default => $munin_port + }, + default => $port + } + $munin_host_real = $host ? { + 'absent' => $munin_host ? { + '' => $fqdn, + 'fqdn' => $fqdn, + default => $munin_host + }, + default => $host + } + @@file { "munin_client_${fhost}_${munin_port_real}": + ensure => present, + path => "/var/lib/puppet/modules/munin/nodes/${fhost}_${munin_port_real}", + content => template("munin/client.erb"), + tag => 'munin', + } +} diff --git a/templates/client.erb b/templates/client.erb new file mode 100644 index 0000000..286631f --- /dev/null +++ b/templates/client.erb @@ -0,0 +1,18 @@ +<% + # Downcase all information + dom = domain.downcase + host = hostname.downcase +%> + +### Munin client from Puppet template +# Domain: <%= dom %> +# Registered on: <%= host %> +# Type: <%= client_type %> +<% if description != 'absent' -%> +# Description: <%= description.gsub!(/\n/, ' ') %> +<% end -%> +[<%= fhost.downcase %>] + address <%= munin_host_real -%> +<% if config -%><% config.each do |val| -%> + <%= val -%> +<% end -%><% end -%> diff --git a/templates/defaultclient.erb b/templates/defaultclient.erb deleted file mode 100644 index 5611bf4..0000000 --- a/templates/defaultclient.erb +++ /dev/null @@ -1,15 +0,0 @@ -<% - # Downcase all information - dom = domain.downcase - host = hostname.downcase - fhost = name.downcase -%> -### This syntax can be extended, it might get better ... -#+<%= dom %> -#-<%= host %>=<%= fhost %>:load.load -[<%= fhost %>] # linux box - address <%= munin_host_real %> - port <%= munin_port_real %> - use_node_name yes - load.load.warning 5 - load.load.critical 10 diff --git a/templates/snmpclient.erb b/templates/snmpclient.erb deleted file mode 100644 index 44ecc6d..0000000 --- a/templates/snmpclient.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% - # Downcase all information - dom = domain.downcase - host = hostname.downcase - fhost = name.downcase -%> -### This syntax can be extended, it might get better ... -#<%= dom %> snmp -> <%= fhost %> -[<%= fhost %>] # snmp box - address <%= munin_host_real %> -- cgit v1.2.3 From f3acecb57d7fde7760f2b74506589b9f4565947a Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 12:30:08 +0200 Subject: use shell so we can actually pipe that command --- manifests/register/snmp.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index c0d9279..0c3ac5c 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -9,7 +9,7 @@ define munin::register::snmp ( $config = [ 'use_node_name no' ] exec { "munin_register_snmp_${fhost}": - command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} | sh", + command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", } -- cgit v1.2.3 From 25e557a7b67b9836ead75b70e6415d8e3f925cfc Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 15:48:13 +0200 Subject: now we use the new modules path everywhere --- manifests/plugin/deploy.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index eb4e3da..67cbfb8 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -11,7 +11,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { include munin::plugin::scriptpaths file { "munin_plugin_${name}": path => "$munin::plugin::scriptpaths::script_path/${name}", - source => "puppet:///$real_source", + source => "puppet:///modules/$real_source", mode => 0755, owner => root, group => 0; } -- cgit v1.2.3 From 553fbe3e1d3c6865172c1db8cf93d69fb936dc18 Mon Sep 17 00:00:00 2001 From: Pascal Simon Date: Mon, 6 Dec 2010 15:51:05 +0100 Subject: update munin-node template --- templates/munin-node.conf.default | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index befcae4..85c0051 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -7,15 +7,16 @@ log_file /var/log/munin/munin-node.log pid_file /var/run/munin/munin-node.pid background 1 -setseid 1 +setsid 1 user root group 0 -setsid yes # Regexps for files to ignore ignore_file ~$ +#ignore_file [#~]$ # FIX doesn't work. '#' starts a comment +ignore_file DEADJOE$ ignore_file \.bak$ ignore_file %$ ignore_file \.dpkg-(tmp|new|old|dist)$ @@ -29,14 +30,23 @@ ignore_file \.pod$ host_name <%= fqdn %> # A list of addresses that are allowed to connect. This must be a -# regular expression, due to brain damage in Net::Server, which -# doesn't understand CIDR-style network notation. You may repeat -# the allow line as many times as you'd like +# regular expression, since Net::Server does not understand CIDR-style +# network notation unless the perl module Net::CIDR is installed. You +# may repeat the allow line as many times as you'd like <% real_munin_allow.split(':').each do |val| -%> allow <%= '^'+val.gsub(/\./, '\.')+'$' %> <% end -%> +# If you have installed the Net::CIDR perl module, you can use +# multiple cidr_allow and cidr_deny address/mask patterns. A +# connecting client must match any cidr_allow, and not match any +# cidr_deny. Example: + +# cidr_allow 127.0.0.1/32 +# cidr_allow 192.0.2.0/24 +# cidr_deny 192.0.2.42/32 + # Which address to bind to; host <%= munin_host_real %> # host 127.0.0.1 -- cgit v1.2.3 From 7a13b36953cc4e359a37c0e7fa80a6ee3b452766 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 31 May 2011 19:30:04 +0200 Subject: no need to manage logfiles, this should be done by the package --- manifests/host.pp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/manifests/host.pp b/manifests/host.pp index e038fd7..69cc7da 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -23,12 +23,6 @@ class munin::host inherits munin header => "/etc/munin/munin.conf.header", } - file { ["/var/log/munin-update.log", "/var/log/munin-limits.log", - "/var/log/munin-graph.log", "/var/log/munin-html.log"]: - ensure => present, - mode => 640, owner => munin, group => 0; - } - include munin::plugins::muninhost case $operatingsystem { -- cgit v1.2.3 From c88a6c4879e13b95e4fff00ec956557dd5be5689 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 31 May 2011 19:39:20 +0200 Subject: make cgi graphing optional --- manifests/host.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/host.pp b/manifests/host.pp index 69cc7da..3e4f5ea 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -25,8 +25,8 @@ class munin::host inherits munin include munin::plugins::muninhost - case $operatingsystem { - centos: { include munin::host::cgi } + if $munin_do_cgi_graphing { + include munin::host::cgi } # from time to time we cleanup hanging munin-runs -- cgit v1.2.3 From 1d33fc714f1ab1c672aca6e6aecb2327332033ec Mon Sep 17 00:00:00 2001 From: Benjamin Krause Date: Tue, 31 May 2011 11:24:26 +0200 Subject: added lucid debian symlink --- templates/munin-node.conf.Debian.lucid | 1 + 1 file changed, 1 insertion(+) create mode 120000 templates/munin-node.conf.Debian.lucid diff --git a/templates/munin-node.conf.Debian.lucid b/templates/munin-node.conf.Debian.lucid new file mode 120000 index 0000000..e0646b9 --- /dev/null +++ b/templates/munin-node.conf.Debian.lucid @@ -0,0 +1 @@ +munin-node.conf.Debian.etch \ No newline at end of file -- cgit v1.2.3 From 5049ee5adee3642bf1ccae40ade1c79e6e301832 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 15 Jul 2011 17:40:31 +0200 Subject: it is not anymore necessary to add an empty source to purge directories --- manifests/plugins/setup.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index c2c5ed3..c88f9e0 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -1,8 +1,7 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: - source => "puppet:///modules/common/empty", - ignore => [ '.ignore', 'snmp_*' ], + ignore => 'snmp_*', ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, mode => 0755, owner => root, group => 0, -- cgit v1.2.3 From eb953716cd545f86972e85d983b5862c194f5aed Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 22 Jul 2011 13:04:38 +0200 Subject: fix typo --- manifests/plugins/apache.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/plugins/apache.pp b/manifests/plugins/apache.pp index b3e7634..dca3cea 100644 --- a/manifests/plugins/apache.pp +++ b/manifests/plugins/apache.pp @@ -1,4 +1,4 @@ class munin::plugins::apache { - munin::plugin{ [ 'apache_accesses', 'apache_processes',' apache_volume' ]: } - munin::plugin::deploy { "apache_activity": } + munin::plugin{ [ 'apache_accesses', 'apache_processes', 'apache_volume' ]: } + munin::plugin::deploy { 'apache_activity': } } -- cgit v1.2.3 From 9b0b698523987b7631478bcf7dc84acf5e0e719c Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Thu, 4 Aug 2011 10:48:57 +0200 Subject: move from concatenated_file to concat --- README | 5 +++-- manifests/client.pp | 2 +- manifests/host.pp | 40 +++++++++++++++++++--------------------- manifests/init.pp | 5 ----- manifests/register.pp | 5 ++--- manifests/register/snmp.pp | 5 ++--- 6 files changed, 27 insertions(+), 35 deletions(-) diff --git a/README b/README index 5964b21..7ea6e44 100644 --- a/README +++ b/README @@ -5,8 +5,9 @@ a very easy plugin interface. The munin homepage is http://munin.projects.linpro To use this module, follow these directions: -1. Install the "common" module -- the munin module depends on functions that are - defined and installed via the common module, see README.common for how to do this +1. Install the "common" and "concat" module -- the munin module depends on functions + that are defined and installed via these modulesh, see README.common for how to do + this 2. You will need storedconfigs enabled in your puppet setup, to do that you need to add a line to your puppet.conf in your [puppetmasterd] section which says: diff --git a/manifests/client.pp b/manifests/client.pp index 273070d..141c916 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -3,7 +3,7 @@ # See LICENSE for the full license granted to you. # Adapted and improved by admin(at)immerda.ch -class munin::client inherits munin { +class munin::client { $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } $munin_host_real = $munin_host ? { diff --git a/manifests/host.pp b/manifests/host.pp index 3e4f5ea..107cd39 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -2,32 +2,30 @@ # Copyright (C) 2007 David Schmitt # See LICENSE for the full license granted to you. -class munin::host inherits munin -{ - package {"munin": ensure => installed, } +class munin::host { + package {"munin": ensure => installed, } - File <<| tag == 'munin' |>> + Concat::Fragment <<| tag == 'munin' |>> - file{'/etc/munin/munin.conf.header': - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", - "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", - "puppet:///modules/site-munin/config/host/munin.conf.header", - "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", - "puppet:///modules/munin/config/host/munin.conf.header" ], - notify => Exec['concat_/etc/munin/munin.conf'], - owner => root, group => 0, mode => 0644; - } + concat::fragment{'munin.conf.header': + target => '/etc/munin/munin.conf', + source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", + "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/site-munin/config/host/munin.conf.header", + "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/munin/config/host/munin.conf.header" ], + order => 05, + } - concatenated_file { "/etc/munin/munin.conf": - dir => '/var/lib/puppet/modules/munin/nodes', - header => "/etc/munin/munin.conf.header", - } + concat{ "/etc/munin/munin.conf": + owner => root, group => 0, mode => 0644; + } - include munin::plugins::muninhost + include munin::plugins::muninhost - if $munin_do_cgi_graphing { - include munin::host::cgi - } + if $munin_do_cgi_graphing { + include munin::host::cgi + } # from time to time we cleanup hanging munin-runs file{'/etc/cron.d/munin_kill': diff --git a/manifests/init.pp b/manifests/init.pp index bae83a4..b015521 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,8 +14,3 @@ # # the port is a parameter so vservers can share # IP addresses and still be happy - -class munin { - include common::moduledir - module_dir { [ "munin", "munin/nodes", "munin/plugins" ]: } -} diff --git a/manifests/register.pp b/manifests/register.pp index 21f1d35..78d13d3 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -25,9 +25,8 @@ define munin::register ( default => $host } - @@file { "munin_client_${fhost}_${munin_port_real}": - ensure => present, - path => "/var/lib/puppet/modules/munin/nodes/${fhost}_${munin_port_real}", + @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": + target => '/etc/munin/munin.conf', content => template("munin/client.erb"), tag => 'munin', } diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index 0c3ac5c..5a1f42d 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -13,9 +13,8 @@ define munin::register::snmp ( unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", } - @@file { "munin_snmp_${fhost}": - ensure => present, - path => "/var/lib/puppet/modules/munin/nodes/${fhost}", + @@concat::fragment{ "munin_snmp_${fhost}": + target => '/etc/munin/munin.conf', content => template("munin/client.erb"), tag => 'munin', } -- cgit v1.2.3 From c2eb31850777a49991e35a9008e589e51e0eee0f Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Thu, 4 Aug 2011 11:00:42 +0200 Subject: get a new line at the end --- templates/client.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/client.erb b/templates/client.erb index 15e05c6..3e8ab39 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -17,3 +17,4 @@ <% if config -%><% config.each do |val| -%> <%= val -%> <% end -%><% end -%> + -- cgit v1.2.3 From 568fa47b11489b7ec7cac556e6927017f6cc8cc7 Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Thu, 4 Aug 2011 12:58:36 +0200 Subject: Update README - this is not anymore necessary --- README | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/README b/README index 7ea6e44..b00e646 100644 --- a/README +++ b/README @@ -36,14 +36,7 @@ To use this module, follow these directions: "modules.pp" in your site.pp, if you do not have that, then you will need to add the import line to your site.pp) - c. you will also need to create the following empty directories: - - mkdir /etc/puppet/modules/munin/files/empty - mkdir /etc/puppet/modules/munin/files/modules_dir - mkdir -p /etc/puppet/modules/munin/files/nodes/modules_dir - mkdir -p /etc/puppet/modules/munin/files/plugins/modules_dir - - d. Add to the top of your site.pp a variable which indicates what IP should be allowed to + c. Add to the top of your site.pp a variable which indicates what IP should be allowed to connect to your individual munin-nodes (this is typically your main munin host's IP): $munin_allow = '192.168.0.1' @@ -52,16 +45,16 @@ To use this module, follow these directions: $munin_allow = '127.0.0.1:192.168.0.1' - e. In the node definition in your site.pp for your main munin host, add the following: + d. In the node definition in your site.pp for your main munin host, add the following: include munin::host - f. On each node that will gather munin statistics, add this line to that node's entry + e. On each node that will gather munin statistics, add this line to that node's entry in site.pp (you may want to also add this to your main munin host): include munin::client - g. If there are particular munin plugins you want to enable or configure, you define them + f. If there are particular munin plugins you want to enable or configure, you define them in the node definition, like follows: # Enable monitoring of disk stats in bytes @@ -81,13 +74,13 @@ To use this module, follow these directions: } - h. If you have Linux-Vservers configured, you will likely have multiple munin-node processes + g. If you have Linux-Vservers configured, you will likely have multiple munin-node processes competing for the default port 4949, for those nodes, set an alternate port for munin-node to run on by putting something similar to the following in the node definition: $munin_port = 4948 - i. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto + h. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto For CentOS this is enabled in the default header config - j. Per default (on CentOS) munin will send warnings and critical messages to root + i. Per default (on CentOS) munin will send warnings and critical messages to root -- cgit v1.2.3 From 8e874720bf878a09a425d3323095202b1ca36846 Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Thu, 4 Aug 2011 14:19:39 +0200 Subject: Also provide port for snmp nodes --- manifests/register/snmp.pp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index 5a1f42d..c45adb0 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -1,6 +1,7 @@ define munin::register::snmp ( $community = 'public', - $description = 'absent' + $description = 'absent', + $port = 'absent' ) { $fhost = $name @@ -8,6 +9,14 @@ define munin::register::snmp ( $client_type = 'snmp' $config = [ 'use_node_name no' ] + $munin_port_real = $port ? { + 'absent' => $munin_port ? { + '' => 4949, + default => $munin_port + }, + default => $port + } + exec { "munin_register_snmp_${fhost}": command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", -- cgit v1.2.3 From 33380e238f3ac37ac79f30485fdebbc5dd10170b Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 5 Aug 2011 10:59:04 +0200 Subject: use correct define --- manifests/client/darwin.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/client/darwin.pp b/manifests/client/darwin.pp index 4004f74..92787ec 100644 --- a/manifests/client/darwin.pp +++ b/manifests/client/darwin.pp @@ -5,9 +5,10 @@ class munin::client::darwin { group => 0, owner => root, } - delete_matching_line{"startsnmpdno": + line{"startsnmpdno": file => "/etc/hostconfig", - pattern => "SNMPSERVER=-NO-", + line => "SNMPSERVER=-NO-", + ensure => 'absent', } line { "startsnmpdyes": file => "/etc/hostconfig", -- cgit v1.2.3 From 9b161f0c61bbd30960e663eceef8f1b35f633507 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 5 Nov 2011 14:14:32 +0100 Subject: use hiera to configure munin node specific things --- README | 32 ++++++++++++-------------------- manifests/client.pp | 7 ------- manifests/client/base.pp | 8 +++----- manifests/register.pp | 10 ++++------ manifests/register/snmp.pp | 5 +---- templates/munin-node.conf.Debian.etch | 8 ++++---- templates/munin-node.conf.default | 8 ++++---- 7 files changed, 28 insertions(+), 50 deletions(-) diff --git a/README b/README index b00e646..22bb19f 100644 --- a/README +++ b/README @@ -28,33 +28,25 @@ To use this module, follow these directions: a. Your modules directory will need all the files included in this repository placed under a directory called "munin" - b. add the following line to your modules.pp: - - import "munin" - - (NOTE: if you have followed the directions in README.common then you will have import - "modules.pp" in your site.pp, if you do not have that, then you will need to add the - import line to your site.pp) - - c. Add to the top of your site.pp a variable which indicates what IP should be allowed to + b. Add your hiera storage value for munin_allow which indicates what IP should be allowed to connect to your individual munin-nodes (this is typically your main munin host's IP): - $munin_allow = '192.168.0.1' + munin_allow: '192.168.0.1' - If you want to define more than one host, you can seperate them by colon: + If you want to define more than one host, you can define them as an array: - $munin_allow = '127.0.0.1:192.168.0.1' + munin_allow: ['127.0.0.1','192.168.0.1'] - d. In the node definition in your site.pp for your main munin host, add the following: + c. In the node definition in your site.pp for your main munin host, add the following: include munin::host - e. On each node that will gather munin statistics, add this line to that node's entry + d. On each node that will gather munin statistics, add this line to that node's entry in site.pp (you may want to also add this to your main munin host): include munin::client - f. If there are particular munin plugins you want to enable or configure, you define them + e. If there are particular munin plugins you want to enable or configure, you define them in the node definition, like follows: # Enable monitoring of disk stats in bytes @@ -74,13 +66,13 @@ To use this module, follow these directions: } - g. If you have Linux-Vservers configured, you will likely have multiple munin-node processes + f. If you have Linux-Vservers configured, you will likely have multiple munin-node processes competing for the default port 4949, for those nodes, set an alternate port for munin-node - to run on by putting something similar to the following in the node definition: + to run on by putting something similar to the following in hiera's node scope: - $munin_port = 4948 + munin_port: 4948 - h. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto + g. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto For CentOS this is enabled in the default header config - i. Per default (on CentOS) munin will send warnings and critical messages to root + h. Per default (on CentOS) munin will send warnings and critical messages to root diff --git a/manifests/client.pp b/manifests/client.pp index 141c916..99480f1 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -5,13 +5,6 @@ class munin::client { - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => '*', - 'fqdn' => '*', - default => $munin_host - } - case $operatingsystem { openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 17387e8..6b4bef9 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,4 +1,6 @@ -class munin::client::base { +class munin::client::base( + $munin_allow = hiera('munin_allow','127.0.0.1') +) { service { 'munin-node': ensure => running, enable => true, @@ -9,10 +11,6 @@ class munin::client::base { ensure => directory, mode => 0755, owner => root, group => 0; } - $real_munin_allow = $munin_allow ? { - '' => '127.0.0.1', - default => $munin_allow - } file {'/etc/munin/munin-node.conf': content => template("munin/munin-node.conf.$operatingsystem"), notify => Service['munin-node'], diff --git a/manifests/register.pp b/manifests/register.pp index 78d13d3..3c542ff 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -9,18 +9,16 @@ define munin::register ( $client_type = 'client' $munin_port_real = $port ? { - 'absent' => $munin_port ? { - '' => 4949, - default => $munin_port - }, + 'absent' => hiera('munin_port','4949'), default => $port } + $hiera_munin_host = hiera('munin_host','') $munin_host_real = $host ? { - 'absent' => $munin_host ? { + 'absent' => $hiera_munin_host ? { '' => $fqdn, 'fqdn' => $fqdn, - default => $munin_host + default => $hiera_munin_host }, default => $host } diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index c45adb0..a4d0d88 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -10,10 +10,7 @@ define munin::register::snmp ( $config = [ 'use_node_name no' ] $munin_port_real = $port ? { - 'absent' => $munin_port ? { - '' => 4949, - default => $munin_port - }, + 'absent' => hiera('munin_port','4949'), default => $port } diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch index 56da89d..17162d8 100644 --- a/templates/munin-node.conf.Debian.etch +++ b/templates/munin-node.conf.Debian.etch @@ -9,8 +9,8 @@ background 1 setseid 1 # Which host/port to bind to; -host <%= munin_host_real %> -port <%= munin_port_real %> +host <%= scope.function_hiera('munin_host','*') %> +port <%= scope.function_hiera('munin_port','4949') %> user root group root setsid yes @@ -33,7 +33,7 @@ host_name <%= fqdn %> # regular expression, due to brain damage in Net::Server, which # doesn't understand CIDR-style network notation. You may repeat # the allow line as many times as you'd like -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index be62848..d67a9f8 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -37,8 +37,8 @@ host_name <%= fqdn %> # network notation unless the perl module Net::CIDR is installed. You # may repeat the allow line as many times as you'd like -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> # If you have installed the Net::CIDR perl module, you can use @@ -51,9 +51,9 @@ allow <%= '^'+val.gsub(/\./, '\.')+'$' %> # cidr_deny 192.0.2.42/32 # Which address to bind to; -host <%= munin_host_real %> +host <%= scope.function_hiera('munin_host','*') %> # host 127.0.0.1 # And which port -port <%= munin_port_real %> +port <%= scope.function_hiera('munin_port','4949') %> -- cgit v1.2.3 From d8de9540534a3801c87278435934da3c88a69e4b Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 22 Dec 2011 23:01:48 +0100 Subject: add squeeze template --- templates/munin-node.conf.Debian.squeeze | 1 + 1 file changed, 1 insertion(+) create mode 120000 templates/munin-node.conf.Debian.squeeze diff --git a/templates/munin-node.conf.Debian.squeeze b/templates/munin-node.conf.Debian.squeeze new file mode 120000 index 0000000..e0646b9 --- /dev/null +++ b/templates/munin-node.conf.Debian.squeeze @@ -0,0 +1 @@ +munin-node.conf.Debian.etch \ No newline at end of file -- cgit v1.2.3 From e2dfae5852ecdf3695a6af8ec48092ea24698390 Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Thu, 2 Feb 2012 18:10:14 -0800 Subject: Fully qualify facter variables --- manifests/client.pp | 2 +- manifests/client/base.pp | 4 ++-- manifests/client/darwin.pp | 2 +- manifests/client/debian.pp | 4 ++-- manifests/client/openbsd.pp | 6 +++--- manifests/host.pp | 6 +++--- manifests/host/cgi.pp | 6 +++--- manifests/plugin.pp | 2 +- manifests/plugin/deploy.pp | 2 +- manifests/plugin/scriptpaths.pp | 4 ++-- manifests/plugins/base.pp | 2 +- manifests/plugins/interfaces.pp | 2 +- manifests/plugins/physical.pp | 2 +- manifests/plugins/setup.pp | 2 +- manifests/register.pp | 4 ++-- manifests/register/snmp.pp | 2 +- templates/client.erb | 4 ++-- 17 files changed, 28 insertions(+), 28 deletions(-) diff --git a/manifests/client.pp b/manifests/client.pp index 99480f1..0ff5b79 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -5,7 +5,7 @@ class munin::client { - case $operatingsystem { + case $::operatingsystem { openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } debian,ubuntu: { include munin::client::debian } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 6b4bef9..0c7a62a 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -12,11 +12,11 @@ class munin::client::base( mode => 0755, owner => root, group => 0; } file {'/etc/munin/munin-node.conf': - content => template("munin/munin-node.conf.$operatingsystem"), + content => template("munin/munin-node.conf.${::operatingsystem}"), notify => Service['munin-node'], mode => 0644, owner => root, group => 0, } - munin::register { $fqdn: + munin::register { $::fqdn: config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], } include munin::plugins::base diff --git a/manifests/client/darwin.pp b/manifests/client/darwin.pp index 92787ec..264263d 100644 --- a/manifests/client/darwin.pp +++ b/manifests/client/darwin.pp @@ -18,5 +18,5 @@ class munin::client::darwin { exec{"/sbin/SystemStarter start SNMP": noop => false, } - munin::register::snmp { $fqdn: } + munin::register::snmp { $::fqdn: } } diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index 97f5fbf..903fb2d 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -4,10 +4,10 @@ class munin::client::debian inherits munin::client::package { Service["munin-node"]{ # sarge's munin-node init script has no status - hasstatus => $lsbdistcodename ? { sarge => false, default => true } + hasstatus => $::lsbdistcodename ? { sarge => false, default => true } } File["/etc/munin/munin-node.conf"]{ - content => template("munin/munin-node.conf.$operatingsystem.$lsbdistcodename"), + content => template("munin/munin-node.conf.${::operatingsystem}.${::lsbdistcodename}"), } # workaround bug in munin_node_configure plugin { "postfix_mailvolume": ensure => absent } diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp index 7012c00..e1742d2 100644 --- a/manifests/client/openbsd.pp +++ b/manifests/client/openbsd.pp @@ -1,7 +1,7 @@ # currently we install munin on openbsd by targz # :( class munin::client::openbsd inherits munin::client::base { - if $operatingsystemrelease == '4.3' { + if $::operatingsystemrelease == '4.3' { file{'/usr/src/munin_openbsd.tar.gz': source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", owner => root, group => 0, mode => 0600; @@ -32,7 +32,7 @@ class munin::client::openbsd inherits munin::client::base { owner => root, group => 0, mode => 0755; } openbsd::rc_local{'munin-node': - binary => $operatingsystemrelease ? { + binary => $::operatingsystemrelease ? { '4.3' => '/opt/munin/sbin/munin-node', default => '/usr/local/sbin/munin-node' }, @@ -41,7 +41,7 @@ class munin::client::openbsd inherits munin::client::base { Service['munin-node']{ restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', - start => $operatingsystemrelease ? { + start => $::operatingsystemrelease ? { '4.3' => '/opt/munin/sbin/munin-node', default => '/usr/local/sbin/munin-node' }, diff --git a/manifests/host.pp b/manifests/host.pp index 107cd39..c424e94 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -9,10 +9,10 @@ class munin::host { concat::fragment{'munin.conf.header': target => '/etc/munin/munin.conf', - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", - "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", + source => [ "puppet:///modules/site-munin/config/host/${::fqdn}/munin.conf.header", + "puppet:///modules/site-munin/config/host/munin.conf.header.${::operatingsystem}", "puppet:///modules/site-munin/config/host/munin.conf.header", - "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}", "puppet:///modules/munin/config/host/munin.conf.header" ], order => 05, } diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 6fd50df..283a243 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -6,10 +6,10 @@ class munin::host::cgi { } file{'/etc/logrotate.d/munin': - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/logrotate", - "puppet:///modules/site-munin/config/host/logrotate.$operatingsystem", + source => [ "puppet:///modules/site-munin/config/host/${::fqdn}/logrotate", + "puppet:///modules/site-munin/config/host/logrotate.${::operatingsystem}", "puppet:///modules/site-munin/config/host/logrotate", - "puppet:///modules/munin/config/host/logrotate.$operatingsystem", + "puppet:///modules/munin/config/host/logrotate.${::operatingsystem}", "puppet:///modules/munin/config/host/logrotate" ], owner => root, group => 0, mode => 0644; } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 69b7322..51de48a 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -21,7 +21,7 @@ define munin::plugin ( file { $plugin: ensure => absent, } } default: { - case $kernel { + case $::kernel { openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 67cbfb8..7de8d45 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -15,7 +15,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { mode => 0755, owner => root, group => 0; } - case $kernel { + case $::kernel { openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp index 164a17e..f4bd39b 100644 --- a/manifests/plugin/scriptpaths.pp +++ b/manifests/plugin/scriptpaths.pp @@ -1,9 +1,9 @@ class munin::plugin::scriptpaths { - case $operatingsystem { + case $::operatingsystem { gentoo: { $script_path = "/usr/libexec/munin/plugins" } debian: { $script_path = "/usr/share/munin/plugins" } centos: { $script_path = "/usr/share/munin/plugins" } - openbsd: { $script_path = $operatingsystemrelease ? { + openbsd: { $script_path = $::operatingsystemrelease ? { '4.3' => '/opt/munin/lib/plugins/', default => '/usr/local/libexec/munin/plugins/' } } diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index 007579c..972a674 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -7,7 +7,7 @@ class munin::plugins::base { } include munin::plugins::interfaces - case $kernel { + case $::kernel { openbsd: { include munin::plugins::openbsd } linux: { case $vserver { diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index 18a713b..b2c448b 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -5,7 +5,7 @@ class munin::plugins::interfaces { munin::plugin { $ifs: ensure => "if_"; } - case $operatingsystem { + case $::operatingsystem { openbsd: { $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") munin::plugin{ diff --git a/manifests/plugins/physical.pp b/manifests/plugins/physical.pp index ac050a5..a1c27a7 100644 --- a/manifests/plugins/physical.pp +++ b/manifests/plugins/physical.pp @@ -1,5 +1,5 @@ class munin::plugins::physical { - case $kernel { + case $::kernel { linux: { munin::plugin { iostat: } } } } diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index c88f9e0..caf2e28 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -11,7 +11,7 @@ class munin::plugins::setup { mode => 0644, owner => root, group => 0, notify => Service['munin-node'], } - case $kernel { + case $::kernel { openbsd: { File['/etc/munin/plugin-conf.d/munin-node']{ before => File['/var/run/munin'], diff --git a/manifests/register.pp b/manifests/register.pp index 3c542ff..254eaaf 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -16,8 +16,8 @@ define munin::register ( $hiera_munin_host = hiera('munin_host','') $munin_host_real = $host ? { 'absent' => $hiera_munin_host ? { - '' => $fqdn, - 'fqdn' => $fqdn, + '' => $::fqdn, + 'fqdn' => $::fqdn, default => $hiera_munin_host }, default => $host diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index a4d0d88..acd1e03 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -5,7 +5,7 @@ define munin::register::snmp ( ) { $fhost = $name - $munin_host_real = $fqdn + $munin_host_real = $::fqdn $client_type = 'snmp' $config = [ 'use_node_name no' ] diff --git a/templates/client.erb b/templates/client.erb index 3e8ab39..8c93cc5 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -1,7 +1,7 @@ <% # Downcase all information - dom = domain.downcase - host = hostname.downcase + dom = scope.lookupvar('::domain').downcase + host = scope.lookupvar('::hostname').downcase %> ### Munin client from Puppet template -- cgit v1.2.3 From 8a2e868c67013f6dcebe722cc1f0c7cbf599b8fc Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Thu, 2 Feb 2012 18:14:56 -0800 Subject: Make sure concat::setup is declared Make sure concat::setup is declared for /etc/munin/munin.conf. --- manifests/host.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/host.pp b/manifests/host.pp index 107cd39..22ffbe2 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -4,6 +4,7 @@ class munin::host { package {"munin": ensure => installed, } + include concat::setup Concat::Fragment <<| tag == 'munin' |>> -- cgit v1.2.3 From c91621a0953d97a83f62205519524708c279a24e Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Thu, 2 Feb 2012 18:19:33 -0800 Subject: Fix munin.conf for squeeze and later Debian releases Add support for lsbdistcodename-specific munin.conf.header files. Create squeeze munin.conf.header file which contains the new htmldir setting, /var/cache/munin/www, and symlink wheezy and sid to it. --- files/config/host/munin.conf.header.Debian.sid | 1 + files/config/host/munin.conf.header.Debian.squeeze | 75 ++++++++++++++++++++++ files/config/host/munin.conf.header.Debian.wheezy | 1 + manifests/host.pp | 8 ++- 4 files changed, 82 insertions(+), 3 deletions(-) create mode 120000 files/config/host/munin.conf.header.Debian.sid create mode 100644 files/config/host/munin.conf.header.Debian.squeeze create mode 120000 files/config/host/munin.conf.header.Debian.wheezy diff --git a/files/config/host/munin.conf.header.Debian.sid b/files/config/host/munin.conf.header.Debian.sid new file mode 120000 index 0000000..5fa2037 --- /dev/null +++ b/files/config/host/munin.conf.header.Debian.sid @@ -0,0 +1 @@ +munin.conf.header.Debian.squeeze \ No newline at end of file diff --git a/files/config/host/munin.conf.header.Debian.squeeze b/files/config/host/munin.conf.header.Debian.squeeze new file mode 100644 index 0000000..771d50d --- /dev/null +++ b/files/config/host/munin.conf.header.Debian.squeeze @@ -0,0 +1,75 @@ +# Example configuration file for Munin, generated by 'make build' + +# The next three variables specifies where the location of the RRD +# databases, the HTML output, and the logs, severally. They all +# must be writable by the user running munin-cron. +dbdir /var/lib/munin +htmldir /var/cache/munin/www +logdir /var/log/munin +rundir /var/run/munin + +# Where to look for the HTML templates +tmpldir /etc/munin/templates + +# Make graphs show values per minute instead of per second +#graph_period minute + +# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime +# something changes (OK -> WARNING, CRITICAL -> OK, etc) +#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm +#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm +# +# For those with Nagios, the following might come in handy. In addition, +# the services must be defined in the Nagios server as well. +#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg + +#contacts me +#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root +#contact.me.always_send warning critical + +# a simple host tree +#[localhost] +# address 127.0.0.1 +# use_node_name yes + +# +# A more complex example of a host tree +# +## First our "normal" host. +# [fii.foo.com] +# address foo +# +## Then our other host... +# [fay.foo.com] +# address fay +# +## Then we want totals... +# [foo.com;Totals] #Force it into the "foo.com"-domain... +# update no # Turn off data-fetching for this "host". +# +# # The graph "load1". We want to see the loads of both machines... +# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" +# load1.graph_title Loads side by side +# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# +# # The graph "load2". Now we want them stacked on top of each other. +# load2.graph_title Loads on top of each other +# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# load2.dummy_field.draw AREA # We want area instead the default LINE2. +# load2.dummy_field.label dummy # This is needed. Silly, really. +# +# # The graph "load3". Now we want them summarised into one field +# load3.graph_title Loads summarised +# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load +# load3.combined_loads.label Combined loads # Must be set, as this is +# # not a dummy field! +# +## ...and on a side note, I want them listen in another order (default is +## alphabetically) +# +# # Since [foo.com] would be interpreted as a host in the domain "com", we +# # specify that this is a domain by adding a semicolon. +# [foo.com;] +# node_order Totals fii.foo.com fay.foo.com +# + diff --git a/files/config/host/munin.conf.header.Debian.wheezy b/files/config/host/munin.conf.header.Debian.wheezy new file mode 120000 index 0000000..5fa2037 --- /dev/null +++ b/files/config/host/munin.conf.header.Debian.wheezy @@ -0,0 +1 @@ +munin.conf.header.Debian.squeeze \ No newline at end of file diff --git a/manifests/host.pp b/manifests/host.pp index 107cd39..a26c013 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -9,10 +9,12 @@ class munin::host { concat::fragment{'munin.conf.header': target => '/etc/munin/munin.conf', - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", - "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", + source => [ "puppet:///modules/site-munin/config/host/${::fqdn}/munin.conf.header", + "puppet:///modules/site-munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}", + "puppet:///modules/site-munin/config/host/munin.conf.header.${::operatingsystem}", "puppet:///modules/site-munin/config/host/munin.conf.header", - "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}", + "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}", "puppet:///modules/munin/config/host/munin.conf.header" ], order => 05, } -- cgit v1.2.3 From d459255da087bda68627dc5c228056b6ebf7036b Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 15 Feb 2012 18:17:14 +0100 Subject: manage selinux if enabled of plugins we manage --- manifests/plugin.pp | 8 ++++++-- manifests/plugin/deploy.pp | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 69b7322..b76a5da 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -21,7 +21,7 @@ define munin::plugin ( file { $plugin: ensure => absent, } } default: { - case $kernel { + case $::kernel { openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } @@ -35,7 +35,11 @@ define munin::plugin ( require => $real_require, notify => Service['munin-node']; } - + if $::selinux == 'true' { + File[$plugin]{ + setype => 'munin_services_plugin_exec_t', + } + } } } case $config { diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 67cbfb8..be7748b 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -15,7 +15,14 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { mode => 0755, owner => root, group => 0; } - case $kernel { + + if $::selinux == 'true' { + File["munin_plugin_${name}"]{ + setype => 'munin_services_plugin_exec_t', + } + } + + case $::kernel { openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } -- cgit v1.2.3 From 71d458239f7e8f175c3180d95f0b7770aea91ff0 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 15 Feb 2012 18:25:11 +0100 Subject: correct param --- manifests/plugin.pp | 2 +- manifests/plugin/deploy.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index b76a5da..30139ea 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -37,7 +37,7 @@ define munin::plugin ( } if $::selinux == 'true' { File[$plugin]{ - setype => 'munin_services_plugin_exec_t', + seltype => 'munin_services_plugin_exec_t', } } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index be7748b..a76bc6e 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -18,7 +18,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { if $::selinux == 'true' { File["munin_plugin_${name}"]{ - setype => 'munin_services_plugin_exec_t', + seltype => 'munin_services_plugin_exec_t', } } -- cgit v1.2.3 From df6d136c29b035616ba5bbf5efd9b16f3a22338e Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 16 Feb 2012 15:57:22 +0100 Subject: set correct labels for munin plugins --- manifests/plugin.pp | 2 +- manifests/plugin/deploy.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 30139ea..c1f488b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -37,7 +37,7 @@ define munin::plugin ( } if $::selinux == 'true' { File[$plugin]{ - seltype => 'munin_services_plugin_exec_t', + seltype => 'munin_etc_t', } } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index a76bc6e..86ca7f5 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -18,7 +18,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { if $::selinux == 'true' { File["munin_plugin_${name}"]{ - seltype => 'munin_services_plugin_exec_t', + seltype => 'munin_exec_t', } } -- cgit v1.2.3 From f2a0d2623b36e6105f31e51d99cbd349adaa30d7 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 25 Feb 2012 13:54:48 +0100 Subject: CentOS 5 does not yet have a munin policy --- manifests/plugin.pp | 2 +- manifests/plugin/deploy.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index c1f488b..9f799aa 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -35,7 +35,7 @@ define munin::plugin ( require => $real_require, notify => Service['munin-node']; } - if $::selinux == 'true' { + if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File[$plugin]{ seltype => 'munin_etc_t', } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 86ca7f5..094b490 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -16,7 +16,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { } - if $::selinux == 'true' { + if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File["munin_plugin_${name}"]{ seltype => 'munin_exec_t', } -- cgit v1.2.3 From e710a3bfd1d24a9fa4fdb217609635fec616a6f7 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 29 Apr 2012 12:58:22 +0200 Subject: update config file to match upstream --- templates/munin-node.conf.default | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index d67a9f8..adc2408 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -41,11 +41,13 @@ host_name <%= fqdn %> allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> -# If you have installed the Net::CIDR perl module, you can use -# multiple cidr_allow and cidr_deny address/mask patterns. A -# connecting client must match any cidr_allow, and not match any -# cidr_deny. Example: - +# If you have installed the Net::CIDR perl module, you can use one or more +# cidr_allow and cidr_deny address/mask patterns. A connecting client must +# match any cidr_allow, and not match any cidr_deny. Note that a netmask +# *must* be provided, even if it's /32 +# +# Example: +# # cidr_allow 127.0.0.1/32 # cidr_allow 192.0.2.0/24 # cidr_deny 192.0.2.42/32 -- cgit v1.2.3 From 9fd1de5acd9064a0d67ca9d2c13a829a3f628f39 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 5 Jun 2012 19:39:49 -0300 Subject: new style for 2.7 --- files/config/host/munin.conf.header.Debian.sid | 76 +++++++++++++++- files/config/host/munin.conf.header.Debian.wheezy | 76 +++++++++++++++- manifests/client.pp | 23 +++-- manifests/client/base.pp | 38 ++++---- manifests/client/centos.pp | 2 +- manifests/client/debian.pp | 24 ++--- manifests/client/gentoo.pp | 2 +- manifests/client/openbsd.pp | 102 ++++++++++----------- manifests/client/package.pp | 18 ++-- manifests/host.pp | 16 ++-- manifests/host/cgi.pp | 26 +++--- manifests/plugin.pp | 104 +++++++++++----------- manifests/plugin/deploy.pp | 72 +++++++-------- manifests/plugin/scriptpaths.pp | 20 ++--- manifests/plugins/base.pp | 2 +- manifests/plugins/gentoo.pp | 6 +- manifests/plugins/interfaces.pp | 6 +- manifests/plugins/linux.pp | 2 +- manifests/register.pp | 40 ++++----- manifests/register/snmp.pp | 37 ++++---- manifests/remoteplugin.pp | 28 +++--- 21 files changed, 434 insertions(+), 286 deletions(-) mode change 120000 => 100644 files/config/host/munin.conf.header.Debian.sid mode change 120000 => 100644 files/config/host/munin.conf.header.Debian.wheezy diff --git a/files/config/host/munin.conf.header.Debian.sid b/files/config/host/munin.conf.header.Debian.sid deleted file mode 120000 index 5fa2037..0000000 --- a/files/config/host/munin.conf.header.Debian.sid +++ /dev/null @@ -1 +0,0 @@ -munin.conf.header.Debian.squeeze \ No newline at end of file diff --git a/files/config/host/munin.conf.header.Debian.sid b/files/config/host/munin.conf.header.Debian.sid new file mode 100644 index 0000000..771d50d --- /dev/null +++ b/files/config/host/munin.conf.header.Debian.sid @@ -0,0 +1,75 @@ +# Example configuration file for Munin, generated by 'make build' + +# The next three variables specifies where the location of the RRD +# databases, the HTML output, and the logs, severally. They all +# must be writable by the user running munin-cron. +dbdir /var/lib/munin +htmldir /var/cache/munin/www +logdir /var/log/munin +rundir /var/run/munin + +# Where to look for the HTML templates +tmpldir /etc/munin/templates + +# Make graphs show values per minute instead of per second +#graph_period minute + +# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime +# something changes (OK -> WARNING, CRITICAL -> OK, etc) +#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm +#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm +# +# For those with Nagios, the following might come in handy. In addition, +# the services must be defined in the Nagios server as well. +#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg + +#contacts me +#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root +#contact.me.always_send warning critical + +# a simple host tree +#[localhost] +# address 127.0.0.1 +# use_node_name yes + +# +# A more complex example of a host tree +# +## First our "normal" host. +# [fii.foo.com] +# address foo +# +## Then our other host... +# [fay.foo.com] +# address fay +# +## Then we want totals... +# [foo.com;Totals] #Force it into the "foo.com"-domain... +# update no # Turn off data-fetching for this "host". +# +# # The graph "load1". We want to see the loads of both machines... +# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" +# load1.graph_title Loads side by side +# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# +# # The graph "load2". Now we want them stacked on top of each other. +# load2.graph_title Loads on top of each other +# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# load2.dummy_field.draw AREA # We want area instead the default LINE2. +# load2.dummy_field.label dummy # This is needed. Silly, really. +# +# # The graph "load3". Now we want them summarised into one field +# load3.graph_title Loads summarised +# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load +# load3.combined_loads.label Combined loads # Must be set, as this is +# # not a dummy field! +# +## ...and on a side note, I want them listen in another order (default is +## alphabetically) +# +# # Since [foo.com] would be interpreted as a host in the domain "com", we +# # specify that this is a domain by adding a semicolon. +# [foo.com;] +# node_order Totals fii.foo.com fay.foo.com +# + diff --git a/files/config/host/munin.conf.header.Debian.wheezy b/files/config/host/munin.conf.header.Debian.wheezy deleted file mode 120000 index 5fa2037..0000000 --- a/files/config/host/munin.conf.header.Debian.wheezy +++ /dev/null @@ -1 +0,0 @@ -munin.conf.header.Debian.squeeze \ No newline at end of file diff --git a/files/config/host/munin.conf.header.Debian.wheezy b/files/config/host/munin.conf.header.Debian.wheezy new file mode 100644 index 0000000..771d50d --- /dev/null +++ b/files/config/host/munin.conf.header.Debian.wheezy @@ -0,0 +1,75 @@ +# Example configuration file for Munin, generated by 'make build' + +# The next three variables specifies where the location of the RRD +# databases, the HTML output, and the logs, severally. They all +# must be writable by the user running munin-cron. +dbdir /var/lib/munin +htmldir /var/cache/munin/www +logdir /var/log/munin +rundir /var/run/munin + +# Where to look for the HTML templates +tmpldir /etc/munin/templates + +# Make graphs show values per minute instead of per second +#graph_period minute + +# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime +# something changes (OK -> WARNING, CRITICAL -> OK, etc) +#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm +#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm +# +# For those with Nagios, the following might come in handy. In addition, +# the services must be defined in the Nagios server as well. +#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg + +#contacts me +#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root +#contact.me.always_send warning critical + +# a simple host tree +#[localhost] +# address 127.0.0.1 +# use_node_name yes + +# +# A more complex example of a host tree +# +## First our "normal" host. +# [fii.foo.com] +# address foo +# +## Then our other host... +# [fay.foo.com] +# address fay +# +## Then we want totals... +# [foo.com;Totals] #Force it into the "foo.com"-domain... +# update no # Turn off data-fetching for this "host". +# +# # The graph "load1". We want to see the loads of both machines... +# # "fii=fii.foo.com:load.load" means "label=machine:graph.field" +# load1.graph_title Loads side by side +# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# +# # The graph "load2". Now we want them stacked on top of each other. +# load2.graph_title Loads on top of each other +# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load +# load2.dummy_field.draw AREA # We want area instead the default LINE2. +# load2.dummy_field.label dummy # This is needed. Silly, really. +# +# # The graph "load3". Now we want them summarised into one field +# load3.graph_title Loads summarised +# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load +# load3.combined_loads.label Combined loads # Must be set, as this is +# # not a dummy field! +# +## ...and on a side note, I want them listen in another order (default is +## alphabetically) +# +# # Since [foo.com] would be interpreted as a host in the domain "com", we +# # specify that this is a domain by adding a semicolon. +# [foo.com;] +# node_order Totals fii.foo.com fay.foo.com +# + diff --git a/manifests/client.pp b/manifests/client.pp index 0ff5b79..5080f99 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -4,16 +4,15 @@ # Adapted and improved by admin(at)immerda.ch class munin::client { - - case $::operatingsystem { - openbsd: { include munin::client::openbsd } - darwin: { include munin::client::darwin } - debian,ubuntu: { include munin::client::debian } - gentoo: { include munin::client::gentoo } - centos: { include munin::client::package } - default: { include munin::client::base } - } - if $use_shorewall { - include shorewall::rules::munin - } + case $::operatingsystem { + openbsd: { include munin::client::openbsd } + darwin: { include munin::client::darwin } + debian,ubuntu: { include munin::client::debian } + gentoo: { include munin::client::gentoo } + centos: { include munin::client::package } + default: { include munin::client::base } + } + if hiera('use_shorewall',false) { + include shorewall::rules::munin + } } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 0c7a62a..80a25c5 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,23 +1,23 @@ class munin::client::base( $munin_allow = hiera('munin_allow','127.0.0.1') ) { - service { 'munin-node': - ensure => running, - enable => true, - hasstatus => true, - hasrestart => true, - } - file {'/etc/munin': - ensure => directory, - mode => 0755, owner => root, group => 0; - } - file {'/etc/munin/munin-node.conf': - content => template("munin/munin-node.conf.${::operatingsystem}"), - notify => Service['munin-node'], - mode => 0644, owner => root, group => 0, - } - munin::register { $::fqdn: - config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], - } - include munin::plugins::base + service { 'munin-node': + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + } + file {'/etc/munin': + ensure => directory, + mode => 0755, owner => root, group => 0; + } + file {'/etc/munin/munin-node.conf': + content => template("munin/munin-node.conf.${::operatingsystem}"), + notify => Service['munin-node'], + mode => 0644, owner => root, group => 0, + } + munin::register { $::fqdn: + config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], + } + include munin::plugins::base } diff --git a/manifests/client/centos.pp b/manifests/client/centos.pp index 42e8c59..3a7151b 100644 --- a/manifests/client/centos.pp +++ b/manifests/client/centos.pp @@ -1,3 +1,3 @@ class munin::client::centos inherits munin::client::package { - include munin::plugins::centos + include munin::plugins::centos } diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index 903fb2d..e67ac26 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -1,15 +1,15 @@ class munin::client::debian inherits munin::client::package { - # the plugin will need that - package { "iproute": ensure => installed } + # the plugin will need that + package { "iproute": ensure => installed } - Service["munin-node"]{ - # sarge's munin-node init script has no status - hasstatus => $::lsbdistcodename ? { sarge => false, default => true } - } - File["/etc/munin/munin-node.conf"]{ - content => template("munin/munin-node.conf.${::operatingsystem}.${::lsbdistcodename}"), - } - # workaround bug in munin_node_configure - plugin { "postfix_mailvolume": ensure => absent } - include munin::plugins::debian + Service["munin-node"]{ + # sarge's munin-node init script has no status + hasstatus => $::lsbdistcodename ? { sarge => false, default => true } + } + File["/etc/munin/munin-node.conf"]{ + content => template("munin/munin-node.conf.${::operatingsystem}.${::lsbdistcodename}"), + } + # workaround bug in munin_node_configure + plugin { "postfix_mailvolume": ensure => absent } + include munin::plugins::debian } diff --git a/manifests/client/gentoo.pp b/manifests/client/gentoo.pp index c24d317..6a01050 100644 --- a/manifests/client/gentoo.pp +++ b/manifests/client/gentoo.pp @@ -4,5 +4,5 @@ class munin::client::gentoo inherits munin::client::package { category => 'net-analyzer', } - include munin::plugins::gentoo + include munin::plugins::gentoo } diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp index e1742d2..88d0640 100644 --- a/manifests/client/openbsd.pp +++ b/manifests/client/openbsd.pp @@ -1,59 +1,59 @@ # currently we install munin on openbsd by targz # :( class munin::client::openbsd inherits munin::client::base { - if $::operatingsystemrelease == '4.3' { - file{'/usr/src/munin_openbsd.tar.gz': - source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", - owner => root, group => 0, mode => 0600; - } - exec{'extract_openbsd': - command => 'cd /;tar xzf /usr/src/munin_openbsd.tar.gz', - unless => 'test -d /opt/munin', - require => File['/usr/src/munin_openbsd.tar.gz'], - before => File['/var/run/munin'], - } - package{'p5-Compress-Zlib': - ensure => installed, - before => File['/var/run/munin'], - } - } else { - package{'munin-node': - ensure => installed, - } + if $::operatingsystemrelease == '4.3' { + file{'/usr/src/munin_openbsd.tar.gz': + source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", + owner => root, group => 0, mode => 0600; } - package{ [ 'p5-Crypt-SSLeay', 'p5-HTML-Parser', 'p5-HTML-Tagset', 'p5-HTTP-GHTTP', - 'p5-LWP-UserAgent-Determined', 'p5-Net-SSLeay', 'p5-Net-Server', - 'p5-URI', 'p5-libwww', 'pcre', 'curl' ]: - ensure => installed, - before => File['/var/run/munin'], + exec{'extract_openbsd': + command => 'cd /;tar xzf /usr/src/munin_openbsd.tar.gz', + unless => 'test -d /opt/munin', + require => File['/usr/src/munin_openbsd.tar.gz'], + before => File['/var/run/munin'], } - file{[ '/var/run/munin', '/var/log/munin' ]: - ensure => directory, - owner => root, group => 0, mode => 0755; + package{'p5-Compress-Zlib': + ensure => installed, + before => File['/var/run/munin'], } - openbsd::rc_local{'munin-node': - binary => $::operatingsystemrelease ? { - '4.3' => '/opt/munin/sbin/munin-node', - default => '/usr/local/sbin/munin-node' - }, - require => File['/var/run/munin'], - } - Service['munin-node']{ - restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', - stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', - start => $::operatingsystemrelease ? { - '4.3' => '/opt/munin/sbin/munin-node', - default => '/usr/local/sbin/munin-node' - }, - status => 'test -e /var/run/munin/munin-node.pid && (ps ax | egrep -q "^$(cat /var/run/munin/munin-node.pid).*munin-node")', - hasstatus => true, - hasrestart => true, - require => [ File['/var/run/munin'], File['/var/log/munin'] ], - } - cron{'clean_munin_logfile': - command => 'rm /var/log/munin/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`', - minute => 0, - hour => 2, - weekday => 0, + } else { + package{'munin-node': + ensure => installed, } + } + package{ [ 'p5-Crypt-SSLeay', 'p5-HTML-Parser', 'p5-HTML-Tagset', 'p5-HTTP-GHTTP', + 'p5-LWP-UserAgent-Determined', 'p5-Net-SSLeay', 'p5-Net-Server', + 'p5-URI', 'p5-libwww', 'pcre', 'curl' ]: + ensure => installed, + before => File['/var/run/munin'], + } + file{[ '/var/run/munin', '/var/log/munin' ]: + ensure => directory, + owner => root, group => 0, mode => 0755; + } + openbsd::rc_local{'munin-node': + binary => $::operatingsystemrelease ? { + '4.3' => '/opt/munin/sbin/munin-node', + default => '/usr/local/sbin/munin-node' + }, + require => File['/var/run/munin'], + } + Service['munin-node']{ + restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', + stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', + start => $::operatingsystemrelease ? { + '4.3' => '/opt/munin/sbin/munin-node', + default => '/usr/local/sbin/munin-node' + }, + status => 'test -e /var/run/munin/munin-node.pid && (ps ax | egrep -q "^$(cat /var/run/munin/munin-node.pid).*munin-node")', + hasstatus => true, + hasrestart => true, + require => [ File['/var/run/munin'], File['/var/log/munin'] ], + } + cron{'clean_munin_logfile': + command => 'rm /var/log/munin/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`', + minute => 0, + hour => 2, + weekday => 0, + } } diff --git a/manifests/client/package.pp b/manifests/client/package.pp index 18566b8..58f40da 100644 --- a/manifests/client/package.pp +++ b/manifests/client/package.pp @@ -1,11 +1,11 @@ class munin::client::package inherits munin::client::base { - package { 'munin-node': ensure => installed } - Service['munin-node']{ - require => Package[munin-node], - } - File['/etc/munin/munin-node.conf']{ - # this has to be installed before the package, so the postinst can - # boot the munin-node without failure! - before => Package['munin-node'], - } + package { 'munin-node': ensure => installed } + Service['munin-node']{ + require => Package[munin-node], + } + File['/etc/munin/munin-node.conf']{ + # this has to be installed before the package, so the postinst can + # boot the munin-node without failure! + before => Package['munin-node'], + } } diff --git a/manifests/host.pp b/manifests/host.pp index e81f08f..524cddf 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -2,7 +2,9 @@ # Copyright (C) 2007 David Schmitt # See LICENSE for the full license granted to you. -class munin::host { +class munin::host( + $cgi_graphing = false +) { package {"munin": ensure => installed, } include concat::setup @@ -10,10 +12,10 @@ class munin::host { concat::fragment{'munin.conf.header': target => '/etc/munin/munin.conf', - source => [ "puppet:///modules/site-munin/config/host/${::fqdn}/munin.conf.header", - "puppet:///modules/site-munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}", - "puppet:///modules/site-munin/config/host/munin.conf.header.${::operatingsystem}", - "puppet:///modules/site-munin/config/host/munin.conf.header", + source => [ "puppet:///modules/site_munin/config/host/${::fqdn}/munin.conf.header", + "puppet:///modules/site_munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}", + "puppet:///modules/site_munin/config/host/munin.conf.header.${::operatingsystem}", + "puppet:///modules/site_munin/config/host/munin.conf.header", "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}", "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}", "puppet:///modules/munin/config/host/munin.conf.header" ], @@ -26,7 +28,7 @@ class munin::host { include munin::plugins::muninhost - if $munin_do_cgi_graphing { + if $munin::host::cgi_graphing { include munin::host::cgi } @@ -35,7 +37,7 @@ class munin::host { content => "4,34 * * * * root if $(ps ax | grep -v grep | grep -q munin-run); then killall munin-run; fi\n", owner => root, group => 0, mode => 0644; } - if $use_shorewall { + if hiera('use_shorewall',false) { include shorewall::rules::out::munin } } diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 283a243..9980856 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -1,16 +1,16 @@ class munin::host::cgi { - exec{'set_modes_for_cgi': - command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', - refreshonly => true, - subscribe => File['/etc/munin/munin.conf.header'], - } + exec{'set_modes_for_cgi': + command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + refreshonly => true, + subscribe => File['/etc/munin/munin.conf.header'], + } - file{'/etc/logrotate.d/munin': - source => [ "puppet:///modules/site-munin/config/host/${::fqdn}/logrotate", - "puppet:///modules/site-munin/config/host/logrotate.${::operatingsystem}", - "puppet:///modules/site-munin/config/host/logrotate", - "puppet:///modules/munin/config/host/logrotate.${::operatingsystem}", - "puppet:///modules/munin/config/host/logrotate" ], - owner => root, group => 0, mode => 0644; - } + file{'/etc/logrotate.d/munin': + source => [ "puppet:///modules/site_munin/config/host/${::fqdn}/logrotate", + "puppet:///modules/site_munin/config/host/logrotate.${::operatingsystem}", + "puppet:///modules/site_munin/config/host/logrotate", + "puppet:///modules/munin/config/host/logrotate.${::operatingsystem}", + "puppet:///modules/munin/config/host/logrotate" ], + owner => root, group => 0, mode => 0644; + } } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 9f799aa..fec7b6b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -4,65 +4,65 @@ # adapted and improved by admin(at)immerda.ch define munin::plugin ( - $ensure = "present", - $script_path_in = '', - $config = '') -{ - include munin::plugin::scriptpaths - $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in } + $ensure = "present", + $script_path_in = '', + $config = '' +) { + include munin::plugin::scriptpaths + $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in } - $plugin_src = $ensure ? { "present" => $name, default => $ensure } - $plugin = "/etc/munin/plugins/$name" - $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf" + $plugin_src = $ensure ? { "present" => $name, default => $ensure } + $plugin = "/etc/munin/plugins/${name}" + $plugin_conf = "/etc/munin/plugin-conf.d/${name}.conf" - include munin::plugins::setup - case $ensure { - "absent": { - file { $plugin: ensure => absent, } - } - default: { - case $::kernel { - openbsd: { $basic_require = File['/var/run/munin'] } - default: { $basic_require = Package['munin-node'] } - } - if $require { - $real_require = [ $require, $basic_require ] - } else { - $real_require = $basic_require - } - file { $plugin: - ensure => "${real_script_path}/${plugin_src}", - require => $real_require, - notify => Service['munin-node']; - } - if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ - File[$plugin]{ - seltype => 'munin_etc_t', - } - } + include munin::plugins::setup + case $ensure { + "absent": { + file { $plugin: ensure => absent, } + } + default: { + case $::kernel { + openbsd: { $basic_require = File['/var/run/munin'] } + default: { $basic_require = Package['munin-node'] } + } + if $require { + $real_require = [ $require, $basic_require ] + } else { + $real_require = $basic_require + } + file { $plugin: + ensure => "${real_script_path}/${plugin_src}", + require => $real_require, + notify => Service['munin-node']; + } + if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ + File[$plugin]{ + seltype => 'munin_etc_t', } + } + } + } + case $config { + '': { + file { $plugin_conf: ensure => absent } } - case $config { - '': { - file { $plugin_conf: ensure => absent } + default: { + case $ensure { + absent: { + file { $plugin_conf: ensure => absent } } default: { - case $ensure { - absent: { - file { $plugin_conf: ensure => absent } - } - default: { - file { $plugin_conf: - content => "[${name}]\n$config\n", - mode => 0644, owner => root, group => 0, - } - if $require { - File[$plugin_conf]{ - require +> $require, - } - } - } + file { $plugin_conf: + content => "[${name}]\n$config\n", + mode => 0644, owner => root, group => 0, + } + if $require { + File[$plugin_conf]{ + require +> $require, } + } } + } } + } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 5003153..9e74afb 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -1,43 +1,43 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { - $plugin_src = $ensure ? { - 'present' => $name, - 'absent' => $name, - default => $ensure - } - $real_source = $source ? { - '' => "munin/plugins/$plugin_src", - default => $source - } - include munin::plugin::scriptpaths - file { "munin_plugin_${name}": - path => "$munin::plugin::scriptpaths::script_path/${name}", - source => "puppet:///modules/$real_source", - mode => 0755, owner => root, group => 0; - } + $plugin_src = $ensure ? { + 'present' => $name, + 'absent' => $name, + default => $ensure + } + $real_source = $source ? { + '' => "munin/plugins/$plugin_src", + default => $source + } + include munin::plugin::scriptpaths + file { "munin_plugin_${name}": + path => "${munin::plugin::scriptpaths::script_path}/${name}", + source => "puppet:///modules/${real_source}", + mode => 0755, owner => root, group => 0; + } - if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ - File["munin_plugin_${name}"]{ - seltype => 'munin_exec_t', - } + if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ + File["munin_plugin_${name}"]{ + seltype => 'munin_exec_t', } + } - case $::kernel { - openbsd: { $basic_require = File['/var/run/munin'] } - default: { $basic_require = Package['munin-node'] } - } - if $require { - File["munin_plugin_${name}"]{ - require => [ $basic_require, $require ], - } - } else { - File["munin_plugin_${name}"]{ - require => $basic_require, - } + case $::kernel { + openbsd: { $basic_require = File['/var/run/munin'] } + default: { $basic_require = Package['munin-node'] } + } + if $require { + File["munin_plugin_${name}"]{ + require => [ $basic_require, $require ], } - # register the plugin - if $require { - munin::plugin{$name: ensure => $ensure, config => $config, require => $require } - } else { - munin::plugin{$name: ensure => $ensure, config => $config } + } else { + File["munin_plugin_${name}"]{ + require => $basic_require, } + } + # register the plugin + if $require { + munin::plugin{$name: ensure => $ensure, config => $config, require => $require } + } else { + munin::plugin{$name: ensure => $ensure, config => $config } + } } diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp index f4bd39b..2cad97b 100644 --- a/manifests/plugin/scriptpaths.pp +++ b/manifests/plugin/scriptpaths.pp @@ -1,12 +1,12 @@ class munin::plugin::scriptpaths { - case $::operatingsystem { - gentoo: { $script_path = "/usr/libexec/munin/plugins" } - debian: { $script_path = "/usr/share/munin/plugins" } - centos: { $script_path = "/usr/share/munin/plugins" } - openbsd: { $script_path = $::operatingsystemrelease ? { - '4.3' => '/opt/munin/lib/plugins/', - default => '/usr/local/libexec/munin/plugins/' - } } - default: { $script_path = "/usr/share/munin/plugins" } - } + case $::operatingsystem { + gentoo: { $script_path = "/usr/libexec/munin/plugins" } + debian: { $script_path = "/usr/share/munin/plugins" } + centos: { $script_path = "/usr/share/munin/plugins" } + openbsd: { $script_path = $::operatingsystemrelease ? { + '4.3' => '/opt/munin/lib/plugins/', + default => '/usr/local/libexec/munin/plugins/' + } } + default: { $script_path = "/usr/share/munin/plugins" } + } } diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index 972a674..d26aaeb 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -17,7 +17,7 @@ class munin::plugins::base { } } - case $virtual { + case $::virtual { physical: { include munin::plugins::physical } xen0: { include munin::plugins::dom0 } } diff --git a/manifests/plugins/gentoo.pp b/manifests/plugins/gentoo.pp index 25c1626..27d4689 100644 --- a/manifests/plugins/gentoo.pp +++ b/manifests/plugins/gentoo.pp @@ -1,5 +1,5 @@ class munin::plugins::gentoo { - munin::plugin::deploy { 'gentoo_lastupdated': - config => "user portage\nenv.logfile /var/log/emerge.log\nenv.tail /usr/bin/tail\nenv.grep /bin/grep" - } + munin::plugin::deploy { 'gentoo_lastupdated': + config => "user portage\nenv.logfile /var/log/emerge.log\nenv.tail /usr/bin/tail\nenv.grep /bin/grep" + } } diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index b2c448b..cc79259 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,19 +1,19 @@ # handle if_ and if_err_ plugins class munin::plugins::interfaces { - $ifs = regsubst(split($interfaces, " |,"), "(.+)", "if_\\1") + $ifs = regsubst(split($::interfaces, " |,"), "(.+)", "if_\\1") munin::plugin { $ifs: ensure => "if_"; } case $::operatingsystem { openbsd: { - $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") + $if_errs = regsubst(split($::interfaces, " |,"), "(.+)", "if_errcoll_\\1") munin::plugin{ $if_errs: ensure => "if_errcoll_"; } } default: { - $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_err_\\1") + $if_errs = regsubst(split($::interfaces, " |,"), "(.+)", "if_err_\\1") munin::plugin{ $if_errs: ensure => "if_err_"; } diff --git a/manifests/plugins/linux.pp b/manifests/plugins/linux.pp index 30e0af6..a73de63 100644 --- a/manifests/plugins/linux.pp +++ b/manifests/plugins/linux.pp @@ -3,6 +3,6 @@ class munin::plugins::linux { [ df_abs, forks, df_inode, irqstats, entropy, open_inodes ]: ensure => present; acpi: - ensure => $acpi_available; + ensure => $::acpi_available; } } diff --git a/manifests/register.pp b/manifests/register.pp index 254eaaf..14019d0 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -5,27 +5,27 @@ define munin::register ( $config = [] ) { - $fhost = $name - $client_type = 'client' + $fhost = $name + $client_type = 'client' - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } + $munin_port_real = $port ? { + 'absent' => hiera('munin_port','4949'), + default => $port + } - $hiera_munin_host = hiera('munin_host','') - $munin_host_real = $host ? { - 'absent' => $hiera_munin_host ? { - '' => $::fqdn, - 'fqdn' => $::fqdn, - default => $hiera_munin_host - }, - default => $host - } + $hiera_munin_host = hiera('munin_host','') + $munin_host_real = $host ? { + 'absent' => $hiera_munin_host ? { + '' => $::fqdn, + 'fqdn' => $::fqdn, + default => $hiera_munin_host + }, + default => $host + } - @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": - target => '/etc/munin/munin.conf', - content => template("munin/client.erb"), - tag => 'munin', - } + @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": + target => '/etc/munin/munin.conf', + content => template("munin/client.erb"), + tag => 'munin', + } } diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index acd1e03..3007b67 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -2,26 +2,25 @@ define munin::register::snmp ( $community = 'public', $description = 'absent', $port = 'absent' -) -{ - $fhost = $name - $munin_host_real = $::fqdn - $client_type = 'snmp' - $config = [ 'use_node_name no' ] +) { + $fhost = $name + $munin_host_real = $::fqdn + $client_type = 'snmp' + $config = [ 'use_node_name no' ] - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } + $munin_port_real = $port ? { + 'absent' => hiera('munin_port','4949'), + default => $port + } - exec { "munin_register_snmp_${fhost}": - command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", - unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", - } + exec { "munin_register_snmp_${fhost}": + command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", + unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", + } - @@concat::fragment{ "munin_snmp_${fhost}": - target => '/etc/munin/munin.conf', - content => template("munin/client.erb"), - tag => 'munin', - } + @@concat::fragment{ "munin_snmp_${fhost}": + target => '/etc/munin/munin.conf', + content => template("munin/client.erb"), + tag => 'munin', + } } diff --git a/manifests/remoteplugin.pp b/manifests/remoteplugin.pp index ce87492..603cb66 100644 --- a/manifests/remoteplugin.pp +++ b/manifests/remoteplugin.pp @@ -1,18 +1,18 @@ define munin::remoteplugin($ensure = "present", $source, $config = '') { - case $ensure { - "absent": { munin::plugin{ $name: ensure => absent } } - default: { - file { - "/var/lib/puppet/modules/munin/plugins/${name}": - source => $source, - mode => 0755, owner => root, group => 0; - } - munin::plugin { $name: - ensure => $ensure, - config => $config, - script_path_in => "/var/lib/puppet/modules/munin/plugins", - } - } + case $ensure { + "absent": { munin::plugin{ $name: ensure => absent } } + default: { + file { + "/var/lib/puppet/modules/munin/plugins/${name}": + source => $source, + mode => 0755, owner => root, group => 0; + } + munin::plugin { $name: + ensure => $ensure, + config => $config, + script_path_in => "/var/lib/puppet/modules/munin/plugins", + } } + } } -- cgit v1.2.3 From b7228e65b66b72709f59709618a7c7be1ce795ef Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jun 2012 13:03:50 -0300 Subject: refactor things for >2.7 --- manifests/plugin.pp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index fec7b6b..af8b44a 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -21,18 +21,12 @@ define munin::plugin ( file { $plugin: ensure => absent, } } default: { - case $::kernel { - openbsd: { $basic_require = File['/var/run/munin'] } - default: { $basic_require = Package['munin-node'] } - } - if $require { - $real_require = [ $require, $basic_require ] - } else { - $real_require = $basic_require - } file { $plugin: ensure => "${real_script_path}/${plugin_src}", - require => $real_require, + require => $::kernel ? { + OpenBSD => File['/var/run/munin'], + default => Package['munin-node'] + }, notify => Service['munin-node']; } if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ @@ -56,11 +50,6 @@ define munin::plugin ( content => "[${name}]\n$config\n", mode => 0644, owner => root, group => 0, } - if $require { - File[$plugin_conf]{ - require +> $require, - } - } } } } -- cgit v1.2.3 From 64a6aa3cf73bdc9d75d34b6fbcd04f5e7f34e923 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 9 Jun 2012 21:17:47 -0300 Subject: use class parameters --- manifests/client.pp | 6 +++++- templates/munin-node.conf.Debian.etch | 6 +++--- templates/munin-node.conf.default | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifests/client.pp b/manifests/client.pp index 5080f99..79d275e 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -3,7 +3,11 @@ # See LICENSE for the full license granted to you. # Adapted and improved by admin(at)immerda.ch -class munin::client { +class munin::client( + $allow = hiera('munin_client_allow',['127.0.0.1']), + $host = hiera('munin_host','*'), + $port = hiera('munin_port','4949') +) { case $::operatingsystem { openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch index 17162d8..44638e7 100644 --- a/templates/munin-node.conf.Debian.etch +++ b/templates/munin-node.conf.Debian.etch @@ -9,8 +9,8 @@ background 1 setseid 1 # Which host/port to bind to; -host <%= scope.function_hiera('munin_host','*') %> -port <%= scope.function_hiera('munin_port','4949') %> +host <%= scope.lookupvar('munin::client::host') %> +port <%= scope.lookupvar('munin::client::port') %> user root group root setsid yes @@ -33,7 +33,7 @@ host_name <%= fqdn %> # regular expression, due to brain damage in Net::Server, which # doesn't understand CIDR-style network notation. You may repeat # the allow line as many times as you'd like -<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +<% scope.lookupvar('munin::client::allow').each do |allow| -%> allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index adc2408..9684bd5 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -37,7 +37,7 @@ host_name <%= fqdn %> # network notation unless the perl module Net::CIDR is installed. You # may repeat the allow line as many times as you'd like -<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +<% scope.lookupvar('munin::client::allow').each do |allow| -%> allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> @@ -53,9 +53,9 @@ allow <%= "^#{Regexp.escape(allow)}$" %> # cidr_deny 192.0.2.42/32 # Which address to bind to; -host <%= scope.function_hiera('munin_host','*') %> +host <%= scope.lookupvar('munin::client::host') %> # host 127.0.0.1 # And which port -port <%= scope.function_hiera('munin_port','4949') %> +port <%= scope.lookupvar('munin::client::port') %> -- cgit v1.2.3 From b4a30b6255ca495b98803317ad691fa1a26a4987 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 10 Jun 2012 19:25:32 -0300 Subject: config for df --- manifests/plugins/base.pp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index d26aaeb..c6b88ed 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -5,6 +5,11 @@ class munin::plugins::base { processes, swap, uptime, users, vmstat ]: ensure => present, } + file{'/etc/munin/plugin-conf.d/df': + content => "[df*]\nenv.exclude none unknown iso9660 squashfs udf romfs ramfs debugfs binfmt_misc rpc_pipefs fuse.gvfs-fuse-daemon\n", + require => Munin::Plugin[df], + owner => root, group => 0, mode => 0644; + } include munin::plugins::interfaces case $::kernel { -- cgit v1.2.3 From c95f0b2fcf4f35b1a7ae3ad9c04600a32ab2bb43 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 13 Jun 2012 20:40:57 -0300 Subject: migrate away from hiera stuff --- README | 6 +++--- manifests/client.pp | 16 +++++++++++----- manifests/client/base.pp | 6 +++--- manifests/host.pp | 2 +- manifests/register.pp | 19 ++----------------- manifests/register/snmp.pp | 9 ++------- templates/client.erb | 8 ++++---- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/README b/README index 22bb19f..1e47d27 100644 --- a/README +++ b/README @@ -28,7 +28,7 @@ To use this module, follow these directions: a. Your modules directory will need all the files included in this repository placed under a directory called "munin" - b. Add your hiera storage value for munin_allow which indicates what IP should be allowed to + b. Add your class parameter for munin::client::allow which indicates what IP should be allowed to connect to your individual munin-nodes (this is typically your main munin host's IP): munin_allow: '192.168.0.1' @@ -68,9 +68,9 @@ To use this module, follow these directions: f. If you have Linux-Vservers configured, you will likely have multiple munin-node processes competing for the default port 4949, for those nodes, set an alternate port for munin-node - to run on by putting something similar to the following in hiera's node scope: + to run on by putting something similar to the following class parameter: - munin_port: 4948 + port => 4948 g. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto For CentOS this is enabled in the default header config diff --git a/manifests/client.pp b/manifests/client.pp index 79d275e..934d23a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -4,9 +4,11 @@ # Adapted and improved by admin(at)immerda.ch class munin::client( - $allow = hiera('munin_client_allow',['127.0.0.1']), - $host = hiera('munin_host','*'), - $port = hiera('munin_port','4949') + $allow = [ '127.0.0.1' ], + $host = '*', + $port = '4949', + $manage_shorewall = false, + $shorewall_collector_source = 'net' ) { case $::operatingsystem { openbsd: { include munin::client::openbsd } @@ -16,7 +18,11 @@ class munin::client( centos: { include munin::client::package } default: { include munin::client::base } } - if hiera('use_shorewall',false) { - include shorewall::rules::munin + if $munin::client::manage_shorewall { + class{'shorewall::rules::munin': + munin_port => $port, + munin_collector => delete($allow,'127.0.0.1'), + collector_source => $shorewall_collector_source, + } } } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 80a25c5..1cba47b 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,6 +1,4 @@ -class munin::client::base( - $munin_allow = hiera('munin_allow','127.0.0.1') -) { +class munin::client::base { service { 'munin-node': ensure => running, enable => true, @@ -17,6 +15,8 @@ class munin::client::base( mode => 0644, owner => root, group => 0, } munin::register { $::fqdn: + host => $munin::client::host, + port => $munin::client::port, config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], } include munin::plugins::base diff --git a/manifests/host.pp b/manifests/host.pp index 524cddf..b828e35 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -37,7 +37,7 @@ class munin::host( content => "4,34 * * * * root if $(ps ax | grep -v grep | grep -q munin-run); then killall munin-run; fi\n", owner => root, group => 0, mode => 0644; } - if hiera('use_shorewall',false) { + if $munin::host::manage_shorewall { include shorewall::rules::out::munin } } diff --git a/manifests/register.pp b/manifests/register.pp index 14019d0..2645542 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -1,6 +1,6 @@ define munin::register ( - $host = 'absent', - $port = 'absent', + $host = $::fqdn, + $port = '4949', $description = 'absent', $config = [] ) @@ -8,21 +8,6 @@ define munin::register ( $fhost = $name $client_type = 'client' - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } - - $hiera_munin_host = hiera('munin_host','') - $munin_host_real = $host ? { - 'absent' => $hiera_munin_host ? { - '' => $::fqdn, - 'fqdn' => $::fqdn, - default => $hiera_munin_host - }, - default => $host - } - @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": target => '/etc/munin/munin.conf', content => template("munin/client.erb"), diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index 3007b67..78c3e91 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -1,18 +1,13 @@ define munin::register::snmp ( $community = 'public', $description = 'absent', - $port = 'absent' + $port = '4949', + $host = $::fqdn ) { $fhost = $name - $munin_host_real = $::fqdn $client_type = 'snmp' $config = [ 'use_node_name no' ] - $munin_port_real = $port ? { - 'absent' => hiera('munin_port','4949'), - default => $port - } - exec { "munin_register_snmp_${fhost}": command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", diff --git a/templates/client.erb b/templates/client.erb index 8c93cc5..7131ade 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -1,19 +1,19 @@ <% # Downcase all information dom = scope.lookupvar('::domain').downcase - host = scope.lookupvar('::hostname').downcase + h = scope.lookupvar('::hostname').downcase %> ### Munin client from Puppet template # Domain: <%= dom %> -# Registered on: <%= host %> +# Registered on: <%= h %> # Type: <%= client_type %> <% if description != 'absent' -%> # Description: <%= description.gsub!(/\n/, ' ') %> <% end -%> [<%= fhost.downcase %>] - address <%= munin_host_real %> - port <%= munin_port_real %> + address <%= host %> + port <%= port %> <% if config -%><% config.each do |val| -%> <%= val -%> <% end -%><% end -%> -- cgit v1.2.3 From 1ca3978ff3094c01a56feaee6c37fc82e3224d15 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 18 Jun 2012 15:40:22 -0300 Subject: if it's * it should be collected by fqdn otherwise directly by what is given to be listened on --- manifests/client/base.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 1cba47b..84ba9b2 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -15,7 +15,10 @@ class munin::client::base { mode => 0644, owner => root, group => 0, } munin::register { $::fqdn: - host => $munin::client::host, + host => $munin::client::host ? { + '*' => $::fqdn, + default => $munin::client::host + }, port => $munin::client::port, config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], } -- cgit v1.2.3 From a3e8f8ed1861d0a253b1605557e195f2530c2ae8 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 24 Jun 2012 19:21:41 -0400 Subject: correct naming --- manifests/register.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/register.pp b/manifests/register.pp index 2645542..9257ca1 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -8,7 +8,7 @@ define munin::register ( $fhost = $name $client_type = 'client' - @@concat::fragment{ "munin_client_${fhost}_${munin_port_real}": + @@concat::fragment{ "munin_client_${fhost}_${port}": target => '/etc/munin/munin.conf', content => template("munin/client.erb"), tag => 'munin', -- cgit v1.2.3 From 0161b29068725dfde73e7416c1d745b7fe31b423 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 27 Jun 2012 15:41:57 -0400 Subject: change site-munin to site_munin for 2.7 --- manifests/host.pp | 6 +++--- manifests/host/cgi.pp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/host.pp b/manifests/host.pp index 9d30d6a..0d069e1 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -12,9 +12,9 @@ class munin::host inherits munin File <<| tag == 'munin' |>> file{'/etc/munin/munin.conf.header': - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", - "puppet:///modules/site-munin/config/host/munin.conf.header.$operatingsystem", - "puppet:///modules/site-munin/config/host/munin.conf.header", + source => [ "puppet:///modules/site_munin/config/host/${fqdn}/munin.conf.header", + "puppet:///modules/site_munin/config/host/munin.conf.header.$operatingsystem", + "puppet:///modules/site_munin/config/host/munin.conf.header", "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem", "puppet:///modules/munin/config/host/munin.conf.header" ], notify => Exec['concat_/etc/munin/munin.conf'], diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index cbf1052..13669ed 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -18,9 +18,9 @@ class munin::host::cgi inherits munin::host { } file{'/etc/logrotate.d/munin': - source => [ "puppet:///modules/site-munin/config/host/${fqdn}/logrotate", - "puppet:///modules/site-munin/config/host/logrotate.$operatingsystem", - "puppet:///modules/site-munin/config/host/logrotate", + source => [ "puppet:///modules/site_munin/config/host/${fqdn}/logrotate", + "puppet:///modules/site_munin/config/host/logrotate.$operatingsystem", + "puppet:///modules/site_munin/config/host/logrotate", "puppet:///modules/munin/config/host/logrotate.$operatingsystem", "puppet:///modules/munin/config/host/logrotate" ], owner => root, group => 0, mode => 0644; -- cgit v1.2.3 From 04e9748b3a967ddfa876cc1e8831cde0afd2a51a Mon Sep 17 00:00:00 2001 From: kwadronaut Date: Thu, 28 Jun 2012 20:50:28 +0200 Subject: Default munin htmldir in Debian moved some time ago to /var/cache/munin/www This commit makes sure that you have it set correctly --- files/config/host/munin.conf.header.Debian | 2 +- manifests/host/cgi.pp | 2 +- templates/site.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/config/host/munin.conf.header.Debian b/files/config/host/munin.conf.header.Debian index 082f01f..771d50d 100644 --- a/files/config/host/munin.conf.header.Debian +++ b/files/config/host/munin.conf.header.Debian @@ -4,7 +4,7 @@ # databases, the HTML output, and the logs, severally. They all # must be writable by the user running munin-cron. dbdir /var/lib/munin -htmldir /var/www/munin +htmldir /var/cache/munin/www logdir /var/log/munin rundir /var/run/munin diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 13669ed..3156314 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -3,7 +3,7 @@ class munin::host::cgi inherits munin::host { case $operatingsystem { debian: { exec { 'set_modes_for_cgi': - command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/munin/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/www/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/cache/munin/www/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/www/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', refreshonly => true, subscribe => File['/etc/munin/munin.conf.header'], } diff --git a/templates/site.conf b/templates/site.conf index 549437c..52ddb53 100644 --- a/templates/site.conf +++ b/templates/site.conf @@ -1,6 +1,6 @@ ServerName <%= name %> - DocumentRoot /var/www/munin/ + DocumentRoot /var/cache/munin/www/ order allow,deny Allow from all -- cgit v1.2.3 From 1d429bf94412228de056b4517ac4b1e6548b9bca Mon Sep 17 00:00:00 2001 From: kwadronaut Date: Wed, 18 Jul 2012 12:00:28 -0700 Subject: Fixing FSH issue for Debian and adding a note about the change from site-munin to site_munin --- README | 3 +++ manifests/host/cgi.pp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README b/README index 754f652..309d63d 100644 --- a/README +++ b/README @@ -102,3 +102,6 @@ To use this module, follow these directions: For CentOS this is enabled in the default header config j. Per default (on CentOS) munin will send warnings and critical messages to root + +== Notes for existing users == +The name of the helper module changed from site-munin to site_munin. See http://projects.puppetlabs.com/issues/4314 for more details on naming. diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 3156314..8b35d8b 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -3,7 +3,7 @@ class munin::host::cgi inherits munin::host { case $operatingsystem { debian: { exec { 'set_modes_for_cgi': - command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/cache/munin/www/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/www/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/cache/munin/www/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/cache/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', refreshonly => true, subscribe => File['/etc/munin/munin.conf.header'], } -- cgit v1.2.3 From 3053b8b340b86d7fd23d2f0c8450a83f3991baef Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 19 Jul 2012 03:22:46 -0400 Subject: Fix requirements for plugins When including munin::host without explicitly including munin::client, puppet fails to run with the following message: Could not find dependent Service[munin-node] for File[/etc/munin/plugins] at /tmp/vagrant-puppet/modules-0/munin/manifests/plugins/setup.pp:14 This is because munin::host declares a munin plugin, and in turn this one creates a dependency on the 'munin-node' package and service. Since this dependency is not fulfilled, the run fails. The munin::plugins::setup class needs to fulfill its own dependencies by including munin::client. Signed-off-by: Gabriel Filion --- manifests/plugins/setup.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index c2c5ed3..853bc00 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -1,4 +1,8 @@ class munin::plugins::setup { + + # This is required for the munin-node service and package requirements below. + include munin::client + file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: source => "puppet:///modules/common/empty", -- cgit v1.2.3 From 405cd4fcc4639e4c9f204bcebf852aeaf6a1b129 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 12 Sep 2012 13:04:33 +0200 Subject: add kvm plugins --- files/plugins/kvm_cpu | 101 +++++++++++++++++++++++++++++++++ files/plugins/kvm_io | 110 ++++++++++++++++++++++++++++++++++++ files/plugins/kvm_mem | 107 +++++++++++++++++++++++++++++++++++ files/plugins/kvm_net | 143 +++++++++++++++++++++++++++++++++++++++++++++++ manifests/plugins/kvm.pp | 7 +++ 5 files changed, 468 insertions(+) create mode 100644 files/plugins/kvm_cpu create mode 100644 files/plugins/kvm_io create mode 100644 files/plugins/kvm_mem create mode 100644 files/plugins/kvm_net create mode 100644 manifests/plugins/kvm.pp diff --git a/files/plugins/kvm_cpu b/files/plugins/kvm_cpu new file mode 100644 index 0000000..f48d9f0 --- /dev/null +++ b/files/plugins/kvm_cpu @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 +# +# Munin plugin to show CPU used by vm +# +# Copyright Maxence Dunnewind, Rodolphe Quiédeville +# +# License : GPLv3 +# +# parsed environment variables: +# vmsuffix: part of vm name to be removed +# +#%# capabilities=autoconf +#%# family=contrib + +import re, os, sys +from subprocess import Popen, PIPE + +def config(vm_names): + ''' Print the plugin's config + @param vm_names : a list of "cleaned" vms' name + ''' + percent = len(filter(lambda x: x[0:3] == 'cpu' and x[3] != ' ', open('/proc/stat', 'r').readlines())) * 100 + + base_config = """graph_title KVM Virtual Machine CPU usage +graph_vlabel %% +graph_category KVM +graph_scale no +graph_period second +graph_info This graph shows the current CPU used by virtual machines +graph_args --base 1000 -r --lower-limit 0 --upper-limit %d""" % percent + print base_config + draw = "AREA" + for vm in vm_names: + print "%s_cpu.label %s" % (vm, vm) + print "%s_cpu.min 0" % vm + print "%s_cpu.type DERIVE" % vm + print "%s_cpu.draw %s" % (vm, draw) + print "%s_cpu.info percent of cpu time used by virtual machine" % vm + draw = "STACK" + + +def clean_vm_name(vm_name): + ''' Replace all special chars + @param vm_name : a vm's name + @return cleaned vm's name + ''' + + # suffix part defined in conf + suffix = os.getenv('vmsuffix') + if suffix: + vm_name = re.sub(suffix,'',vm_name) + + return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name) + +def detect_kvm(): + ''' Check if kvm is installed + ''' + kvm = Popen("which kvm", shell=True, stdout=PIPE) + kvm.communicate() + return not bool(kvm.returncode) + +def find_vm_names(pids): + '''Find and clean vm names from pids + @return a dictionnary of {pids : cleaned vm name} + ''' + result = {} + for pid in pids: + cmdline = open("/proc/%s/cmdline" % pid, "r") + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + return result + +def list_pids(): + ''' Find the pid of kvm processes + @return a list of pids from running kvm + ''' + pid = Popen("pidof qemu-kvm kvm", shell=True, stdout=PIPE) + return pid.communicate()[0].split() + +def fetch(vms): + ''' Fetch values for a list of pids + @param dictionnary {kvm_pid: cleaned vm name} + ''' + for ( pid, name ) in vms.iteritems(): + ( user, system ) = open("/proc/%s/stat" % pid, 'r').readline().split(' ')[13:15] + print '%s_cpu.value %d' % ( name, int(user) + int(system) ) + +if __name__ == "__main__": + if len(sys.argv) > 1: + if sys.argv[1] in ['autoconf', 'detect']: + if detect_kvm(): + print "yes" + else: + print "no" + elif sys.argv[1] == "config": + config(find_vm_names(list_pids()).values()) + else: + fetch(find_vm_names(list_pids())) + else: + fetch(find_vm_names(list_pids())) diff --git a/files/plugins/kvm_io b/files/plugins/kvm_io new file mode 100644 index 0000000..602b2ca --- /dev/null +++ b/files/plugins/kvm_io @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 +# +# Munin plugin to show io by vm +# +# Copyright Maxence Dunnewind, Rodolphe Quiédeville +# +# License : GPLv3 +# +# parsed environment variables: +# vmsuffix: part of vm name to be removed +# +#%# capabilities=autoconf +#%# family=contrib + +import re, os, sys +from subprocess import Popen, PIPE + +def config(vm_names): + ''' Print the plugin's config + @param vm_names : a list of "cleaned" vms' name + ''' + base_config = """graph_title KVM Virtual Machine IO usage +graph_vlabel Bytes read(-)/written(+) per second +graph_category KVM +graph_info This graph shows the block device I/O used of virtual machines +graph_args --base 1024 + """ + print base_config + + for vm in vm_names: + print "%s_read.label %s" % (vm, vm) + print "%s_read.type COUNTER" % vm + print "%s_read.min 0" % vm + print "%s_read.draw LINE1" % vm + print "%s_read.info I/O used by virtual machine %s" % (vm, vm) + print "%s_write.label %s" % (vm, vm) + print "%s_write.type COUNTER" % vm + print "%s_write.min 0" % vm + print "%s_write.draw LINE1" % vm + print "%s_write.negative %s_read" % (vm, vm) + print "%s_write.info I/O used by virtual machine %s" % (vm, vm) + +def clean_vm_name(vm_name): + ''' Replace all special chars + @param vm_name : a vm's name + @return cleaned vm's name + ''' + # suffix part defined in conf + suffix = os.getenv('vmsuffix') + if suffix: + vm_name = re.sub(suffix,'',vm_name) + + return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name) + +def fetch(vms): + ''' Fetch values for a list of pids + @param dictionnary {kvm_pid: cleaned vm name} + ''' + res = {} + for pid in vms: + f = open("/proc/%s/io" % pid, "r") + for line in f.readlines(): + if "read_bytes" in line: + read = line.split()[1] + print "%s_read.value %s" % (vms[pid], read) + if "write_bytes" in line: + write = line.split()[1] + print "%s_write.value %s" % (vms[pid], write) + break + f.close() + +def detect_kvm(): + ''' Check if kvm is installed + ''' + kvm = Popen("which kvm", shell=True, stdout=PIPE) + kvm.communicate() + return not bool(kvm.returncode) + +def find_vm_names(pids): + '''Find and clean vm names from pids + @return a dictionnary of {pids : cleaned vm name} + ''' + result = {} + for pid in pids: + cmdline = open("/proc/%s/cmdline" % pid, "r") + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + return result + +def list_pids(): + ''' Find the pid of kvm processes + @return a list of pids from running kvm + ''' + pid = Popen("pidof qemu-kvm kvm", shell=True, stdout=PIPE) + return pid.communicate()[0].split() + +if __name__ == "__main__": + if len(sys.argv) > 1: + if sys.argv[1] in ['autoconf', 'detect']: + if detect_kvm(): + print "yes" + else: + print "no" + elif sys.argv[1] == "config": + config(find_vm_names(list_pids()).values()) + else: + fetch(find_vm_names(list_pids())) + else: + fetch(find_vm_names(list_pids())) diff --git a/files/plugins/kvm_mem b/files/plugins/kvm_mem new file mode 100644 index 0000000..c64d8ce --- /dev/null +++ b/files/plugins/kvm_mem @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 +# +# Munin plugin to show amount of memory used by vm +# +# Copyright Maxence Dunnewind, Rodolphe Quiédeville, Adrien Pujol +# +# License : GPLv3 +# +# parsed environment variables: +# vmsuffix: part of vm name to be removed +# +#%# capabilities=autoconf +#%# family=contrib + +import re, os, sys +from subprocess import Popen, PIPE + +def config(vm_names): + ''' Print the plugin's config + @param vm_names : a list of "cleaned" vms' name + ''' + base_config = """graph_title KVM Virtual Machine Memory usage +graph_vlabel Bytes +graph_category KVM +graph_info This graph shows the current amount of memory used by virtual machines +graph_args --base 1024 + """ + print base_config + draw = "AREA" + for vm in vm_names: + print "%s_mem.label %s" % (vm, vm) + print "%s_mem.type GAUGE" % vm + if draw == 'AREA': + print "%s_mem.min 0" % vm + print "%s_mem.draw %s" % (vm, draw) + print "%s_mem.info memory used by virtual machine %s" % (vm, vm) + draw = "STACK" + + +def clean_vm_name(vm_name): + ''' Replace all special chars + @param vm_name : a vm's name + @return cleaned vm's name + ''' + # suffix part defined in conf + suffix = os.getenv('vmsuffix') + if suffix: + vm_name = re.sub(suffix,'',vm_name) + + return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name) + +def fetch(vms): + ''' Fetch values for a list of pids + @param dictionnary {kvm_pid: cleaned vm name} + ''' + res = {} + for pid in vms: + try: + cmdline = open("/proc/%s/cmdline" % pid, "r") + amount = re.sub(r"^.*-m\x00(.*)\x00-smp.*$",r"\1", cmdline.readline()) + ammount = int(amount) * 1024 * 1024 + print "%s_mem.value %s" % (vms[pid], ammount) + except: + cmdline = open("/proc/%s/cmdline" % pid, "r") + amount = re.sub(r"^.*-m\x00(\d+).*$",r"\1", cmdline.readline()) + ammount = int(amount) * 1024 * 1024 + print "%s_mem.value %s" % (vms[pid], ammount) + +def detect_kvm(): + ''' Check if kvm is installed + ''' + kvm = Popen("which kvm", shell=True, stdout=PIPE) + kvm.communicate() + return not bool(kvm.returncode) + +def find_vm_names(pids): + '''Find and clean vm names from pids + @return a dictionnary of {pids : cleaned vm name} + ''' + result = {} + for pid in pids: + cmdline = open("/proc/%s/cmdline" % pid, "r") + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + return result + +def list_pids(): + ''' Find the pid of kvm processes + @return a list of pids from running kvm + ''' + pid = Popen("pidof qemu-kvm kvm", shell=True, stdout=PIPE) + return pid.communicate()[0].split() + +if __name__ == "__main__": + if len(sys.argv) > 1: + if sys.argv[1] in ['autoconf', 'detect']: + if detect_kvm(): + print "yes" + else: + print "no" + elif sys.argv[1] == "config": + config(find_vm_names(list_pids()).values()) + else: + fetch(find_vm_names(list_pids())) + else: + fetch(find_vm_names(list_pids())) diff --git a/files/plugins/kvm_net b/files/plugins/kvm_net new file mode 100644 index 0000000..6da0d90 --- /dev/null +++ b/files/plugins/kvm_net @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: set fileencoding=utf-8 +# +# Munin plugin to show the network I/O per vm +# On redhat based systems +# +# Copyright Igor Borodikhin +# Copyright Peter Meier +# +# License : GPLv3 +# +# +# parsed environment variables: +# vmsuffix: part of vm name to be removed +# +#%# capabilities=autoconf +#%# family=contrib + +import re, os, sys +from subprocess import Popen, PIPE + +def config(vm_names): + ''' Print the plugin's config + @param vm_names : a list of "cleaned" vms' name + ''' + base_config = """graph_title KVM Network I/O +graph_vlabel Bytes rx(-)/tx(+) per second +graph_category KVM +graph_info This graph shows the network I/O of the virtual machines +graph_args --base 1024 + """ + print base_config + for vm in vm_names: + print "%s_in.label %s" % (vm, vm) + print "%s_in.type COUNTER" % vm + print "%s_in.min 0" % vm + print "%s_in.draw LINE2" % vm + print "%s_out.negative %s_in" % (vm, vm) + print "%s_out.label %s" % (vm, vm) + print "%s_out.type COUNTER" % vm + print "%s_out.min 0" % vm + print "%s_out.draw LINE2" % vm + +def clean_vm_name(vm_name): + ''' Replace all special chars + @param vm_name : a vm's name + @return cleaned vm's name + ''' + # suffix part defined in conf + suffix = os.getenv('vmsuffix') + if suffix: + vm_name = re.sub(suffix,'',vm_name) + + return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name) + +def fetch(vms): + ''' Fetch values for a list of pids + @param dictionnary {kvm_pid: cleaned vm name} + ''' + res = {} + macs_to_inf = find_macs_to_inf() + interfaces = {} + for e in Popen('cat /proc/net/dev | awk \'{ print $1 ":" $9 }\'', shell=True, stdout=PIPE).communicate()[0].split('\n'): + s = e.split(':') + if len(s) == 3: + interfaces[s[0]] = (s[1],s[2]) + for pid in vms: + macs = get_vm_macs(pid) + for mac in macs: + inf = macs_to_inf[mac] + values = interfaces[inf] + if len(values) == 2: + print "%s_%s_in.value %s" % (vms[pid], inf, values[0]) + print "%s_%s_out.value %s" % (vms[pid], inf, values[1]) + +def detect_kvm(): + ''' Check if kvm is installed + ''' + kvm = Popen("which kvm", shell=True, stdout=PIPE) + kvm.communicate() + return not bool(kvm.returncode) + +def find_vm_names(pids): + '''Find and clean vm names from pids + @return a dictionnary of {pids : cleaned vm name} + ''' + result = {} + for pid in pids: + cmdline = open("/proc/%s/cmdline" % pid, "r") + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + return result + +def get_vm_macs(pid): + '''Find macs for a pid + @return the mac addresses for a specified pid + ''' + cmdline = open("/proc/%s/cmdline" % pid, "r") + line = cmdline.readline() + # macs are fe:... on the host + macs = [ re.sub(r"^\d{2}",'fe',p.split('=')[1]) for p in line.split(",") if re.match(r"^mac(addr)?=",p) ] + return macs + +def list_pids(): + ''' Find the pid of kvm processes + @return a list of pids from running kvm + ''' + pid = Popen("pidof qemu-kvm kvm", shell=True, stdout=PIPE) + return pid.communicate()[0].split() + +def find_macs_to_inf(): + ''' Find interfaces for vms + @return a dictionary of macs to inf + ''' + result = {} + inf = "" + kvm = Popen("ip a | grep -E -A 1 '(tap|vnet)' | awk '{print $2}' | grep -v '^$'", shell=True, stdout=PIPE) + res = kvm.communicate()[0].split('\n') + for line in res: + if len(line) > 0: + if re.match(r"^tap.*", line): + inf = re.sub(r"(tap[^:]+):", r"\1", line) + elif re.match(r"^vnet.*", line): + inf = re.sub(r"(vnet[^:]+):", r"\1", line) + else: + result[line] = inf + + return result + +if __name__ == "__main__": + if len(sys.argv) > 1: + if sys.argv[1] in ['autoconf', 'detect']: + if detect_kvm(): + print "yes" + else: + print "no" + elif sys.argv[1] == "config": + config(find_vm_names(list_pids()).values()) + else: + fetch(find_vm_names(list_pids())) + else: + fetch(find_vm_names(list_pids())) + diff --git a/manifests/plugins/kvm.pp b/manifests/plugins/kvm.pp new file mode 100644 index 0000000..7a1430f --- /dev/null +++ b/manifests/plugins/kvm.pp @@ -0,0 +1,7 @@ +class munin::plugins::kvm { + munin::plugin::deploy { + [ 'kvm_cpu', 'kvm_mem', 'kvm_net' ]:; + 'kvm_io': + config => 'user root'; + } +} -- cgit v1.2.3 From f85fe9d9b94a1f30dda6637722542884194edd39 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 15 Sep 2012 14:09:56 +0200 Subject: fix config and output --- files/plugins/kvm_net | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/files/plugins/kvm_net b/files/plugins/kvm_net index 6da0d90..c7aae2b 100644 --- a/files/plugins/kvm_net +++ b/files/plugins/kvm_net @@ -20,7 +20,7 @@ import re, os, sys from subprocess import Popen, PIPE -def config(vm_names): +def config(vms): ''' Print the plugin's config @param vm_names : a list of "cleaned" vms' name ''' @@ -31,16 +31,20 @@ graph_info This graph shows the network I/O of the virtual machines graph_args --base 1024 """ print base_config - for vm in vm_names: - print "%s_in.label %s" % (vm, vm) - print "%s_in.type COUNTER" % vm - print "%s_in.min 0" % vm - print "%s_in.draw LINE2" % vm - print "%s_out.negative %s_in" % (vm, vm) - print "%s_out.label %s" % (vm, vm) - print "%s_out.type COUNTER" % vm - print "%s_out.min 0" % vm - print "%s_out.draw LINE2" % vm + for pid in vms: + macs = get_vm_macs(pid) + i = 0 + for mac in macs: + print "%s_eth%s_in.label %s" % (vms[pid],i, vms[pid]) + print "%s_eth%s_in.type COUNTER" % (vms[pid], i) + print "%s_eth%s_in.min 0" % (vms[pid],i) + print "%s_eth%s_in.draw LINE2" % (vms[pid],i) + print "%s_eth%s_out.negative %s_in" % (vms[pid], i, vms[pid]) + print "%s_eth%s_out.label %s" % (vms[pid], i, vms[pid]) + print "%s_eth%s_out.type COUNTER" % (vms[pid], i) + print "%s_eth%s_out.min 0" % (vms[pid], i) + print "%s_eth%s_out.draw LINE2" % (vms[pid], i) + i += 1 def clean_vm_name(vm_name): ''' Replace all special chars @@ -67,12 +71,14 @@ def fetch(vms): interfaces[s[0]] = (s[1],s[2]) for pid in vms: macs = get_vm_macs(pid) + i = 0 for mac in macs: inf = macs_to_inf[mac] values = interfaces[inf] if len(values) == 2: - print "%s_%s_in.value %s" % (vms[pid], inf, values[0]) - print "%s_%s_out.value %s" % (vms[pid], inf, values[1]) + print "%s_eth%s_in.value %s" % (vms[pid], i, values[0]) + print "%s_eth%s_out.value %s" % (vms[pid], i, values[1]) + i += 1 def detect_kvm(): ''' Check if kvm is installed @@ -135,7 +141,7 @@ if __name__ == "__main__": else: print "no" elif sys.argv[1] == "config": - config(find_vm_names(list_pids()).values()) + config(find_vm_names(list_pids())) else: fetch(find_vm_names(list_pids())) else: -- cgit v1.2.3 From d304394caaf15c0bc1f23c5e57fabcdffd86b90d Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 15 Sep 2012 15:12:45 +0200 Subject: fix plugin --- files/plugins/kvm_net | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/plugins/kvm_net b/files/plugins/kvm_net index c7aae2b..bcad719 100644 --- a/files/plugins/kvm_net +++ b/files/plugins/kvm_net @@ -39,7 +39,7 @@ graph_args --base 1024 print "%s_eth%s_in.type COUNTER" % (vms[pid], i) print "%s_eth%s_in.min 0" % (vms[pid],i) print "%s_eth%s_in.draw LINE2" % (vms[pid],i) - print "%s_eth%s_out.negative %s_in" % (vms[pid], i, vms[pid]) + print "%s_eth%s_out.negative %s_eth%s_in" % (vms[pid], i, vms[pid], i) print "%s_eth%s_out.label %s" % (vms[pid], i, vms[pid]) print "%s_eth%s_out.type COUNTER" % (vms[pid], i) print "%s_eth%s_out.min 0" % (vms[pid], i) -- cgit v1.2.3 From a29438a07e9af6ccdcadd465492e527f6ba4a8ab Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 15 Sep 2012 16:18:54 +0200 Subject: cleanup plugins --- files/plugins/kvm_io | 3 +-- files/plugins/kvm_mem | 3 +-- files/plugins/kvm_net | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/files/plugins/kvm_io b/files/plugins/kvm_io index 602b2ca..43941f5 100644 --- a/files/plugins/kvm_io +++ b/files/plugins/kvm_io @@ -25,8 +25,7 @@ def config(vm_names): graph_vlabel Bytes read(-)/written(+) per second graph_category KVM graph_info This graph shows the block device I/O used of virtual machines -graph_args --base 1024 - """ +graph_args --base 1024""" print base_config for vm in vm_names: diff --git a/files/plugins/kvm_mem b/files/plugins/kvm_mem index c64d8ce..14fb793 100644 --- a/files/plugins/kvm_mem +++ b/files/plugins/kvm_mem @@ -25,8 +25,7 @@ def config(vm_names): graph_vlabel Bytes graph_category KVM graph_info This graph shows the current amount of memory used by virtual machines -graph_args --base 1024 - """ +graph_args --base 1024""" print base_config draw = "AREA" for vm in vm_names: diff --git a/files/plugins/kvm_net b/files/plugins/kvm_net index bcad719..c7b5aca 100644 --- a/files/plugins/kvm_net +++ b/files/plugins/kvm_net @@ -28,19 +28,18 @@ def config(vms): graph_vlabel Bytes rx(-)/tx(+) per second graph_category KVM graph_info This graph shows the network I/O of the virtual machines -graph_args --base 1024 - """ +graph_args --base 1024""" print base_config for pid in vms: macs = get_vm_macs(pid) i = 0 for mac in macs: - print "%s_eth%s_in.label %s" % (vms[pid],i, vms[pid]) + print "%s_eth%s_in.label %s_eth%s" % (vms[pid],i, vms[pid], i) print "%s_eth%s_in.type COUNTER" % (vms[pid], i) print "%s_eth%s_in.min 0" % (vms[pid],i) print "%s_eth%s_in.draw LINE2" % (vms[pid],i) print "%s_eth%s_out.negative %s_eth%s_in" % (vms[pid], i, vms[pid], i) - print "%s_eth%s_out.label %s" % (vms[pid], i, vms[pid]) + print "%s_eth%s_out.label %s_eth%s" % (vms[pid], i, vms[pid], i) print "%s_eth%s_out.type COUNTER" % (vms[pid], i) print "%s_eth%s_out.min 0" % (vms[pid], i) print "%s_eth%s_out.draw LINE2" % (vms[pid], i) -- cgit v1.2.3 From a33995ad702c6203314d1b9b68000ae931a35dc4 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 17 Oct 2012 21:38:41 +0200 Subject: new upstream config --- files/config/host/munin.conf.header.CentOS | 88 +++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 26 deletions(-) diff --git a/files/config/host/munin.conf.header.CentOS b/files/config/host/munin.conf.header.CentOS index 413cd84..f212ce0 100644 --- a/files/config/host/munin.conf.header.CentOS +++ b/files/config/host/munin.conf.header.CentOS @@ -5,26 +5,40 @@ # must be writable by the user running munin-cron. They are all # defaulted to the values you see here. # -# dbdir /var/lib/munin -# htmldir /var/www/html/munin -# logdir /var/log/munin -# rundir /var/run/munin +#dbdir /var/lib/munin +#htmldir /var/www/html/munin +htmldir /var/www/html/munin +#logdir /var/log/munin +#rundir /var/run/munin + +# Where to look for the HTML templates # -# tmpldir /etc/munin/templates +#tmpldir /etc/munin/templates -# (Exactly one) directory to include all files from. +# Where to look for the static www files +# +#staticdir /etc/munin/static + +# temporary cgi files are here. note that it has to be writable by +# the cgi user (usually nobody or httpd). # -# includedir /etc/munin/munin-conf.d +# cgitmpdir /var/lib/munin/cgi-tmp -# Make graphs show values per minute instead of per second -#graph_period minute +# (Exactly one) directory to include all files from. +includedir /etc/munin/conf.d + +# You can choose the time reference for "DERIVE" like graphs, and show +# "per minute", "per hour" values instead of the default "per second" +# +#graph_period second -# Graphics files are normaly generated by munin-graph, no matter if -# the graphs are used or not. You can change this to -# on-demand-graphing by following the instructions in -# http://munin.projects.linpro.no/wiki/CgiHowto +# Graphics files are generated either via cron or by a CGI process. +# See http://munin-monitoring.org/wiki/CgiHowto2 for more +# documentation. +# Since 2.0, munin-graph has been rewritten to use the cgi code. +# It is single threaded *by design* now. # -graph_strategy cgi +#graph_strategy cgi # munin-cgi-graph is invoked by the web server up to very many times at the # same time. This is not optimal since it results in high CPU and memory @@ -36,15 +50,41 @@ graph_strategy cgi # If the automatic CGI url is wrong for your system override it here: # -#cgiurl_graph /cgi-bin/munin-cgi-graph +#cgiurl_graph /munin-cgi/munin-cgi-graph + +# max_size_x and max_size_y are the max size of images in pixel. +# Default is 4000. Do not make it too large otherwise RRD might use all +# RAM to generate the images. +# +#max_size_x 4000 +#max_size_y 4000 -# munin-graph runs in parallel, the number of concurrent processes is -# 6. If you want munin-graph to not be parallel set to 0. If set too -# high it will slow down munin-graph. Some experiments are needed to -# determine how many are optimal on your system. On a multi-core -# system with good SCSI disks the number can probably be quite high. +# HTML files are normally generated by munin-html, no matter if the +# files are used or not. You can change this to on-demand generation +# by following the instructions in http://munin-monitoring.org/wiki/CgiHowto2 +# +# Notes: +# - moving to CGI for HTML means you cannot have graph generated by cron. +# - cgi html has some bugs, mostly you still have to launch munin-html by hand +# +html_strategy cron + +# munin-update runs in parallel. +# +# The default max number of processes is 16, and is probably ok for you. +# +# If set too high, it might hit some process/ram/filedesc limits. +# If set too low, munin-update might take more than 5 min. +# +# If you want munin-update to not be parallel set it to 0. # -#max_graph_jobs 6 +#max_processes 16 + +# RRD updates are per default, performed directly on the rrd files. +# To reduce IO and enable the use of the rrdcached, uncomment it and set it to +# the location of the socket that rrdcached uses. +# +#rrdcached_socket /var/run/rrdcached.sock # Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime # something changes (OK -> WARNING, CRITICAL -> OK, etc) @@ -53,11 +93,7 @@ graph_strategy cgi # # For those with Nagios, the following might come in handy. In addition, # the services must be defined in the Nagios server as well. -#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg - -contacts me -contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root -contact.me.always_send warning critical +#contact.nagios.command /usr/bin/send_nsca nagios.host.comm -c /etc/nsca.conf # a simple host tree #[localhost] -- cgit v1.2.3 From d43c6ae0fcf45411524d093d21f5cb5c01f7c830 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 27 Nov 2012 15:43:21 +0100 Subject: there are now official selinux plugins --- files/plugins/selinux_avcstats | 111 ----------------------------------------- files/plugins/selinuxenforced | 30 ----------- manifests/plugins/selinux.pp | 2 +- 3 files changed, 1 insertion(+), 142 deletions(-) delete mode 100755 files/plugins/selinux_avcstats delete mode 100755 files/plugins/selinuxenforced diff --git a/files/plugins/selinux_avcstats b/files/plugins/selinux_avcstats deleted file mode 100755 index b7d2dbb..0000000 --- a/files/plugins/selinux_avcstats +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -# -# Plugin to monitor SELinux's Access Vector Cache (AVC). -# -# config (required) -# autoconf (optional - used by munin-config) -# -# Lars Strand, 2007 -# -# -# Magic markers (used by munin-config and some installation scripts (i.e. -# optional)): -#%# family=auto -#%# capabilities=autoconf - - -AVCSTATS="/selinux/avc/cache_stats" - -if [ "$1" = "autoconf" ]; then - if [ -r $AVCSTATS ]; then - echo yes - exit 0 - else - echo no - exit 1 - fi -fi - -if [ "$1" = "config" ]; then - - echo "graph_title SELinux's Access Vector Cache" - echo 'graph_args -l 0 --base 1000' - echo 'graph_vlabel AVC operations' - echo 'graph_category selinux' - - echo 'lookups.label lookups' - echo 'lookups.type DERIVE' - echo 'lookups.min 0' - echo 'lookups.max 1000000000' - echo 'lookups.draw AREA' - echo 'lookups.colour ff0000' # Red - echo 'lookups.info Number of access vector lookups. This number is a good indicator of the load beeing placed on the AVC.' - - echo 'hits.label hits' - echo 'hits.type DERIVE' - echo 'hits.min 0' - echo 'hits.max 1000000000' - echo 'hits.draw STACK' - echo 'hits.colour 0022ff' # Blue - echo 'hits.info Number of access vector hits.' - - echo 'misses.label misses' - echo 'misses.type DERIVE' - echo 'misses.min 0' - echo 'misses.max 1000000000' - echo 'misses.draw STACK' - echo 'misses.colour 990000' # Darker red - echo 'misses.info Number of cache misses.' - - echo 'allocations.label allocations' - echo 'allocations.type DERIVE' - echo 'allocations.min 0' - echo 'allocations.max 100000000' - echo 'allocations.draw STACK' - echo 'allocations.colour ffa500' # Orange - echo 'allocations.info Number of AVC entries allocated.' - - echo 'reclaims.label reclaims' - echo 'reclaims.type DERIVE' - echo 'reclaims.min 0' - echo 'reclaims.max 1000000000' - echo 'reclaims.draw STACK' - echo 'reclaims.colour 00aaaa' # Darker turquoise - echo 'reclaims.info Number of current total reclaimed AVC entries. If this keeps changing, you may need to increase the cache size (/selinux/avc/cache_threshold).' - - echo 'frees.label frees' - echo 'frees.type DERIVE' - echo 'frees.min 0' - echo 'frees.max 1000000000' - echo 'frees.draw STACK' - echo 'frees.colour 00ff7f' # Spring green - echo 'frees.info Number of free AVC entries.' - - exit 0 -fi - -if [ -r $AVCSTATS ]; then - awk ' NR > 1 { - lookups += $1; - hits += $2; - misses += $3; - allocations += $4; - reclaims += $5; - frees += $6; - } END { - print "lookups.value " lookups; - print "hits.value " hits; - print "misses.value " misses; - print "allocations.value " allocations; - print "reclaims.value " reclaims; - print "frees.value " frees; - } ' < $AVCSTATS -else - echo "lookups.value U" - echo "hits.value U" - echo "misses.value U" - echo "allocations.value U" - echo "reclaims.value U" - echo "frees.value U" -fi - diff --git a/files/plugins/selinuxenforced b/files/plugins/selinuxenforced deleted file mode 100755 index e157e3d..0000000 --- a/files/plugins/selinuxenforced +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -*- sh -*- -# -# Plugin to monitor the status of selinux -# -# Contributed by admin(at)immerda.ch - -if [ "$1" = "autoconf" ]; then - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - echo 'graph_title enforced amount' - echo 'graph_args --upper-limit 1 -l 0 ' - echo 'graph_vlabel Is the system selinux enforced?' - echo 'graph_scale no\n'; - echo 'graph_category selinux' - echo 'enforced.label IsEnforced' - #echo 'enforced.draw AREA' - echo 'enforced.draw LINE2' - - exit 0 -fi - -if [ -r /selinux/enforce ]; then - echo -n "enforced.value " && cat /selinux/enforce -else - echo "enforced.value 0" -fi diff --git a/manifests/plugins/selinux.pp b/manifests/plugins/selinux.pp index faf610a..d094f35 100644 --- a/manifests/plugins/selinux.pp +++ b/manifests/plugins/selinux.pp @@ -1,3 +1,3 @@ class munin::plugins::selinux { - munin::plugin::deploy { [ 'selinuxenforced', 'selinux_avcstats' ]: } + munin::plugin{ [ 'selinux_avcstat' ]: } } -- cgit v1.2.3 From adbfc508abf5bda607795f7bf02f9581e78b17a5 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 27 Nov 2012 21:54:19 +0100 Subject: filter out many of the useless interfaces that show up --- manifests/plugins/interfaces.pp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index cc79259..33fef33 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,21 +1,23 @@ # handle if_ and if_err_ plugins -class munin::plugins::interfaces { +class munin::plugins::interfaces { + + # filter out many of the useless interfaces that show up + $ifs = regsubst(reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+'), '(.+)', 'if_\\1') - $ifs = regsubst(split($::interfaces, " |,"), "(.+)", "if_\\1") munin::plugin { - $ifs: ensure => "if_"; + $ifs: ensure => 'if_'; } case $::operatingsystem { openbsd: { - $if_errs = regsubst(split($::interfaces, " |,"), "(.+)", "if_errcoll_\\1") + $if_errs = regsubst(split($::interfaces, ' |,'), '(.+)', 'if_errcoll_\\1') munin::plugin{ - $if_errs: ensure => "if_errcoll_"; + $if_errs: ensure => 'if_errcoll_'; } } default: { - $if_errs = regsubst(split($::interfaces, " |,"), "(.+)", "if_err_\\1") + $if_errs = regsubst(split($::interfaces, ' |,'), '(.+)', 'if_err_\\1') munin::plugin{ - $if_errs: ensure => "if_err_"; + $if_errs: ensure => 'if_err_'; } } } -- cgit v1.2.3 From bc23eb26287c343358a6bfbb9a776a67db39d02e Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 27 Nov 2012 22:08:14 +0100 Subject: improve regexp --- manifests/plugins/interfaces.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index 33fef33..7e9819c 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -2,20 +2,21 @@ class munin::plugins::interfaces { # filter out many of the useless interfaces that show up - $ifs = regsubst(reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+'), '(.+)', 'if_\\1') + $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+') + $ifs = regsubst($real_ifs, '(.+)', "if_\\1") munin::plugin { $ifs: ensure => 'if_'; } case $::operatingsystem { openbsd: { - $if_errs = regsubst(split($::interfaces, ' |,'), '(.+)', 'if_errcoll_\\1') + $if_errs = regsubst($real_ifs, '(.+)', "if_errcoll_\\1") munin::plugin{ $if_errs: ensure => 'if_errcoll_'; } } default: { - $if_errs = regsubst(split($::interfaces, ' |,'), '(.+)', 'if_err_\\1') + $if_errs = regsubst($real_ifs, '(.+)', "if_err_\\1") munin::plugin{ $if_errs: ensure => 'if_err_'; } -- cgit v1.2.3 From 005c89cfbd924e204e87a11248b0efe42d5cc8d6 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 27 Nov 2012 23:36:25 +0100 Subject: exclude more weird interfaces --- manifests/plugins/interfaces.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index 7e9819c..a7e8ce6 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -2,7 +2,7 @@ class munin::plugins::interfaces { # filter out many of the useless interfaces that show up - $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+') + $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+|__temp\d+') $ifs = regsubst($real_ifs, '(.+)', "if_\\1") munin::plugin { -- cgit v1.2.3 From 6a440c04ee381ff184a7b7c9f3a98ca61337df92 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 29 Nov 2012 00:24:20 +0100 Subject: filter correct unwanted interfaces --- manifests/plugins/interfaces.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index a7e8ce6..da89ed0 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -2,7 +2,7 @@ class munin::plugins::interfaces { # filter out many of the useless interfaces that show up - $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+:\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+|__temp\d+') + $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+_\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+|__tmp\d+') $ifs = regsubst($real_ifs, '(.+)', "if_\\1") munin::plugin { -- cgit v1.2.3 From 17106c70cbf414ed54606b7a2f3bcc66cb36b9df Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 6 Dec 2012 21:42:51 +0100 Subject: update with latest upstream --- templates/munin-node.conf.default | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index 9684bd5..ff9fbb1 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -16,9 +16,7 @@ user root group 0 # Regexps for files to ignore - -ignore_file ~$ -#ignore_file [#~]$ # FIX doesn't work. '#' starts a comment +ignore_file [\#~]$ ignore_file DEADJOE$ ignore_file \.bak$ ignore_file %$ -- cgit v1.2.3 From 630f4d609e1e58a74abb04963ce68c9fc4bab4a1 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 6 Dec 2012 22:11:10 +0100 Subject: replace xen-cpu plugin with a better plugin --- files/plugins/xen-cpu | 121 ----------------------------- files/plugins/xen_cpu | 189 ++++++++++++++++++++++++++++++++++++++++++++++ manifests/plugins/dom0.pp | 2 +- 3 files changed, 190 insertions(+), 122 deletions(-) delete mode 100755 files/plugins/xen-cpu create mode 100644 files/plugins/xen_cpu diff --git a/files/plugins/xen-cpu b/files/plugins/xen-cpu deleted file mode 100755 index b456a14..0000000 --- a/files/plugins/xen-cpu +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/perl -wT -# -# Script to minitor the cpu usage of Xen domains -# -# Author: Adam Crews shroom com> -# -# License: GPL -# Based on the origional xen script from Matthias Pfafferodt, syntron at web.de -# -# Note: Your munin config must run this as root. -# -# Parameters -# config (required) -# autoconf (optional - used by munin-config) -# -#%# family=auto -#%# capabilities=autoconf - -# Define where to find xm tools -my $XM = '/usr/sbin/xm'; -my $XMTOP = '/usr/sbin/xentop'; - -############## -# You should not need to edit anything below here -# - -use strict; - -$ENV{PATH} = '/bin:/usr/bin:/usr/sbin'; - -# we cache xm list for 5 min for perfomance reasons -system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); -system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 > /var/lib/munin/plugin-state/xm_top.state'); - -my $arg; undef($arg); -if (defined($ARGV[0])) { - $arg = 'config' if ($ARGV[0] eq 'config'); - $arg = 'autoconf' if ($ARGV[0] eq 'autoconf'); - - if ( "$arg" eq 'autoconf') { - if ( -e $XM && -e $XMTOP ) { - print "yes\n"; - exit 0; - } else { - print "no ($XM and/or $XMTOP not found\n"; - exit 1; - } - } - - if ( "$arg" eq 'config') { - my %cnf; undef(%cnf); - %cnf = ( - 'graph_title' => 'Xen Domain CPU Usage', - 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid', - 'graph_vlabel' => 'Percent (%)', - 'graph_category' => 'xen', - 'graph_info' => 'Display the % of CPU Usage for each domain', - ); - - my @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; - # the header line is not in the cached file - #shift(@domains); # we dont need the header line - my $cnt = "0"; - foreach my $domain ( @domains ) { - my ($dom,undef) = split(/\s/, $domain, 2); - # we need to change - and . to _ or things get weird with the graphs - # some decent quoting would probably fix this, but this works for now - $dom =~ s/[-.]/_/g; - - $cnf{ "$dom" . '.label' } = "$dom"; - $cnf{ "$dom" . '.draw' } = 'STACK'; - $cnf{ "$dom" . '.min' } = '0'; - $cnf{ "$dom" . '.max' } = '100'; - $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom"; - - if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; } - $cnt++; - } - - foreach my $key (sort(keys(%cnf))) { - print "$key $cnf{$key}\n"; - } - exit 0; - } -} - -# Nothing was passed as an argument, so let's just return the proper values - -my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; - -# remove the first 4 items that are junk that we don't need. -shift(@stats); -shift(@stats); -shift(@stats); -shift(@stats); - -my %vals; undef(%vals); - -foreach my $domain (@stats) { - # trim the leading whitespace - $domain =~ s/^\s+//; - my @v_tmp = split(/\s+/, $domain); - - # we need to change - and . to _ or things get weird with the graphs - # some decent quoting would probably fix this, but this works for now - $v_tmp[0] =~ s/[-.]/_/g; - - $vals{$v_tmp[0]}{'cpu_percent'} = $v_tmp[3]; - $vals{$v_tmp[0]}{'vcpu'} = $v_tmp[8]; - if ( $vals{$v_tmp[0]}{'vcpu'} =~ m/n\/a/ ) { - my $cpu = `grep -c "processor" < /proc/cpuinfo`; - if ( $cpu =~ m/^(\d+)$/ ) { - $vals{$v_tmp[0]}{'vcpu'} = $1; - } - } -} - -foreach my $key (sort(keys(%vals))) { - print "$key.value " . ($vals{$key}{'cpu_percent'}/$vals{'Domain_0'}{'vcpu'}), "\n"; -} - diff --git a/files/plugins/xen_cpu b/files/plugins/xen_cpu new file mode 100644 index 0000000..382c8b5 --- /dev/null +++ b/files/plugins/xen_cpu @@ -0,0 +1,189 @@ +#!/usr/bin/perl -w +# +# xen_cpu_v2.pl 1.00 +# Script to minitor the CPU usage of Xen domains +# Zoltan HERPAI (c) 2009, wigyori@uid0.hu +# +# Based loosely on Adam Crews' xen_cpu script +# +# This script tries to measure the CPU usage of the Xen guests +# accurately. +# The problem with the current monitoring script is that these +# scripts use the CPU output of xentop or xm list, which might be +# inaccurate due to the resources used up at the time of the query by +# the xm or xentop command. +# +# This script stores the previous value of the CPU sec value of the given +# guests in a tempfile, then does some simple calculations to get the real +# CPU usage percentage of the guests. +# + +#%# family=auto +#%# capabilities=autoconf + +use strict; +use POSIX; + +# Define where to find xm tools +my $XM = '/usr/sbin/xm'; +my $XMTOP = '/usr/sbin/xentop'; +my $curtime = time(); +my $basename = `/usr/bin/env basename $0`; chop ($basename); +my $TEMPFILE = "/tmp/$basename"; + +my $debug = 0; + +############## +# You should not need to edit anything below here +# + +$ENV{PATH} = '/bin:/usr/bin:/usr/sbin'; + +my $arg; +if ( defined($ARGV[0]) ) +{ + if ( $ARGV[0] eq 'config' ) + { + $arg = 'config'; + } + if ( $ARGV[0] eq 'autoconf' ) + { + $arg = 'autoconf'; + } + + if ( $arg eq 'autoconf') + { + if ( -e $XM && -e $XMTOP ) + { + print "yes\n"; + exit 0; + } + else + { + print "no ($XM and/or $XMTOP not found\n"; + exit 1; + } + } + + if ( $arg eq 'config' ) + { + my %cnf; + %cnf = ( + 'graph_title' => 'Xen Domain CPU Usage v2', + 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid', + 'graph_vlabel' => 'Percent (%)', + 'graph_category' => 'xen', + 'graph_info' => 'Display the % of CPU Usage for each domain', + ); + + my @domains = `$XM list`; + my $cnt = 0; + shift(@domains); # we dont need the header line + foreach my $domain ( @domains ) + { + my ($dom,undef) = split(/\s/, $domain, 2); + $dom =~ s/[-.]/_/g; + $cnf{ "$dom" . '.label' } = "$dom"; + $cnf{ "$dom" . '.draw' } = 'STACK'; + $cnf{ "$dom" . '.min' } = '0'; + $cnf{ "$dom" . '.max' } = '100'; + $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom"; +# $cnf{ "$dom" . '.draw' } = 'AREA'; + if ( $cnt == 0 ) + { + $cnf{ "$dom" . '.draw' } = 'AREA'; + } + $cnt++; + } + foreach my $key (sort(keys(%cnf))) + { + print "$key $cnf{$key}\n"; + } + exit 0; + } +} + +my @xmlist = `$XM list`; +shift (@xmlist); + +my %dom; my $name; my $oldtime; +# Read old data +if ( -e $TEMPFILE ) +{ + open(FH, "<", $TEMPFILE) or die $!; + $oldtime = ; + + if ( $debug ) + { + print "Oldtime: $oldtime\n"; + } + + while () + { + # Get the guest name and its CPU usage, and store it in $dom + $_ =~ /(\S+)\s+\S+\s+\S+\s+\d+\s+\S+\s+(\S+)/; + $dom{$1}->{'oldtime'} = $2; + } + + close FH; +} + +my $diff; my $cpusum = 0; +foreach my $domain ( @xmlist ) +{ + # Get the domains' name and current CPU usage, store it in $dom + $domain =~ /(\S+)\s+\S+\s+\S+\s+\d+\s+\S+\s+(\S+)/; + $dom{$1}->{'newtime'} = $2; + + $diff = $dom{$1}->{'newtime'} - $dom{$1}->{'oldtime'}; + $diff = sprintf("%.2f", $diff); + + # Calc the diff between old and new cputime, or reset the counter + if ( $diff < 0 ) + { + $diff = $dom{$1}->{'newtime'}; + } + $dom{$1}->{'diff'} = $diff; + + # Calc a sum CPU usage + $cpusum = $cpusum + $diff; +} + +my $numcpus = `$XM info |grep nr_cpus |cut -d \: -f 2`; +my $timediff = $curtime - $oldtime; +my $tcpuavail = $numcpus * $timediff; + +if ( $debug ) +{ + print "UsedCPUtime sum: $cpusum\n"; + print "CPUs: $numcpus\n"; + print "Timediff: $timediff\n"; + print "Total CPU time available: $tcpuavail\n"; +} + +my $key; my $value; +while (($key, $value) = each %dom) +{ + # Calc a percentage based on the used CPU time sum + my $tmp = 0; + $tmp = ( $dom{$key}->{'diff'} / $cpusum ) * 100; + $dom{$key}->{'pc_time'} = sprintf("%.2f", $tmp); + + # Calc a percentage based on the _total_ available CPU time + $tmp = 0; + $tmp = ( $dom{$key}->{'diff'} / $tcpuavail ) * 100; + $dom{$key}->{'pc_tcpu'} = sprintf("%.2f", $tmp); + + if ( $debug ) + { + print "$key newtime: ".$dom{$key}->{'newtime'}.", oldtime: ".$dom{$key}->{'oldtime'}.", diff: ".$dom{$key}->{'diff'}.", pc_bytime ".$dom{$key}->{'pc_time'}.", pc_bytcpu ".$dom{$key}->{'pc_tcpu'}."\n"; + } + print "$key.value ".$dom{$key}->{'pc_tcpu'}."\n"; +} + +# We'll need to log out the current "xm list" output, and the current time also. +open(FH, ">", $TEMPFILE) or die $!; +print FH $curtime."\n"; +print FH @xmlist; +close FH; + diff --git a/manifests/plugins/dom0.pp b/manifests/plugins/dom0.pp index ed4f62c..44995fc 100644 --- a/manifests/plugins/dom0.pp +++ b/manifests/plugins/dom0.pp @@ -1,6 +1,6 @@ class munin::plugins::dom0 { munin::plugin::deploy { - [ 'xen', 'xen-cpu', 'xen_memory', 'xen_mem', + [ 'xen', 'xen_cpu', 'xen_memory', 'xen_mem', 'xen_vm', 'xen_vbd', 'xen_traffic_all' ]: config => 'user root'; } -- cgit v1.2.3 From aeeee144bf7e4740e9a8826e3d2086a4320c6ac8 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 6 Dec 2012 22:58:02 +0100 Subject: make this plugin caching more stable --- files/plugins/xen_traffic_all | 75 +++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/files/plugins/xen_traffic_all b/files/plugins/xen_traffic_all index c5bbfbb..b6f668d 100644 --- a/files/plugins/xen_traffic_all +++ b/files/plugins/xen_traffic_all @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Author: mario manno # Description: measure traffic for all xen hosts # @@ -32,6 +32,21 @@ if [ "$1" = "autoconf" ]; then exit 0 fi +# we update network devices only twice an hour +function net_state { + dom=$1 + (find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ + [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ] + if [ $? -gt 0 ] || [ ! -f /var/lib/munin/plugin-state/xm_net_$dom.state ]; then + content=$(/usr/sbin/xm network-list $dom) + if [ $? -eq 0 ]; then + echo "${content}" | egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state + else + [ -f /var/lib/munin/plugin-state/xm_net_$dom.state ] && rm /var/lib/munin/plugin-state/xm_net_$dom.state + fi + fi +} + if [ "$1" = "config" ]; then echo 'graph_title Xen Traffic' echo 'graph_vlabel bits received (-) / sent (+) per ${graph_period}' @@ -39,43 +54,38 @@ if [ "$1" = "config" ]; then echo 'graph_category xen' DOMAINS=$(cat /var/lib/munin/plugin-state/xm_list.state | awk '{print $1}' | egrep -v "^(Name|Domain-0)") for dom in $DOMAINS; do - # we update network devices only twice an hour - ((find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ - [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ]) || \ - (/usr/sbin/xm network-list $dom |\ - egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state) - devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) - real_name=$( echo $dom | sed -e's/-/_/g' ) - name=$real_name - for dev in $devs; do - if [ ${#devs} -gt 1 ]; then - name=$real_name"_"`echo $dev | sed 's/\./\_/'` - fi + net_state $dom + if [ -f /var/lib/munin/plugin-state/xm_net_$dom.state ]; then + devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) + real_name=$( echo $dom | sed -e's/-/_/g' ) + name=$real_name + for dev in $devs; do + if [ ${#devs} -gt 1 ]; then + name=$real_name"_"`echo $dev | sed 's/\./\_/'` + fi - echo $name'Down.label received' - echo $name'Down.type COUNTER' - echo $name'Down.graph no' - echo "${name}Down.cdef ${name}Down,8,*" - echo "${name}Up.label ${name}" - echo $name'Up.type COUNTER' - echo "${name}Up.negative ${name}Down" - echo "${name}Up.cdef ${name}Up,8,*" - done + echo $name'Down.label received' + echo $name'Down.type COUNTER' + echo $name'Down.graph no' + echo "${name}Down.cdef ${name}Down,8,*" + echo "${name}Up.label ${name}" + echo $name'Up.type COUNTER' + echo "${name}Up.negative ${name}Down" + echo "${name}Up.cdef ${name}Up,8,*" + done + fi done exit 0 fi DOMAINS=$(cat /var/lib/munin/plugin-state/xm_list.state | awk '{print $1}' | egrep -v "^(Name|Domain-0)") for dom in $DOMAINS; do - # we update network devices only twice an hour - ((find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ - [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ]) || \ - (/usr/sbin/xm network-list $dom |\ - egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state) - devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) - real_name=$( echo $dom | sed -e's/-/_/g' ) - name=$real_name - for dev in $devs; do + net_state $dom + if [ -f /var/lib/munin/plugin-state/xm_net_$dom.state ]; then + devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) + real_name=$( echo $dom | sed -e's/-/_/g' ) + name=$real_name + for dev in $devs; do if [ ${#devs} -gt 1 ]; then name=$real_name"_"`echo $dev | sed 's/\./\_/'` fi @@ -86,6 +96,7 @@ for dom in $DOMAINS; do print name"Down.value " $1 "\n"name"Up.value " $9 \ }' \ /proc/net/dev - done + done + fi done -- cgit v1.2.3 From 61de53c6b99c18e309351c5e5cae5027ff2f4905 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Dec 2012 11:17:54 +0100 Subject: fix plugin to work on debian and centos --- files/plugins/xen_vbd | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index 4eca5a6..f3362c7 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -18,7 +18,7 @@ $XMTOP = '/usr/sbin/xentop'; # we cache xm list for 5 min for perfomance reasons system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); -system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 > /var/lib/munin/plugin-state/xm_top.state'); +system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 | grep -E "^ " > /var/lib/munin/plugin-state/xm_top.state'); # ah, parameters coming in if ( defined($ARGV[0])) @@ -88,10 +88,7 @@ if ( defined($ARGV[0])) # No args, get rolling my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; -# remove the first 4 items that are junk that we don't need. -shift(@stats); -shift(@stats); -shift(@stats); +# remove the first line shift(@stats); my %vals; undef(%vals); -- cgit v1.2.3 From 7bac1218e57c3092d52e4eb0734451e45cb78c94 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Dec 2012 15:14:00 +0100 Subject: correct filtering --- files/plugins/xen | 2 +- files/plugins/xen_mem | 2 +- files/plugins/xen_traffic_all | 2 +- files/plugins/xen_vbd | 2 +- files/plugins/xen_vm | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/plugins/xen b/files/plugins/xen index a9f1a1e..378e040 100755 --- a/files/plugins/xen +++ b/files/plugins/xen @@ -20,7 +20,7 @@ fi # we cache xm list for 5 min for perfomance reasons ((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ - /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + /usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "config" ]; then diff --git a/files/plugins/xen_mem b/files/plugins/xen_mem index 16d91cf..edfc926 100644 --- a/files/plugins/xen_mem +++ b/files/plugins/xen_mem @@ -46,7 +46,7 @@ # we cache xm list for 5 min for perfomance reasons ((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ - /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + /usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "autoconf" ]; then echo yes diff --git a/files/plugins/xen_traffic_all b/files/plugins/xen_traffic_all index b6f668d..492effc 100644 --- a/files/plugins/xen_traffic_all +++ b/files/plugins/xen_traffic_all @@ -14,7 +14,7 @@ # we cache xm list for 5 min for perfomance reasons ((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ - /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + /usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "autoconf" ]; then if which xm > /dev/null ; then diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index f3362c7..ccea940 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -17,7 +17,7 @@ $XM = '/usr/sbin/xm'; $XMTOP = '/usr/sbin/xentop'; # we cache xm list for 5 min for perfomance reasons -system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); +system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state'); system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 | grep -E "^ " > /var/lib/munin/plugin-state/xm_top.state'); # ah, parameters coming in diff --git a/files/plugins/xen_vm b/files/plugins/xen_vm index a69b5fe..18ee9a8 100644 --- a/files/plugins/xen_vm +++ b/files/plugins/xen_vm @@ -48,7 +48,7 @@ XM="/usr/sbin/xm" # we cache xm list for 5 min for perfomance reasons ((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ - /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + /usr/sbin/xm list | grep -v "^Name .* ID" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "autoconf" ]; then echo yes -- cgit v1.2.3 From 3dc03e88057890b5ef8dc02fde45b66bfd94cf73 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Dec 2012 15:19:23 +0100 Subject: this does not yet work on the older munins --- templates/munin-node.conf.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index ff9fbb1..4e2f534 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -16,7 +16,7 @@ user root group 0 # Regexps for files to ignore -ignore_file [\#~]$ +ignore_file ~$ ignore_file DEADJOE$ ignore_file \.bak$ ignore_file %$ -- cgit v1.2.3 From 8cb10f7bcd7bb3084e20d5a26099d65a83fb0f56 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Dec 2012 16:00:18 +0100 Subject: fix a few other issues --- files/plugins/xen_mem | 4 ++-- files/plugins/xen_vbd | 1 - files/plugins/xen_vm | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/files/plugins/xen_mem b/files/plugins/xen_mem index edfc926..a260fbd 100644 --- a/files/plugins/xen_mem +++ b/files/plugins/xen_mem @@ -63,7 +63,7 @@ if [ "$1" = "config" ]; then echo 'graph_info This graph shows affected memory for each domain.' echo 'Domain_0.label Domain-0' echo 'Domain_0.draw AREA' -cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Domain-0' | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.label " echo $i | awk '{ print $1 }' @@ -73,7 +73,7 @@ done exit 0 fi -cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.value " echo $i | awk '{ print $3 * 1024 * 1024 }' diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index ccea940..a684839 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -51,7 +51,6 @@ if ( defined($ARGV[0])) ); @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; - shift(@domains); # we don't need the header line foreach $domain ( @domains ) { diff --git a/files/plugins/xen_vm b/files/plugins/xen_vm index 18ee9a8..725e800 100644 --- a/files/plugins/xen_vm +++ b/files/plugins/xen_vm @@ -69,4 +69,4 @@ fi domains=`cat /var/lib/munin/plugin-state/xm_list.state | wc -l` echo -n "domains.value " -echo $(($domains-2)) +echo $(($domains-1)) -- cgit v1.2.3 From 864587e318adf0aa7d4a191b596f5b8337faf521 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 7 Dec 2012 16:05:41 +0100 Subject: fix issue if pid is not at the beginning + linting --- manifests/client/openbsd.pp | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp index 88d0640..1852962 100644 --- a/manifests/client/openbsd.pp +++ b/manifests/client/openbsd.pp @@ -3,14 +3,16 @@ class munin::client::openbsd inherits munin::client::base { if $::operatingsystemrelease == '4.3' { file{'/usr/src/munin_openbsd.tar.gz': - source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", - owner => root, group => 0, mode => 0600; + source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", + owner => root, + group => 0, + mode => '0600'; } exec{'extract_openbsd': command => 'cd /;tar xzf /usr/src/munin_openbsd.tar.gz', - unless => 'test -d /opt/munin', + unless => 'test -d /opt/munin', require => File['/usr/src/munin_openbsd.tar.gz'], - before => File['/var/run/munin'], + before => File['/var/run/munin'], } package{'p5-Compress-Zlib': ensure => installed, @@ -28,32 +30,32 @@ class munin::client::openbsd inherits munin::client::base { before => File['/var/run/munin'], } file{[ '/var/run/munin', '/var/log/munin' ]: - ensure => directory, - owner => root, group => 0, mode => 0755; + ensure => directory, + owner => root, + group => 0, + mode => '0755'; + } + $bin_loc = $::operatingsystemrelease ? { + '4.3' => '/opt/munin/sbin/munin-node', + default => '/usr/local/sbin/munin-node' } openbsd::rc_local{'munin-node': - binary => $::operatingsystemrelease ? { - '4.3' => '/opt/munin/sbin/munin-node', - default => '/usr/local/sbin/munin-node' - }, + binary => $bin_loc, require => File['/var/run/munin'], } Service['munin-node']{ - restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', - stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', - start => $::operatingsystemrelease ? { - '4.3' => '/opt/munin/sbin/munin-node', - default => '/usr/local/sbin/munin-node' - }, - status => 'test -e /var/run/munin/munin-node.pid && (ps ax | egrep -q "^$(cat /var/run/munin/munin-node.pid).*munin-node")', - hasstatus => true, - hasrestart => true, - require => [ File['/var/run/munin'], File['/var/log/munin'] ], + restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', + stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', + start => $bin_loc, + status => 'test -e /var/run/munin/munin-node.pid && (ps ax | egrep -q "^ *$(cat /var/run/munin/munin-node.pid).*munin-node")', + hasstatus => true, + hasrestart => true, + require => [ File['/var/run/munin'], File['/var/log/munin'] ], } cron{'clean_munin_logfile': command => 'rm /var/log/munin/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`', - minute => 0, - hour => 2, + minute => 0, + hour => 2, weekday => 0, } } -- cgit v1.2.3 From f34990e5a63bf3aeaaeafb7be2ed842c524a9926 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 15 Dec 2012 20:29:41 +0100 Subject: fix a few remaining things in xen plugins --- files/plugins/xen_traffic_all | 4 +--- files/plugins/xen_vbd | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/files/plugins/xen_traffic_all b/files/plugins/xen_traffic_all index 492effc..72f3b27 100644 --- a/files/plugins/xen_traffic_all +++ b/files/plugins/xen_traffic_all @@ -35,9 +35,7 @@ fi # we update network devices only twice an hour function net_state { dom=$1 - (find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ - [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ] - if [ $? -gt 0 ] || [ ! -f /var/lib/munin/plugin-state/xm_net_$dom.state ]; then + if [ `find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin +30 2> /dev/null | wc -l` -gt 0 ] || [ ! -f /var/lib/munin/plugin-state/xm_net_$dom.state ]; then content=$(/usr/sbin/xm network-list $dom) if [ $? -eq 0 ]; then echo "${content}" | egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index a684839..e34d41c 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -50,7 +50,7 @@ if ( defined($ARGV[0])) 'graph_info' => 'Display the I/O operations for each domain', ); - @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; + @domains = `cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Domain-0'`; foreach $domain ( @domains ) { @@ -85,7 +85,7 @@ if ( defined($ARGV[0])) # No args, get rolling -my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; +my @stats = `cat /var/lib/munin/plugin-state/xm_top.state | grep -v 'Domain-0'`; # remove the first line shift(@stats); -- cgit v1.2.3 From 90de43454b59db2561a600ec1b017920916b0f23 Mon Sep 17 00:00:00 2001 From: Evan Stachowiak Date: Sat, 15 Dec 2012 19:38:52 -0500 Subject: add munin-node template for Ubuntu --- templates/munin-node.conf.Ubuntu | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 templates/munin-node.conf.Ubuntu diff --git a/templates/munin-node.conf.Ubuntu b/templates/munin-node.conf.Ubuntu new file mode 100644 index 0000000..17162d8 --- /dev/null +++ b/templates/munin-node.conf.Ubuntu @@ -0,0 +1,39 @@ +########## +########## Managed by puppet +########## + +log_level 4 +log_file /var/log/munin/munin-node.log +pid_file /var/run/munin/munin-node.pid +background 1 +setseid 1 + +# Which host/port to bind to; +host <%= scope.function_hiera('munin_host','*') %> +port <%= scope.function_hiera('munin_port','4949') %> +user root +group root +setsid yes + +# Regexps for files to ignore + +ignore_file ~$ +ignore_file \.bak$ +ignore_file %$ +ignore_file \.dpkg-(tmp|new|old|dist)$ +ignore_file \.rpm(save|new)$ + +# Set this if the client doesn't report the correct hostname when +# telnetting to localhost, port 4949 +# +#host_name localhost.localdomain +host_name <%= fqdn %> + +# A list of addresses that are allowed to connect. This must be a +# regular expression, due to brain damage in Net::Server, which +# doesn't understand CIDR-style network notation. You may repeat +# the allow line as many times as you'd like +<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> +<% end -%> + -- cgit v1.2.3 From f48f21b3ba853836585bc99bb496b9206dae34ae Mon Sep 17 00:00:00 2001 From: Evan Stachowiak Date: Sat, 15 Dec 2012 20:14:57 -0500 Subject: add munin-node template for Ubuntu Precise --- templates/munin-node.conf.Ubuntu.precise | 1 + 1 file changed, 1 insertion(+) create mode 120000 templates/munin-node.conf.Ubuntu.precise diff --git a/templates/munin-node.conf.Ubuntu.precise b/templates/munin-node.conf.Ubuntu.precise new file mode 120000 index 0000000..d8fcb24 --- /dev/null +++ b/templates/munin-node.conf.Ubuntu.precise @@ -0,0 +1 @@ +munin-node.conf.Ubuntu \ No newline at end of file -- cgit v1.2.3 From 764c51e305c4e6d0d8e12f2a601aad508585fbe9 Mon Sep 17 00:00:00 2001 From: Matt Taggart Date: Wed, 19 Dec 2012 15:17:40 -0800 Subject: minimize diffs to upstream, which is: https://github.com/munin-monitoring/contrib/blob/master/plugins/virtualization/xen-cpu --- files/plugins/xen-cpu | 147 +++++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/files/plugins/xen-cpu b/files/plugins/xen-cpu index b456a14..da36f6d 100755 --- a/files/plugins/xen-cpu +++ b/files/plugins/xen-cpu @@ -3,15 +3,19 @@ # Script to minitor the cpu usage of Xen domains # # Author: Adam Crews shroom com> -# +# # License: GPL # Based on the origional xen script from Matthias Pfafferodt, syntron at web.de # # Note: Your munin config must run this as root. # # Parameters -# config (required) -# autoconf (optional - used by munin-config) +# config (required) +# autoconf (optional - used by munin-config) +# +# Changelog: +# Properly ignore the xentop output header line. +# Ward Vandewege (ward@gnu.org), 2011-04-20 # #%# family=auto #%# capabilities=autoconf @@ -34,54 +38,54 @@ system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE my $arg; undef($arg); if (defined($ARGV[0])) { - $arg = 'config' if ($ARGV[0] eq 'config'); - $arg = 'autoconf' if ($ARGV[0] eq 'autoconf'); - - if ( "$arg" eq 'autoconf') { - if ( -e $XM && -e $XMTOP ) { - print "yes\n"; - exit 0; - } else { - print "no ($XM and/or $XMTOP not found\n"; - exit 1; - } - } - - if ( "$arg" eq 'config') { - my %cnf; undef(%cnf); - %cnf = ( - 'graph_title' => 'Xen Domain CPU Usage', - 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid', - 'graph_vlabel' => 'Percent (%)', - 'graph_category' => 'xen', - 'graph_info' => 'Display the % of CPU Usage for each domain', - ); - - my @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; + $arg = 'config' if ($ARGV[0] eq 'config'); + $arg = 'autoconf' if ($ARGV[0] eq 'autoconf'); + + if ( "$arg" eq 'autoconf') { + if ( -e $XM && -e $XMTOP ) { + print "yes\n"; + exit 0; + } else { + print "no ($XM and/or $XMTOP not found\n"; + exit 1; + } + } + + if ( "$arg" eq 'config') { + my %cnf; undef(%cnf); + %cnf = ( + 'graph_title' => 'Xen Domain CPU Usage', + 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid', + 'graph_vlabel' => 'Percent (%)', + 'graph_category' => 'xen', + 'graph_info' => 'Display the % of CPU Usage for each domain', + ); + + my @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; # the header line is not in the cached file - #shift(@domains); # we dont need the header line - my $cnt = "0"; - foreach my $domain ( @domains ) { - my ($dom,undef) = split(/\s/, $domain, 2); - # we need to change - and . to _ or things get weird with the graphs - # some decent quoting would probably fix this, but this works for now - $dom =~ s/[-.]/_/g; - - $cnf{ "$dom" . '.label' } = "$dom"; - $cnf{ "$dom" . '.draw' } = 'STACK'; - $cnf{ "$dom" . '.min' } = '0'; - $cnf{ "$dom" . '.max' } = '100'; - $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom"; - - if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; } - $cnt++; - } - - foreach my $key (sort(keys(%cnf))) { - print "$key $cnf{$key}\n"; - } - exit 0; - } + #shift(@domains); # we dont need the header line + my $cnt = "0"; + foreach my $domain ( @domains ) { + my ($dom,undef) = split(/\s/, $domain, 2); + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $dom =~ s/[-.]/_/g; + + $cnf{ "$dom" . '.label' } = "$dom"; + $cnf{ "$dom" . '.draw' } = 'STACK'; + $cnf{ "$dom" . '.min' } = '0'; + $cnf{ "$dom" . '.max' } = '100'; + $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom"; + + if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; } + $cnt++; + } + + foreach my $key (sort(keys(%cnf))) { + print "$key $cnf{$key}\n"; + } + exit 0; + } } # Nothing was passed as an argument, so let's just return the proper values @@ -89,33 +93,32 @@ if (defined($ARGV[0])) { my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; # remove the first 4 items that are junk that we don't need. -shift(@stats); -shift(@stats); -shift(@stats); -shift(@stats); +shift(@stats); +shift(@stats); +shift(@stats); +shift(@stats); my %vals; undef(%vals); foreach my $domain (@stats) { - # trim the leading whitespace - $domain =~ s/^\s+//; - my @v_tmp = split(/\s+/, $domain); - - # we need to change - and . to _ or things get weird with the graphs - # some decent quoting would probably fix this, but this works for now - $v_tmp[0] =~ s/[-.]/_/g; - - $vals{$v_tmp[0]}{'cpu_percent'} = $v_tmp[3]; - $vals{$v_tmp[0]}{'vcpu'} = $v_tmp[8]; - if ( $vals{$v_tmp[0]}{'vcpu'} =~ m/n\/a/ ) { - my $cpu = `grep -c "processor" < /proc/cpuinfo`; - if ( $cpu =~ m/^(\d+)$/ ) { - $vals{$v_tmp[0]}{'vcpu'} = $1; - } - } + # trim the leading whitespace + $domain =~ s/^\s+//; + my @v_tmp = split(/\s+/, $domain); + + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $v_tmp[0] =~ s/[-.]/_/g; + + $vals{$v_tmp[0]}{'cpu_percent'} = $v_tmp[3]; + $vals{$v_tmp[0]}{'vcpu'} = $v_tmp[8]; + if ( $vals{$v_tmp[0]}{'vcpu'} =~ m/n\/a/ ) { + my $cpu = `grep -c "processor" < /proc/cpuinfo`; + if ( $cpu =~ m/^(\d+)$/ ) { + $vals{$v_tmp[0]}{'vcpu'} = $1; + } + } } foreach my $key (sort(keys(%vals))) { - print "$key.value " . ($vals{$key}{'cpu_percent'}/$vals{'Domain_0'}{'vcpu'}), "\n"; + print "$key.value " . ($vals{$key}{'cpu_percent'}/$vals{'Domain_0'}{'vcpu'}), "\n"; } - -- cgit v1.2.3 From 935752b577e9b02e6d08dee1d3b885cba8043466 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 12 Jan 2013 12:47:56 +0100 Subject: fix path for munin-log file --- templates/munin-node.conf.OpenBSD | 60 ++++++++++++++++++++++++++++++++++++++- templates/munin-node.conf.default | 2 +- 2 files changed, 60 insertions(+), 2 deletions(-) mode change 120000 => 100644 templates/munin-node.conf.OpenBSD diff --git a/templates/munin-node.conf.OpenBSD b/templates/munin-node.conf.OpenBSD deleted file mode 120000 index 082b30c..0000000 --- a/templates/munin-node.conf.OpenBSD +++ /dev/null @@ -1 +0,0 @@ -munin-node.conf.default \ No newline at end of file diff --git a/templates/munin-node.conf.OpenBSD b/templates/munin-node.conf.OpenBSD new file mode 100644 index 0000000..4e2f534 --- /dev/null +++ b/templates/munin-node.conf.OpenBSD @@ -0,0 +1,59 @@ +########## +########## Managed by puppet +########## +# +# Example config-file for munin-node +# + +log_level 4 +log_file /var/log/munin/munin-node.log +pid_file /var/run/munin/munin-node.pid + +background 1 +setsid 1 + +user root +group 0 + +# Regexps for files to ignore +ignore_file ~$ +ignore_file DEADJOE$ +ignore_file \.bak$ +ignore_file %$ +ignore_file \.dpkg-(tmp|new|old|dist)$ +ignore_file \.rpm(save|new)$ +ignore_file \.pod$ + +# Set this if the client doesn't report the correct hostname when +# telnetting to localhost, port 4949 +# +#host_name localhost.localdomain +host_name <%= fqdn %> + +# A list of addresses that are allowed to connect. This must be a +# regular expression, since Net::Server does not understand CIDR-style +# network notation unless the perl module Net::CIDR is installed. You +# may repeat the allow line as many times as you'd like + +<% scope.lookupvar('munin::client::allow').each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> +<% end -%> + +# If you have installed the Net::CIDR perl module, you can use one or more +# cidr_allow and cidr_deny address/mask patterns. A connecting client must +# match any cidr_allow, and not match any cidr_deny. Note that a netmask +# *must* be provided, even if it's /32 +# +# Example: +# +# cidr_allow 127.0.0.1/32 +# cidr_allow 192.0.2.0/24 +# cidr_deny 192.0.2.42/32 + +# Which address to bind to; +host <%= scope.lookupvar('munin::client::host') %> +# host 127.0.0.1 + +# And which port +port <%= scope.lookupvar('munin::client::port') %> + diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index 4e2f534..2a95fbc 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -6,7 +6,7 @@ # log_level 4 -log_file /var/log/munin/munin-node.log +log_file /var/log/munin-node/munin-node.log pid_file /var/run/munin/munin-node.pid background 1 -- cgit v1.2.3 From bee292c51a392fc36948862f88585d41aaf68c65 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 12 Jan 2013 12:50:43 +0100 Subject: update to latest upstream --- templates/munin-node.conf.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default index 2a95fbc..9d7f32f 100644 --- a/templates/munin-node.conf.default +++ b/templates/munin-node.conf.default @@ -16,7 +16,7 @@ user root group 0 # Regexps for files to ignore -ignore_file ~$ +ignore_file [\#~]$ ignore_file DEADJOE$ ignore_file \.bak$ ignore_file %$ -- cgit v1.2.3 From 14bcc7fd1385934c3750c4b5eed36ed4dfb109c9 Mon Sep 17 00:00:00 2001 From: Markus Heberling Date: Wed, 23 Jan 2013 22:15:00 +0100 Subject: added quantal --- templates/munin-node.conf.Ubuntu.quantal | 1 + 1 file changed, 1 insertion(+) create mode 120000 templates/munin-node.conf.Ubuntu.quantal diff --git a/templates/munin-node.conf.Ubuntu.quantal b/templates/munin-node.conf.Ubuntu.quantal new file mode 120000 index 0000000..d8fcb24 --- /dev/null +++ b/templates/munin-node.conf.Ubuntu.quantal @@ -0,0 +1 @@ +munin-node.conf.Ubuntu \ No newline at end of file -- cgit v1.2.3 From a2004f577c2e15d9b6cf482f0693601f43c43fad Mon Sep 17 00:00:00 2001 From: Markus Heberling Date: Wed, 23 Jan 2013 20:15:52 +0100 Subject: added support for use_ssh for munin 2.0 --- manifests/client.pp | 1 + manifests/client/base.pp | 1 + manifests/register.pp | 1 + templates/client.erb | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/manifests/client.pp b/manifests/client.pp index 934d23a..6726836 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -7,6 +7,7 @@ class munin::client( $allow = [ '127.0.0.1' ], $host = '*', $port = '4949', + $use_ssh = false, $manage_shorewall = false, $shorewall_collector_source = 'net' ) { diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 84ba9b2..441198e 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -20,6 +20,7 @@ class munin::client::base { default => $munin::client::host }, port => $munin::client::port, + use_ssh => $munin::client::use_ssh, config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], } include munin::plugins::base diff --git a/manifests/register.pp b/manifests/register.pp index 9257ca1..6c154e5 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -1,6 +1,7 @@ define munin::register ( $host = $::fqdn, $port = '4949', + $use_ssh = false, $description = 'absent', $config = [] ) diff --git a/templates/client.erb b/templates/client.erb index 7131ade..ba03da5 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -12,8 +12,12 @@ # Description: <%= description.gsub!(/\n/, ' ') %> <% end -%> [<%= fhost.downcase %>] +<% if use_ssh -%> + address ssh://<%= host %>/bin/nc localhost <%= port %> +<% else -%> address <%= host %> port <%= port %> +<% end -%> <% if config -%><% config.each do |val| -%> <%= val -%> <% end -%><% end -%> -- cgit v1.2.3 From d3dae3c834c37f689af3d1b08bc0c1fd4762bd91 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Feb 2013 19:14:56 +0100 Subject: linting --- manifests/plugin.pp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index af8b44a..e9e5dba 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,33 +1,30 @@ -# plugin.pp - configure a specific munin plugin -# Copyright (C) 2007 David Schmitt -# See LICENSE for the full license granted to you. -# adapted and improved by admin(at)immerda.ch - +# configure a specific munin plugin define munin::plugin ( - $ensure = "present", + $ensure = 'present', $script_path_in = '', - $config = '' + $config = '' ) { include munin::plugin::scriptpaths $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in } - $plugin_src = $ensure ? { "present" => $name, default => $ensure } + $plugin_src = $ensure ? { 'present' => $name, default => $ensure } $plugin = "/etc/munin/plugins/${name}" $plugin_conf = "/etc/munin/plugin-conf.d/${name}.conf" include munin::plugins::setup case $ensure { - "absent": { + 'absent': { file { $plugin: ensure => absent, } } default: { + $dep = $::kernel ? { + OpenBSD => File['/var/run/munin'], + default => Package['munin-node'] + } file { $plugin: - ensure => "${real_script_path}/${plugin_src}", - require => $::kernel ? { - OpenBSD => File['/var/run/munin'], - default => Package['munin-node'] - }, - notify => Service['munin-node']; + ensure => "${real_script_path}/${plugin_src}", + require => $dep, + notify => Service['munin-node']; } if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File[$plugin]{ @@ -47,8 +44,10 @@ define munin::plugin ( } default: { file { $plugin_conf: - content => "[${name}]\n$config\n", - mode => 0644, owner => root, group => 0, + content => "[${name}]\n${config}\n", + owner => root, + group => 0, + mode => '0644', } } } -- cgit v1.2.3 From 61cfbbf42268045b0d4f0dc0481b962e9aad9f8f Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Feb 2013 20:21:53 +0100 Subject: linting --- manifests/plugin/deploy.pp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 9e74afb..2928a3a 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -1,18 +1,25 @@ -define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { +# deploy and register a munin plugin +define munin::plugin::deploy( + $ensure = 'present', + $source = '', + $config = '', +) { $plugin_src = $ensure ? { 'present' => $name, - 'absent' => $name, - default => $ensure + 'absent' => $name, + default => $ensure } $real_source = $source ? { - '' => "munin/plugins/$plugin_src", + '' => "munin/plugins/${plugin_src}", default => $source } include munin::plugin::scriptpaths file { "munin_plugin_${name}": - path => "${munin::plugin::scriptpaths::script_path}/${name}", - source => "puppet:///modules/${real_source}", - mode => 0755, owner => root, group => 0; + path => "${munin::plugin::scriptpaths::script_path}/${name}", + source => "puppet:///modules/${real_source}", + owner => root, + group => 0, + mode => '0755'; } if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ @@ -35,9 +42,13 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { } } # register the plugin + munin::plugin{$name: + ensure => $ensure, + config => $config + } if $require { - munin::plugin{$name: ensure => $ensure, config => $config, require => $require } - } else { - munin::plugin{$name: ensure => $ensure, config => $config } + Munin::Plugin[$name]{ + require => $require + } } } -- cgit v1.2.3 From f047c5c38310c25a4f5483cd33caba6d73a42ab0 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Feb 2013 20:23:10 +0100 Subject: this require is pretty useless, as if we have a require on the define, we do not need to pass it down --- manifests/plugin/deploy.pp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 2928a3a..53f6481 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -2,7 +2,7 @@ define munin::plugin::deploy( $ensure = 'present', $source = '', - $config = '', + $config = '' ) { $plugin_src = $ensure ? { 'present' => $name, @@ -32,23 +32,12 @@ define munin::plugin::deploy( openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } - if $require { - File["munin_plugin_${name}"]{ - require => [ $basic_require, $require ], - } - } else { - File["munin_plugin_${name}"]{ - require => $basic_require, - } + File["munin_plugin_${name}"]{ + require => $basic_require, } # register the plugin munin::plugin{$name: ensure => $ensure, config => $config } - if $require { - Munin::Plugin[$name]{ - require => $require - } - } } -- cgit v1.2.3 From 77e0a70999a8c4c20ee8d9eb521b927c525ac653 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Feb 2013 20:24:02 +0100 Subject: make it possible to manage the seltype --- manifests/plugin/deploy.pp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 53f6481..cbf64fb 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -1,8 +1,9 @@ # deploy and register a munin plugin define munin::plugin::deploy( - $ensure = 'present', - $source = '', - $config = '' + $ensure = 'present', + $source = '', + $config = '', + $seltype = 'munin_exec_t' ) { $plugin_src = $ensure ? { 'present' => $name, @@ -24,7 +25,7 @@ define munin::plugin::deploy( if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File["munin_plugin_${name}"]{ - seltype => 'munin_exec_t', + seltype => $seltype, } } -- cgit v1.2.3 From 68a4cb4ae4dc5aeeece00a1e40e41edcda82a8ff Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Feb 2013 20:29:55 +0100 Subject: move this to the apache module --- files/plugins/apache_activity | 99 ------------------------------------------- manifests/plugins/apache.pp | 4 -- 2 files changed, 103 deletions(-) delete mode 100755 files/plugins/apache_activity delete mode 100644 manifests/plugins/apache.pp diff --git a/files/plugins/apache_activity b/files/plugins/apache_activity deleted file mode 100755 index 65fc072..0000000 --- a/files/plugins/apache_activity +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# -# Parameters supported: -# -# config -# autoconf -# -# Configurable variables -# -# url - Override default status-url -# -# Magic markers: -#%# family=auto -#%# capabilities=autoconf - -my $ret = undef; -if (!eval "require LWP::UserAgent;") { - $ret = "LWP::UserAgent not found"; -} - -my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto"; -my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80); -my %chars = ( - # '\_' => 'Waiting', - # 'S' => 'Starting up', - 'R' => 'Reading request', - 'W' => 'Sending reply', - 'K' => 'Keepalive', - 'D' => 'DNS lookup', - 'C' => 'Closing', - # 'L' => 'Logging', - # 'G' => 'Gracefully finishing', - # 'I' => 'Idle cleanup', - # '\.' => 'Open slot', - ); - -# "_" Waiting for Connection, "S" Starting up, "R" Reading Request, -# "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, -# "C" Closing connection, "L" Logging, "G" Gracefully finishing, -# "I" Idle cleanup of worker, "." Open slot with no current process - -if (exists $ARGV[0] and $ARGV[0] eq "autoconf") { - if ($ret) { - print "no ($ret)\n"; - exit 1; - } - my $ua = LWP::UserAgent->new(timeout => 30); - my @badports; - - foreach my $port (@PORTS) { - my $url = sprintf $URL, $port; - my $response = $ua->request(HTTP::Request->new('GET',$url)); - push @badports, $port unless $response->is_success and $response->content =~ /Scoreboard/im; - } - - if (@badports) { - print "no (no apache server-status on ports @badports)\n"; - exit 1; - } else { - print "yes\n"; - exit 0; - } -} - -if (exists $ARGV[0] and $ARGV[0] eq "config") { - print "graph_title Apache activity\n"; - print "graph_args --base 1000 -l 0\n"; - print "graph_category apache\n"; - print "graph_vlabel processes\n"; - foreach my $port (@PORTS) { - while (my ($char, $val) = each (%chars)) { - $char =~ s/\\\./dot/; - $char =~ s/\\\_/underline/; - print "activity_${port}_${char}.label "; - print $val, "\n"; - print "activity_${port}_${char}.type GAUGE\n"; - } - } - exit 0; -} - -foreach my $port (@PORTS) { - my $ua = LWP::UserAgent->new (timeout => 30); - my $url = sprintf $URL, $port; - my $response = $ua->request (HTTP::Request->new('GET',$url)); - if ($response->content =~ /^Scoreboard\:\s?(.*)$/sm) { - my $string = $1; - chomp $string; - my @act = split (//, $string); - foreach my $char (keys (%chars)) { - my $num = scalar (grep (/$char/, @act)); - $char =~ s/\\\./dot/; - $char =~ s/\\\_/underline/; - print "activity_${port}_${char}.value $num\n"; - } - } -} - - diff --git a/manifests/plugins/apache.pp b/manifests/plugins/apache.pp deleted file mode 100644 index dca3cea..0000000 --- a/manifests/plugins/apache.pp +++ /dev/null @@ -1,4 +0,0 @@ -class munin::plugins::apache { - munin::plugin{ [ 'apache_accesses', 'apache_processes', 'apache_volume' ]: } - munin::plugin::deploy { 'apache_activity': } -} -- cgit v1.2.3 From 3b10e0eb3fabb19cc0fa9d66f5a8379ae96aeb6f Mon Sep 17 00:00:00 2001 From: Sander Hoentjen Date: Mon, 18 Mar 2013 14:56:44 +0100 Subject: Add support for specifying tags for exported resources This enables you to specify different servers for different clients. --- manifests/client.pp | 3 ++- manifests/client/base.pp | 13 +++++++------ manifests/host.pp | 5 +++-- manifests/register.pp | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/manifests/client.pp b/manifests/client.pp index 6726836..2316bc9 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -9,7 +9,8 @@ class munin::client( $port = '4949', $use_ssh = false, $manage_shorewall = false, - $shorewall_collector_source = 'net' + $shorewall_collector_source = 'net', + $export_tag = 'munin' ) { case $::operatingsystem { openbsd: { include munin::client::openbsd } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index 441198e..78398a9 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -15,13 +15,14 @@ class munin::client::base { mode => 0644, owner => root, group => 0, } munin::register { $::fqdn: - host => $munin::client::host ? { - '*' => $::fqdn, - default => $munin::client::host + host => $munin::client::host ? { + '*' => $::fqdn, + default => $munin::client::host }, - port => $munin::client::port, - use_ssh => $munin::client::use_ssh, - config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], + port => $munin::client::port, + use_ssh => $munin::client::use_ssh, + config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], + export_tag => $munin::client::export_tag, } include munin::plugins::base } diff --git a/manifests/host.pp b/manifests/host.pp index b828e35..05dcb5e 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -3,12 +3,13 @@ # See LICENSE for the full license granted to you. class munin::host( - $cgi_graphing = false + $cgi_graphing = false, + $export_tag = 'munin' ) { package {"munin": ensure => installed, } include concat::setup - Concat::Fragment <<| tag == 'munin' |>> + Concat::Fragment <<| tag == $export_tag |>> concat::fragment{'munin.conf.header': target => '/etc/munin/munin.conf', diff --git a/manifests/register.pp b/manifests/register.pp index 6c154e5..309c322 100644 --- a/manifests/register.pp +++ b/manifests/register.pp @@ -3,15 +3,16 @@ define munin::register ( $port = '4949', $use_ssh = false, $description = 'absent', - $config = [] + $config = [], + $export_tag = 'munin' ) { $fhost = $name $client_type = 'client' @@concat::fragment{ "munin_client_${fhost}_${port}": - target => '/etc/munin/munin.conf', + target => '/etc/munin/munin.conf', content => template("munin/client.erb"), - tag => 'munin', + tag => $export_tag, } } -- cgit v1.2.3 From e822d6140b1ffea7d85546062376a7e464a3cb61 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 20 Mar 2013 12:01:14 +0100 Subject: Security: plugin-config should not me world readable as it might contain passwords --- manifests/plugin.pp | 2 +- manifests/plugins/setup.pp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index e9e5dba..36fc81b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -47,7 +47,7 @@ define munin::plugin ( content => "[${name}]\n${config}\n", owner => root, group => 0, - mode => '0644', + mode => '0640', } } } diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index caf2e28..5c56099 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -1,15 +1,22 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: - ignore => 'snmp_*', - ensure => directory, checksum => mtime, - recurse => true, purge => true, force => true, - mode => 0755, owner => root, group => 0, - notify => Service['munin-node']; + ignore => 'snmp_*', + ensure => directory, + checksum => mtime, + recurse => true, + purge => true, + force => true, + notify => Service['munin-node'], + owner => root, + group => 0, + mode => '0755'; '/etc/munin/plugin-conf.d/munin-node': - ensure => present, - mode => 0644, owner => root, group => 0, - notify => Service['munin-node'], + ensure => present, + notify => Service['munin-node'], + owner => root, + group => 0, + mode => '0640'; } case $::kernel { openbsd: { -- cgit v1.2.3 From 5c15d0cf46cef4b1d01df49b390cd452d8d41f76 Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 14:44:00 -0400 Subject: Security: plugin-config should not me world readable as it might contain passwords --- manifests/plugin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index a0989a8..d243b66 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -52,7 +52,7 @@ define munin::plugin ( default: { file { $plugin_conf: content => "[${name}]\n$config\n", - mode => 0644, owner => root, group => 0, + mode => 0640, owner => root, group => 0, } if $require { File[$plugin_conf]{ -- cgit v1.2.3 From 149a78e7a8465da97f8ea267cd6a75e3bcdefe4d Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 15:28:58 -0400 Subject: Security: another mode change on /etc/munin/plugin-conf.d/munin-node --- manifests/plugins/setup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index 853bc00..2dff15d 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -13,7 +13,7 @@ class munin::plugins::setup { notify => Service['munin-node']; '/etc/munin/plugin-conf.d/munin-node': ensure => present, - mode => 0644, owner => root, group => 0, + mode => 0640, owner => root, group => 0, notify => Service['munin-node'], } case $kernel { -- cgit v1.2.3 From 9dbd0cabcae7a23079253af384bb7104166b935c Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 16:44:17 -0400 Subject: README update: clarify the language so it doesn't specifically talk only about the common module, when concat is also a requirement --- README | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README b/README index 1e47d27..3923d46 100644 --- a/README +++ b/README @@ -5,9 +5,8 @@ a very easy plugin interface. The munin homepage is http://munin.projects.linpro To use this module, follow these directions: -1. Install the "common" and "concat" module -- the munin module depends on functions - that are defined and installed via these modulesh, see README.common for how to do - this +1. Install the "common" and "concat" module -- the munin module depends on + functions that are defined and installed via these modules. 2. You will need storedconfigs enabled in your puppet setup, to do that you need to add a line to your puppet.conf in your [puppetmasterd] section which says: -- cgit v1.2.3 From 4f8c8302b09c302e71cf3ba73022e73673276a9d Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 17:18:22 -0400 Subject: README: update README to reflect a real setup, clarifying exactly how you go about getting things setup --- README | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/README b/README index 3923d46..83a4ad7 100644 --- a/README +++ b/README @@ -27,51 +27,55 @@ To use this module, follow these directions: a. Your modules directory will need all the files included in this repository placed under a directory called "munin" - b. Add your class parameter for munin::client::allow which indicates what IP should be allowed to - connect to your individual munin-nodes (this is typically your main munin host's IP): + b. For every host you wish to gather munin statistics, add the class munin::client to that + node. You will want to set the class parameter 'allow' to be the IP(s) of the munin + collector, this defines what IP is permitted to connect to the node, for example: - munin_allow: '192.168.0.1' - - If you want to define more than one host, you can define them as an array: + node foo { + class { 'munin::client': allow => '192.168.0.1'} + } - munin_allow: ['127.0.0.1','192.168.0.1'] + for multiple munin nodes, you can pass an array: + class { 'munin::client': allow => [ '192.168.0.1', '10.0.0.1' ] } + c. In the node definition in your site.pp for your main munin host, add the following: - include munin::host - - d. On each node that will gather munin statistics, add this line to that node's entry - in site.pp (you may want to also add this to your main munin host): - - include munin::client + class { 'munin::host': } - e. If there are particular munin plugins you want to enable or configure, you define them + If you want cgi graphing you can pass cgi_graphing => true. + (For CentOS this is enabled in the default header config) + for more information, see: http://munin.projects.linpro.no/wiki/CgiHowto + + d. If there are particular munin plugins you want to enable or configure, you define them in the node definition, like follows: # Enable monitoring of disk stats in bytes - munin::plugin { df_abs: } + munin::plugin { 'df_abs': } # Use a non-standard plugin path to use custom plugins - munin::plugin { "spamassassin": - ensure => "spamassassin", - script_path => "/usr/local/share/munin-plugins", + munin::plugin { 'spamassassin': + ensure => present, + script_path => '/usr/local/share/munin-plugins', + } + + # For wildcard plugins (eg. ip_, snmp_, etc.), use the name variable to + # configure the plugin name, and the ensure parameter to indicate the base + # plugin name to which you want a symlink, for example: + munin::plugin { [ 'ip_192.168.0.1', 'ip_10.0.0.1' ]: + ensure => 'ip_' } # Use a special config to pass parameters to the plugin munin::plugin { - [ "apache_accesses", "apache_processes", "apache_volume" ]: + [ 'apache_accesses', 'apache_processes', 'apache_volume' ]: ensure => present, - config => "env.url http://127.0.0.1:80/server-status?auto" + config => 'env.url http://127.0.0.1:80/server-status?auto' } - - f. If you have Linux-Vservers configured, you will likely have multiple munin-node processes + e. If you have Linux-Vservers configured, you will likely have multiple munin-node processes competing for the default port 4949, for those nodes, set an alternate port for munin-node to run on by putting something similar to the following class parameter: - port => 4948 - - g. If you'd like to do cgi graphing, please note the following page: http://munin.projects.linpro.no/wiki/CgiHowto - For CentOS this is enabled in the default header config + class { 'munin::client': allow => '192.168.0.1', port => '4948' } - h. Per default (on CentOS) munin will send warnings and critical messages to root -- cgit v1.2.3 From f79f662bedbbd75c7e2022da282ba48c1b323e90 Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 18:15:20 -0400 Subject: README: stdlib is a required module due to the reject() --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 83a4ad7..ab962a0 100644 --- a/README +++ b/README @@ -5,8 +5,8 @@ a very easy plugin interface. The munin homepage is http://munin.projects.linpro To use this module, follow these directions: -1. Install the "common" and "concat" module -- the munin module depends on - functions that are defined and installed via these modules. +1. Install the "common", "concat" and "stdlib" modules -- the munin module + depends on functions that are defined and installed via these modules. 2. You will need storedconfigs enabled in your puppet setup, to do that you need to add a line to your puppet.conf in your [puppetmasterd] section which says: -- cgit v1.2.3 From d7b7240acbd4bfd89beae245cc8da6d667c6dfff Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 20 Mar 2013 18:31:12 -0400 Subject: README: note that puppet 2.7 is required --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index ab962a0..ef3c2fd 100644 --- a/README +++ b/README @@ -5,6 +5,8 @@ a very easy plugin interface. The munin homepage is http://munin.projects.linpro To use this module, follow these directions: +0. This module requires puppet 2.7 or newer. + 1. Install the "common", "concat" and "stdlib" modules -- the munin module depends on functions that are defined and installed via these modules. -- cgit v1.2.3 From 8ca2751bbb58358b7e1fb19d0e6e88b2b2654c26 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 30 Mar 2013 13:32:54 +0100 Subject: migrate all templates to the parametrized classes style --- templates/munin-node.conf.Debian.etch | 2 +- templates/munin-node.conf.Debian.lenny | 10 +++++----- templates/munin-node.conf.Debian.wheezy | 10 +++++----- templates/munin-node.conf.OpenBSD | 2 +- templates/munin-node.conf.Ubuntu | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch index 44638e7..9763772 100644 --- a/templates/munin-node.conf.Debian.etch +++ b/templates/munin-node.conf.Debian.etch @@ -27,7 +27,7 @@ ignore_file \.rpm(save|new)$ # telnetting to localhost, port 4949 # #host_name localhost.localdomain -host_name <%= fqdn %> +host_name <%= scope.lookupvar('::fqdn') %> # A list of addresses that are allowed to connect. This must be a # regular expression, due to brain damage in Net::Server, which diff --git a/templates/munin-node.conf.Debian.lenny b/templates/munin-node.conf.Debian.lenny index 56da89d..9763772 100644 --- a/templates/munin-node.conf.Debian.lenny +++ b/templates/munin-node.conf.Debian.lenny @@ -9,8 +9,8 @@ background 1 setseid 1 # Which host/port to bind to; -host <%= munin_host_real %> -port <%= munin_port_real %> +host <%= scope.lookupvar('munin::client::host') %> +port <%= scope.lookupvar('munin::client::port') %> user root group root setsid yes @@ -27,13 +27,13 @@ ignore_file \.rpm(save|new)$ # telnetting to localhost, port 4949 # #host_name localhost.localdomain -host_name <%= fqdn %> +host_name <%= scope.lookupvar('::fqdn') %> # A list of addresses that are allowed to connect. This must be a # regular expression, due to brain damage in Net::Server, which # doesn't understand CIDR-style network notation. You may repeat # the allow line as many times as you'd like -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.lookupvar('munin::client::allow').each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> diff --git a/templates/munin-node.conf.Debian.wheezy b/templates/munin-node.conf.Debian.wheezy index 2b5d41f..fe6f27f 100644 --- a/templates/munin-node.conf.Debian.wheezy +++ b/templates/munin-node.conf.Debian.wheezy @@ -27,15 +27,15 @@ ignore_file \.pod$ # telnetting to localhost, port 4949 # #host_name localhost.localdomain -host_name <%= fqdn %> +host_name <%= scope.lookupvar('::fqdn') %> # A list of addresses that are allowed to connect. This must be a # regular expression, since Net::Server does not understand CIDR-style # network notation unless the perl module Net::CIDR is installed. You # may repeat the allow line as many times as you'd like -<% real_munin_allow.split(':').each do |val| -%> -allow <%= '^'+val.gsub(/\./, '\.')+'$' %> +<% scope.lookupvar('munin::client::allow').each do |allow| -%> +allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> # If you have installed the Net::CIDR perl module, you can use one or more @@ -50,8 +50,8 @@ allow <%= '^'+val.gsub(/\./, '\.')+'$' %> # cidr_deny 192.0.2.42/32 # Which address to bind to; -host <%= munin_host_real %> +host <%= scope.lookupvar('munin::client::host') %> # And which port -port <%= munin_port_real %> +port <%= scope.lookupvar('munin::client::port') %> diff --git a/templates/munin-node.conf.OpenBSD b/templates/munin-node.conf.OpenBSD index 4e2f534..14b658e 100644 --- a/templates/munin-node.conf.OpenBSD +++ b/templates/munin-node.conf.OpenBSD @@ -28,7 +28,7 @@ ignore_file \.pod$ # telnetting to localhost, port 4949 # #host_name localhost.localdomain -host_name <%= fqdn %> +host_name <%= scope.lookupvar('::fqdn') %> # A list of addresses that are allowed to connect. This must be a # regular expression, since Net::Server does not understand CIDR-style diff --git a/templates/munin-node.conf.Ubuntu b/templates/munin-node.conf.Ubuntu index 17162d8..9763772 100644 --- a/templates/munin-node.conf.Ubuntu +++ b/templates/munin-node.conf.Ubuntu @@ -9,8 +9,8 @@ background 1 setseid 1 # Which host/port to bind to; -host <%= scope.function_hiera('munin_host','*') %> -port <%= scope.function_hiera('munin_port','4949') %> +host <%= scope.lookupvar('munin::client::host') %> +port <%= scope.lookupvar('munin::client::port') %> user root group root setsid yes @@ -27,13 +27,13 @@ ignore_file \.rpm(save|new)$ # telnetting to localhost, port 4949 # #host_name localhost.localdomain -host_name <%= fqdn %> +host_name <%= scope.lookupvar('::fqdn') %> # A list of addresses that are allowed to connect. This must be a # regular expression, due to brain damage in Net::Server, which # doesn't understand CIDR-style network notation. You may repeat # the allow line as many times as you'd like -<% scope.function_hiera('munin_allow',['127.0.0.1']).each do |allow| -%> +<% scope.lookupvar('munin::client::allow').each do |allow| -%> allow <%= "^#{Regexp.escape(allow)}$" %> <% end -%> -- cgit v1.2.3 From fe7b3b5cc614378e9451640d1fa0e125e022b847 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 17 Apr 2013 15:29:34 -0400 Subject: fix dependency on Concat::Fragment['munin.conf.header'], was set to File which would cause this: err: Failed to apply catalog: Could not find dependency File[/etc/munin/munin.conf.header] for Exec[set_modes_for_cgi] at /etc/puppet/modules/munin/manifests/host/cgi.pp:6 --- manifests/host/cgi.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 9980856..750c72d 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -2,7 +2,7 @@ class munin::host::cgi { exec{'set_modes_for_cgi': command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', refreshonly => true, - subscribe => File['/etc/munin/munin.conf.header'], + subscribe => Concat::Fragment['munin.conf.header'], } file{'/etc/logrotate.d/munin': -- cgit v1.2.3 From a5ce0a9317fc5dd5228cff4c5b6d36366c17b6d5 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 17 Apr 2013 15:53:03 -0400 Subject: setup $::operatingsystem triggered variables for the apache_user and document_root --- manifests/host/cgi.pp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index 750c72d..0c11d32 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -1,8 +1,20 @@ class munin::host::cgi { + + case $::operatingsystem { + debian,ubuntu: { + $apache_user = 'www-data' + $document_root = '/var/www/munin' + } + default: { + $apache_user = 'apache' + $document_root = '/var/www/html/munin' + } + } + exec{'set_modes_for_cgi': - command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + command => "chgrp ${apache_user} /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find ${document_root}/* -maxdepth 1 -type d -exec chgrp -R ${apache_user} {} \; && find ${document_root}/* -maxdepth 1 -type d -exec chmod -R g+w {} \;", refreshonly => true, - subscribe => Concat::Fragment['munin.conf.header'], + subscribe => Concat::Fragment['munin.conf.header'], } file{'/etc/logrotate.d/munin': -- cgit v1.2.3