summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2013-04-17 16:36:37 -0400
committerMicah Anderson <micah@riseup.net>2013-04-17 16:36:37 -0400
commit8f7c0071eb82591477876eeb3f309067853a3261 (patch)
treeb095f01b960b7ba3699da2dfa4d84cd5bb8a6361
parentea31faee76141646c173d88bd5bec5aa4a773c1c (diff)
parenta5ce0a9317fc5dd5228cff4c5b6d36366c17b6d5 (diff)
Merge branch 'master' into leap
Conflicts: README manifests/host/cgi.pp
-rw-r--r--README65
-rw-r--r--files/config/host/munin.conf.header.CentOS88
-rw-r--r--files/config/host/munin.conf.header.Debian.sid75
-rw-r--r--files/config/host/munin.conf.header.Debian.squeeze75
-rw-r--r--files/config/host/munin.conf.header.Debian.wheezy75
-rwxr-xr-xfiles/plugins/apache_activity99
-rw-r--r--files/plugins/kvm_cpu101
-rw-r--r--files/plugins/kvm_io109
-rw-r--r--files/plugins/kvm_mem106
-rw-r--r--files/plugins/kvm_net148
-rwxr-xr-xfiles/plugins/selinux_avcstats111
-rwxr-xr-xfiles/plugins/selinuxenforced30
-rwxr-xr-xfiles/plugins/xen2
-rwxr-xr-xfiles/plugins/xen-cpu121
-rw-r--r--files/plugins/xen_cpu189
-rw-r--r--files/plugins/xen_mem6
-rw-r--r--files/plugins/xen_traffic_all75
-rwxr-xr-xfiles/plugins/xen_vbd14
-rw-r--r--files/plugins/xen_vm4
-rw-r--r--manifests/client.pp42
-rw-r--r--manifests/client/base.pp50
-rw-r--r--manifests/client/centos.pp2
-rw-r--r--manifests/client/darwin.pp40
-rw-r--r--manifests/client/debian.pp27
-rw-r--r--manifests/client/gentoo.pp2
-rw-r--r--manifests/client/openbsd.pp105
-rw-r--r--manifests/client/package.pp27
-rw-r--r--manifests/host.pp54
-rw-r--r--manifests/host/cgi.pp36
-rw-r--r--manifests/init.pp5
-rw-r--r--manifests/plugin.pp102
-rw-r--r--manifests/plugin/deploy.pp49
-rw-r--r--manifests/plugin/scriptpaths.pp20
-rw-r--r--manifests/plugins/apache.pp4
-rw-r--r--manifests/plugins/base.pp10
-rw-r--r--manifests/plugins/dom0.pp2
-rw-r--r--manifests/plugins/gentoo.pp6
-rw-r--r--manifests/plugins/interfaces.pp19
-rw-r--r--manifests/plugins/kvm.pp7
-rw-r--r--manifests/plugins/linux.pp2
-rw-r--r--manifests/plugins/physical.pp2
-rw-r--r--manifests/plugins/selinux.pp2
-rw-r--r--manifests/plugins/setup.pp30
-rw-r--r--manifests/register.pp40
-rw-r--r--manifests/register/snmp.pp33
-rw-r--r--manifests/remoteplugin.pp28
-rw-r--r--manifests/snmp_collector.pp22
-rw-r--r--templates/client.erb15
-rw-r--r--templates/munin-node.conf.Debian.etch10
-rw-r--r--templates/munin-node.conf.Debian.lenny10
l---------templates/munin-node.conf.Debian.lucid1
-rw-r--r--templates/munin-node.conf.Debian.wheezy10
-rw-r--r--[l---------]templates/munin-node.conf.OpenBSD60
-rw-r--r--templates/munin-node.conf.Ubuntu39
l---------templates/munin-node.conf.Ubuntu.precise1
l---------templates/munin-node.conf.Ubuntu.quantal1
-rw-r--r--templates/munin-node.conf.default27
57 files changed, 1538 insertions, 897 deletions
diff --git a/README b/README
index b6ead1c..b386c66 100644
--- a/README
+++ b/README
@@ -5,8 +5,10 @@ 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
+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.
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:
@@ -49,56 +51,51 @@ To use this module, follow these directions:
On pre-lenny systems, you have to use the older Regexp-variant:
- $munin_allow = '^192\.168\.0\.1$'
-
- e. In the node definition in your site.pp for your main munin host, add the following:
-
- include munin::host
+ node foo {
+ class { 'munin::client': allow => '192.168.0.1'}
+ }
- If you want to specify a particular package version for the main munin
- host, you can set the $munin_ensure_version variable _before_ the above
- include, like this
+ for multiple munin nodes, you can pass an array:
- $munin_ensure_version = "1.2.6-17"
-
- f. 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):
+ class { 'munin::client': allow => [ '192.168.0.1', '10.0.0.1' ] }
- include munin::client
+ c. In the node definition in your site.pp for your main munin host, add the following:
- If you want to specify a particular package version for the munin
- client, you can set the $munin_node_ensure_version variable _before_ the
- above include, like this
+ class { 'munin::host': }
- $munin_node_ensure_version = "1.2.6-17"
+ 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
- g. If there are particular munin plugins you want to enable or configure, you define them
+ 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_in => "/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'
}
-
- h. 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 in the node definition:
-
- $munin_port = 4948
+ to run on by putting something similar to the following class parameter:
- i. 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' }
- j. Per default (on CentOS) munin will send warnings and critical messages to root
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]
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.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 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/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/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..43941f5
--- /dev/null
+++ b/files/plugins/kvm_io
@@ -0,0 +1,109 @@
+#!/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..14fb793
--- /dev/null
+++ b/files/plugins/kvm_mem
@@ -0,0 +1,106 @@
+#!/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..c7b5aca
--- /dev/null
+++ b/files/plugins/kvm_net
@@ -0,0 +1,148 @@
+#!/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(vms):
+ ''' 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 pid in vms:
+ macs = get_vm_macs(pid)
+ i = 0
+ for mac in macs:
+ 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_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)
+ i += 1
+
+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)
+ i = 0
+ for mac in macs:
+ inf = macs_to_inf[mac]
+ values = interfaces[inf]
+ if len(values) == 2:
+ 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
+ '''
+ 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()))
+ else:
+ fetch(find_vm_names(list_pids()))
+ else:
+ fetch(find_vm_names(list_pids()))
+
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/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-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 <doo <at> shroom <dot> 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 = <FH>;
+
+ if ( $debug )
+ {
+ print "Oldtime: $oldtime\n";
+ }
+
+ while (<FH>)
+ {
+ # 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/files/plugins/xen_mem b/files/plugins/xen_mem
index 16d91cf..a260fbd 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
@@ -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_traffic_all b/files/plugins/xen_traffic_all
index c5bbfbb..72f3b27 100644
--- a/files/plugins/xen_traffic_all
+++ b/files/plugins/xen_traffic_all
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Author: mario manno <projects@manno.name>
# Description: measure traffic for all xen hosts
#
@@ -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
@@ -32,6 +32,19 @@ if [ "$1" = "autoconf" ]; then
exit 0
fi
+# we update network devices only twice an hour
+function net_state {
+ dom=$1
+ 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
+ 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 +52,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 +94,7 @@ for dom in $DOMAINS; do
print name"Down.value " $1 "\n"name"Up.value " $9 \
}' \
/proc/net/dev
- done
+ done
+ fi
done
diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd
index 4eca5a6..e34d41c 100755
--- a/files/plugins/xen_vbd
+++ b/files/plugins/xen_vbd
@@ -17,8 +17,8 @@ $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_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_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
if ( defined($ARGV[0]))
@@ -50,8 +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`;
- shift(@domains); # we don't need the header line
+ @domains = `cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Domain-0'`;
foreach $domain ( @domains )
{
@@ -86,12 +85,9 @@ 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 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);
diff --git a/files/plugins/xen_vm b/files/plugins/xen_vm
index a69b5fe..725e800 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
@@ -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))
diff --git a/manifests/client.pp b/manifests/client.pp
index 273070d..2316bc9 100644
--- a/manifests/client.pp
+++ b/manifests/client.pp
@@ -3,24 +3,28 @@
# See LICENSE for the full license granted to you.
# Adapted and improved by admin(at)immerda.ch
-class munin::client inherits munin {
-
- $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 }
- 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
+class munin::client(
+ $allow = [ '127.0.0.1' ],
+ $host = '*',
+ $port = '4949',
+ $use_ssh = false,
+ $manage_shorewall = false,
+ $shorewall_collector_source = 'net',
+ $export_tag = '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 $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 7c2adc2..78398a9 100644
--- a/manifests/client/base.pp
+++ b/manifests/client/base.pp
@@ -1,26 +1,28 @@
class munin::client::base {
-
- service { 'munin-node':
- ensure => running,
- enable => true,
- hasstatus => true,
- hasrestart => true,
- }
- file {'/etc/munin':
- 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'],
- 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:
+ 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'],
+ export_tag => $munin::client::export_tag,
+ }
+ 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/darwin.pp b/manifests/client/darwin.pp
index 9cfe7e9..264263d 100644
--- a/manifests/client/darwin.pp
+++ b/manifests/client/darwin.pp
@@ -1,22 +1,22 @@
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,
+ }
+ line{"startsnmpdno":
+ file => "/etc/hostconfig",
+ line => "SNMPSERVER=-NO-",
+ ensure => 'absent',
+ }
+ 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: }
}
diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp
index 60b496d..e67ac26 100644
--- a/manifests/client/debian.pp
+++ b/manifests/client/debian.pp
@@ -1,18 +1,15 @@
class munin::client::debian inherits munin::client::package {
+ # the plugin will need that
+ package { "iproute": ensure => installed }
- # the plugin will need that
- if !defined(Package['iproute']) {
- 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 d4fe71e..e79f6b0 100644
--- a/manifests/client/gentoo.pp
+++ b/manifests/client/gentoo.pp
@@ -5,5 +5,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 89b5752..cd21abf 100644
--- a/manifests/client/openbsd.pp
+++ b/manifests/client/openbsd.pp
@@ -2,60 +2,61 @@
# :(
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,
- }
- }
- 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;
+ 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';
}
- 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'],
+ 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'],
}
- 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'] ],
+ package{'p5-Compress-Zlib':
+ ensure => installed,
+ before => File['/var/run/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';
+ }
+ $bin_loc = $::operatingsystemrelease ? {
+ '4.3' => '/opt/munin/sbin/munin-node',
+ default => '/usr/local/sbin/munin-node'
+ }
+ openbsd::rc_local{'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 => $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,
+ weekday => 0,
+ }
}
diff --git a/manifests/client/package.pp b/manifests/client/package.pp
index 29f256d..206ccc8 100644
--- a/manifests/client/package.pp
+++ b/manifests/client/package.pp
@@ -1,21 +1,12 @@
class munin::client::package inherits munin::client::base {
-
- if $munin_node_ensure_version == '' { $munin_node_ensure_version = 'installed' }
-
- if $operatingsystem == "Debian" and $lsbdistcodename != "lenny" {
- package { 'munin-common':
- before => Package['munin-node'],
- ensure => $munin_node_ensure_version;
- }
- }
- package { 'munin-node': ensure => $munin_node_ensure_version }
- 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 9d30d6a..05dcb5e 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -2,40 +2,35 @@
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# See LICENSE for the full license granted to you.
-class munin::host inherits munin
-{
+class munin::host(
+ $cgi_graphing = false,
+ $export_tag = 'munin'
+) {
+ package {"munin": ensure => installed, }
+ include concat::setup
- if $munin_ensure_version == '' { $munin_ensure_version = 'installed' }
+ Concat::Fragment <<| tag == $export_tag |>>
- package {"munin": ensure => $munin_ensure_version, }
-
- 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",
- "puppet:///modules/munin/config/host/munin.conf.header.$operatingsystem",
+ 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",
+ "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" ],
- notify => Exec['concat_/etc/munin/munin.conf'],
- owner => root, group => 0, mode => 0644;
+ order => 05,
}
-
- concatenated_file { "/etc/munin/munin.conf":
- dir => '/var/lib/puppet/modules/munin/nodes',
- 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;
+
+ concat{ "/etc/munin/munin.conf":
+ owner => root, group => 0, mode => 0644;
}
-
+
include munin::plugins::muninhost
-
- case $operatingsystem {
- centos: { include munin::host::cgi }
+
+ if $munin::host::cgi_graphing {
+ include munin::host::cgi
}
# from time to time we cleanup hanging munin-runs
@@ -43,8 +38,7 @@ class munin::host inherits munin
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 $munin::host::manage_shorewall {
include shorewall::rules::out::munin
}
}
diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp
index ab09168..0c11d32 100644
--- a/manifests/host/cgi.pp
+++ b/manifests/host/cgi.pp
@@ -1,27 +1,27 @@
-class munin::host::cgi inherits munin::host {
+class munin::host::cgi {
- 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 {} \;',
- refreshonly => true,
- subscribe => File['/etc/munin/munin.conf.header'],
- }
+ case $::operatingsystem {
+ debian,ubuntu: {
+ $apache_user = 'www-data'
+ $document_root = '/var/www/munin'
}
default: {
- 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'],
- }
+ $apache_user = 'apache'
+ $document_root = '/var/www/html/munin'
}
}
-
+
+ exec{'set_modes_for_cgi':
+ 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'],
+ }
+
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",
+ 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/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/plugin.pp b/manifests/plugin.pp
index a0989a8..ffe5452 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -1,67 +1,57 @@
-# plugin.pp - configure a specific munin plugin
-# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
-# See LICENSE for the full license granted to you.
-# adapted and improved by admin(at)immerda.ch
-
-### defines
-
+# configure a specific munin plugin
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"
-
- 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'];
- }
+ $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: {
+ $dep = $::kernel ? {
+ OpenBSD => File['/var/run/munin'],
+ default => Package['munin-node']
+ }
+ file { $plugin:
+ 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]{
+ 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",
+ owner => root,
+ group => 0,
+ mode => '0640',
+ }
}
+ }
}
+ }
}
diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp
index 0ab4e9f..cbf64fb 100644
--- a/manifests/plugin/deploy.pp
+++ b/manifests/plugin/deploy.pp
@@ -1,39 +1,44 @@
-define munin::plugin::deploy( $source = '', $ensure = 'present', $config = '' )
-{
+# deploy and register a munin plugin
+define munin::plugin::deploy(
+ $ensure = 'present',
+ $source = '',
+ $config = '',
+ $seltype = 'munin_exec_t'
+) {
$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://$server/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';
}
- 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 {
+ if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){
File["munin_plugin_${name}"]{
- require => $basic_require,
+ seltype => $seltype,
}
}
+ case $::kernel {
+ openbsd: { $basic_require = File['/var/run/munin'] }
+ default: { $basic_require = Package['munin-node'] }
+ }
+ 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 }
+ munin::plugin{$name:
+ ensure => $ensure,
+ config => $config
}
}
diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp
index 164a17e..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/apache.pp b/manifests/plugins/apache.pp
deleted file mode 100644
index b3e7634..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": }
-}
diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp
index bfccae5..c6b88ed 100644
--- a/manifests/plugins/base.pp
+++ b/manifests/plugins/base.pp
@@ -1,14 +1,18 @@
class munin::plugins::base {
-
# setup basic plugins
munin::plugin {
[ df, cpu, interrupts, load, memory, netstat, open_files,
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 {
+ case $::kernel {
openbsd: { include munin::plugins::openbsd }
linux: {
case $vserver {
@@ -18,7 +22,7 @@ class munin::plugins::base {
}
}
- case $virtual {
+ case $::virtual {
physical: { include munin::plugins::physical }
xen0: { include munin::plugins::dom0 }
}
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';
}
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 18a713b..da89ed0 100644
--- a/manifests/plugins/interfaces.pp
+++ b/manifests/plugins/interfaces.pp
@@ -1,21 +1,24 @@
# handle if_ and if_err_ plugins
-class munin::plugins::interfaces {
+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+|__tmp\d+')
+ $ifs = regsubst($real_ifs, '(.+)', "if_\\1")
- $ifs = regsubst(split($interfaces, " |,"), "(.+)", "if_\\1")
munin::plugin {
- $ifs: ensure => "if_";
+ $ifs: ensure => 'if_';
}
- case $operatingsystem {
+ 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_";
+ $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_";
+ $if_errs: ensure => 'if_err_';
}
}
}
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';
+ }
+}
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/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/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' ]: }
}
diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp
index c2c5ed3..197b657 100644
--- a/manifests/plugins/setup.pp
+++ b/manifests/plugins/setup.pp
@@ -1,18 +1,28 @@
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",
- ignore => [ '.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 {
+ 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 21f1d35..309c322 100644
--- a/manifests/register.pp
+++ b/manifests/register.pp
@@ -1,34 +1,18 @@
define munin::register (
- $host = 'absent',
- $port = 'absent',
+ $host = $::fqdn,
+ $port = '4949',
+ $use_ssh = false,
$description = 'absent',
- $config = []
+ $config = [],
+ $export_tag = 'munin'
)
{
- $fhost = $name
- $client_type = 'client'
+ $fhost = $name
+ $client_type = 'client'
- $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',
- }
+ @@concat::fragment{ "munin_client_${fhost}_${port}":
+ target => '/etc/munin/munin.conf',
+ content => template("munin/client.erb"),
+ tag => $export_tag,
+ }
}
diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp
index 0c3ac5c..78c3e91 100644
--- a/manifests/register/snmp.pp
+++ b/manifests/register/snmp.pp
@@ -1,22 +1,21 @@
define munin::register::snmp (
$community = 'public',
- $description = 'absent'
-)
-{
- $fhost = $name
- $munin_host_real = $fqdn
- $client_type = 'snmp'
- $config = [ 'use_node_name no' ]
+ $description = 'absent',
+ $port = '4949',
+ $host = $::fqdn
+) {
+ $fhost = $name
+ $client_type = 'snmp'
+ $config = [ 'use_node_name no' ]
- 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",
+ }
- @@file { "munin_snmp_${fhost}":
- ensure => present,
- path => "/var/lib/puppet/modules/munin/nodes/${fhost}",
- 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",
+ }
}
+ }
}
diff --git a/manifests/snmp_collector.pp b/manifests/snmp_collector.pp
index 7bd8bba..0f8318a 100644
--- a/manifests/snmp_collector.pp
+++ b/manifests/snmp_collector.pp
@@ -1,14 +1,14 @@
class munin::snmp_collector{
- file {
- "/var/lib/puppet/modules/munin/create_snmp_links":
- source => "puppet:///modules/munin/create_snmp_links.sh",
- mode => 755, owner => root, group => 0;
- }
+ file {
+ "/var/lib/puppet/modules/munin/create_snmp_links":
+ source => "puppet:///modules/munin/create_snmp_links.sh",
+ mode => 755, owner => root, group => 0;
+ }
- exec { "create_snmp_links":
- command => "/var/lib/puppet/modules/munin/create_snmp_links /var/lib/puppet/modules/munin/nodes",
- require => File["snmp_links"],
- timeout => "2048",
- schedule => daily
- }
+ exec { "create_snmp_links":
+ command => "/var/lib/puppet/modules/munin/create_snmp_links /var/lib/puppet/modules/munin/nodes",
+ require => File["snmp_links"],
+ timeout => "2048",
+ schedule => daily
+ }
}
diff --git a/templates/client.erb b/templates/client.erb
index 15e05c6..ba03da5 100644
--- a/templates/client.erb
+++ b/templates/client.erb
@@ -1,19 +1,24 @@
<%
# Downcase all information
- dom = domain.downcase
- host = hostname.downcase
+ dom = scope.lookupvar('::domain').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 %>
+<% 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 -%>
+
diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch
index 56da89d..9763772 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.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.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.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
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 082b30c..14b658e 120000..100644
--- a/templates/munin-node.conf.OpenBSD
+++ b/templates/munin-node.conf.OpenBSD
@@ -1 +1,59 @@
-munin-node.conf.default \ No newline at end of file
+##########
+########## 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 <%= 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
+
+<% 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.Ubuntu b/templates/munin-node.conf.Ubuntu
new file mode 100644
index 0000000..9763772
--- /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.lookupvar('munin::client::host') %>
+port <%= scope.lookupvar('munin::client::port') %>
+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 <%= 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.lookupvar('munin::client::allow').each do |allow| -%>
+allow <%= "^#{Regexp.escape(allow)}$" %>
+<% end -%>
+
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
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
diff --git a/templates/munin-node.conf.default b/templates/munin-node.conf.default
index e584df1..9d7f32f 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
@@ -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 %$
@@ -37,24 +35,25 @@ 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.lookupvar('munin::client::allow').each do |allow| -%>
+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
-
# Which address to bind to;
-host <%= munin_host_real %>
+host <%= scope.lookupvar('munin::client::host') %>
# host 127.0.0.1
# And which port
-port <%= munin_port_real %>
+port <%= scope.lookupvar('munin::client::port') %>