summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README83
-rw-r--r--manifests/client.pp122
-rw-r--r--manifests/host.pp33
-rw-r--r--manifests/init.pp17
-rw-r--r--manifests/plugin.pp127
-rw-r--r--plugins/facter/acpi_available.rb10
-rwxr-xr-xplugins/facter/interfaces.rb13
-rw-r--r--templates/defaultclient.erb14
-rw-r--r--templates/munin-node.conf.Debian.etch36
l---------templates/munin-node.conf.Debian.sarge1
l---------templates/munin-node.conf.Debian.sid1
-rw-r--r--templates/munin-node.conf.Gentoo39
l---------templates/munin-node.conf.Gentoo.1
13 files changed, 497 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..762a802
--- /dev/null
+++ b/README
@@ -0,0 +1,83 @@
+
+Munin is a performance monitoring system which creates nice RRD graphs and has
+a very easy plugin interface. The munin homepage is http://munin.projects.linpro.no/
+
+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
+
+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:
+
+ storeconfigs=true
+
+ You may wish to immediately setup a mysql/pgsql database for your storedconfigs, as
+ the default method uses sqlite, and is not very efficient, to do that you need lines
+ such as the following below the storeconfigs=true line (adjust as needed):
+
+ dbadapter=mysql
+ dbserver=localhost
+ dbuser=puppet
+ dbpassword=puppetspasswd
+
+3. Install the "munin" module:
+
+ a. Your modules directory will need all the files included in this repository placed
+ under a directory called "munin"
+
+ b. add the following line to your modules.pp:
+
+ import "munin"
+
+ (NOTE: if you have followed the directions in README.common then you will have import
+ "modules.pp" in your site.pp, if you do not have that, then you will need to add the
+ import line to your site.pp)
+
+ c. you will also need to create the following empty directories:
+
+ mkdir /etc/puppet/modules/munin/files/empty
+ mkdir /etc/puppet/modules/munin/files/modules_dir
+ mkdir -p /etc/puppet/modules/munin/files/nodes/modules_dir
+ mkdir -p /etc/puppet/modules/munin/files/plugins/modules_dir
+
+ d. Add to the top of your site.pp a variable which indicates what IP should be allowed to
+ connect to your individual munin-nodes (this is typically your main munin host's IP):
+
+ $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
+
+ 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):
+
+ include munin::client
+
+ g. 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: }
+
+ # Use a non-standard plugin path to use custom plugins
+ munin::plugin { "spamassassin":
+ ensure => "spamassassin",
+ script_path => "/usr/local/share/munin-plugins",
+ }
+
+ # Use a special config to pass parameters to the plugin
+ munin::plugin {
+ [ "apache_accesses", "apache_processes", "apache_volume" ]:
+ ensure => present,
+ 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
+ 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
+
diff --git a/manifests/client.pp b/manifests/client.pp
new file mode 100644
index 0000000..5b78186
--- /dev/null
+++ b/manifests/client.pp
@@ -0,0 +1,122 @@
+# client.pp - configure a munin node
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+class munin::client {
+
+ $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
+ $munin_host_real = $munin_host ? {
+ '' => '*',
+ 'fqdn' => '*',
+ default => $munin_host
+ }
+
+ case $operatingsystem {
+ darwin: { include munin::client::darwin }
+ debian: {
+ include munin::client::debian
+ include munin::plugins::debian
+ }
+ ubuntu: {
+ info ( "Trying to configure Ubuntu's munin with Debian class" )
+ include munin::client::debian
+ include munin::plugins::debian
+ }
+ default: { fail ("Don't know how to handle munin on $operatingsystem") }
+ }
+
+ case $kernel {
+ linux: {
+ case $vserver {
+ guest: { include munin::plugins::vserver }
+ default: {
+ include munin::plugins::linux
+ case $virtual {
+ xen0: { include munin::plugins::xen }
+ }
+ }
+ }
+ }
+ default: {
+ err( "Don't know which munin plugins to install for $kernel" )
+ }
+ }
+
+}
+
+define munin::register()
+{
+ $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
+ $munin_host_real = $munin_host ? {
+ '' => $fqdn,
+ 'fqdn' => $fqdn,
+ default => $munin_host
+ }
+
+ @@file { "${NODESDIR}/${name}_${munin_port_real}":
+ ensure => present,
+ content => template("munin/defaultclient.erb"),
+ }
+}
+
+define munin::register_snmp()
+{
+ @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
+ ensure => present,
+ content => template("munin/snmpclient.erb"),
+ }
+}
+
+class munin::client::darwin
+{
+ file { "/usr/share/snmp/snmpd.conf":
+ mode => 744,
+ content => template("munin/darwin_snmpd.conf.erb"),
+ group => staff,
+ 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: }
+}
+
+class munin::client::debian
+{
+
+ package { "munin-node": ensure => installed }
+
+ file {
+ "/etc/munin/":
+ ensure => directory,
+ mode => 0755, owner => root, group => root;
+ "/etc/munin/munin-node.conf":
+ content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
+ mode => 0644, owner => root, group => root,
+ # this has to be installed before the package, so the postinst can
+ # boot the munin-node without failure!
+ before => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+
+ service { "munin-node":
+ ensure => running,
+ # sarge's munin-node init script has no status
+ hasstatus => $lsbdistcodename ? { sarge => false, default => true }
+ }
+
+ munin::register { $fqdn: }
+
+ # workaround bug in munin_node_configure
+ plugin { "postfix_mailvolume": ensure => absent }
+}
+
diff --git a/manifests/host.pp b/manifests/host.pp
new file mode 100644
index 0000000..8a90cc2
--- /dev/null
+++ b/manifests/host.pp
@@ -0,0 +1,33 @@
+# host.pp - the master host of the munin installation
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+class munin::host
+{
+ package { [ "munin", "nmap"]: ensure => installed, }
+
+ File <<||>>
+
+ concatenated_file { "/etc/munin/munin.conf":
+ dir => $NODESDIR,
+ header => "/etc/munin/munin.conf.header",
+ }
+
+}
+
+class munin::snmp_collector
+{
+
+ file {
+ "/var/lib/puppet/modules/munin/create_snmp_links":
+ source => "puppet://$servername/munin/create_snmp_links.sh",
+ mode => 755, owner => root, group => root;
+ }
+
+ exec { "create_snmp_links":
+ command => "/var/lib/puppet/modules/munin/create_snmp_links $NODESDIR",
+ require => File["snmp_links"],
+ timeout => "2048",
+ schedule => daily
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644
index 0000000..a1ea92c
--- /dev/null
+++ b/manifests/init.pp
@@ -0,0 +1,17 @@
+# munin.pp - everything a sitewide munin installation needs
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+# the port is a parameter so vservers can share IP addresses and still be happy
+
+# Define where the individual nodes' configs are stored
+$NODESDIR="/var/lib/puppet/modules/munin/nodes"
+
+modules_dir { [ "munin", "munin/nodes", "munin/plugins" ]: }
+
+import "host.pp"
+import "client.pp"
+import "plugin.pp"
+
+include assert_lsbdistcodename
+
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
new file mode 100644
index 0000000..e7e22d1
--- /dev/null
+++ b/manifests/plugin.pp
@@ -0,0 +1,127 @@
+# 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.
+
+define munin::plugin (
+ $ensure = "present",
+ $script_path = "/usr/share/munin/plugins",
+ $config = '')
+{
+ debug ( "munin_plugin: name=$name, ensure=$ensure, script_path=$script_path" )
+ $plugin = "/etc/munin/plugins/$name"
+ $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf"
+ case $ensure {
+ "absent": {
+ debug ( "munin_plugin: suppressing $plugin" )
+ file { $plugin: ensure => absent, }
+ }
+ default: {
+ $plugin_src = $ensure ? { "present" => $name, default => $ensure }
+ debug ( "munin_plugin: making $plugin using src: $plugin_src" )
+ file { $plugin:
+ ensure => "$script_path/${plugin_src}",
+ require => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+ }
+ }
+ case $config {
+ '': {
+ debug("no config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ case $ensure {
+ absent: {
+ debug("removing config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ debug("creating $plugin_conf")
+ file { $plugin_conf:
+ content => "[${name}]\n$config\n",
+ mode => 0644, owner => root, group => root,
+ }
+ }
+ }
+ }
+ }
+}
+
+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 => root;
+ }
+ munin::plugin { $name:
+ ensure => $ensure,
+ config => $config,
+ script_path => "/var/lib/puppet/modules/munin/plugins",
+ }
+ }
+ }
+}
+
+class munin::plugins::base {
+
+ file {
+ [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]:
+ source => "puppet://$servername/munin/empty",
+ ensure => directory, checksum => mtime,
+ recurse => true, purge => true, force => true,
+ mode => 0755, owner => root, group => root,
+ notify => Service[munin-node];
+ "/etc/munin/plugin-conf.d/munin-node":
+ ensure => present,
+ mode => 0644, owner => root, group => root,
+ notify => Service[munin-node];
+ }
+
+}
+
+# handle if_ and if_err_ plugins
+class munin::plugins::interfaces inherits munin::plugins::base {
+
+ $ifs = gsub(split($interfaces, " "), "(.+)", "if_\\1")
+ $if_errs = gsub(split($interfaces, " "), "(.+)", "if_err_\\1")
+ plugin {
+ $ifs: ensure => "if_";
+ $if_errs: ensure => "if_err_";
+ }
+
+
+}
+
+class munin::plugins::linux inherits munin::plugins::base {
+
+ plugin {
+ [ df_abs, forks, iostat, memory, processes, cpu, df_inode, irqstats,
+ netstat, open_files, swap, df, entropy, interrupts, load, open_inodes,
+ vmstat
+ ]:
+ ensure => present;
+ acpi:
+ ensure => $acpi_available;
+ }
+
+ include munin::plugins::interfaces
+}
+
+class munin::plugins::debian inherits munin::plugins::base {
+
+ plugin { apt_all: ensure => present; }
+
+}
+
+class munin::plugins::vserver inherits munin::plugins::base {
+
+ plugin {
+ [ netstat, processes ]:
+ ensure => present;
+ }
+
+}
diff --git a/plugins/facter/acpi_available.rb b/plugins/facter/acpi_available.rb
new file mode 100644
index 0000000..e3d8dfa
--- /dev/null
+++ b/plugins/facter/acpi_available.rb
@@ -0,0 +1,10 @@
+# return whether acpi is available -- used for deciding whether to install the munin plugin
+Facter.add("acpi_available") do
+ setcode do
+ if `acpi -t -B -A 2>/dev/null`.match(/\d/).nil?
+ "absent"
+ else
+ "present"
+ end
+ end
+end
diff --git a/plugins/facter/interfaces.rb b/plugins/facter/interfaces.rb
new file mode 100755
index 0000000..a498d64
--- /dev/null
+++ b/plugins/facter/interfaces.rb
@@ -0,0 +1,13 @@
+# return the set of active interfaces as an array
+Facter.add("interfaces") do
+ setcode do
+ `ip -o link show`.split(/\n/).collect do |line|
+ value = nil
+ matches = line.match(/^\d*: ([^:]*): <(.*,)?UP(,.*)?>/)
+ if !matches.nil?
+ value = matches[1]
+ end
+ value
+ end.compact.sort.join(" ")
+ end
+end
diff --git a/templates/defaultclient.erb b/templates/defaultclient.erb
new file mode 100644
index 0000000..954a0cb
--- /dev/null
+++ b/templates/defaultclient.erb
@@ -0,0 +1,14 @@
+<%
+ # Downcase all information
+ dom = domain.downcase
+ host = hostname.downcase
+ fhost = name.downcase
+%>
+### This syntax can be extended, it might get better ...
+#+<%= dom %>
+#-<%= host %>=<%= fhost %>:load.load
+[<%= fhost %>] # linux box
+ address <%= munin_host_real %>
+ port <%= munin_port_real %>
+ use_node_name yes
+ exim_mailstats.graph_period minute
diff --git a/templates/munin-node.conf.Debian.etch b/templates/munin-node.conf.Debian.etch
new file mode 100644
index 0000000..0673937
--- /dev/null
+++ b/templates/munin-node.conf.Debian.etch
@@ -0,0 +1,36 @@
+##########
+########## 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 <%= munin_host_real %>
+port <%= munin_port_real %>
+user root
+group root
+setsid yes
+
+# Regexps for files to ignore
+
+ignore_file ~$
+ignore_file \.bak$
+ignore_file %$
+ignore_file \.dpkg-(tmp|new|old|dist)$
+ignore_file \.rpm(save|new)$
+
+# Set this if the client doesn't report the correct hostname when
+# telnetting to localhost, port 4949
+#
+#host_name localhost.localdomain
+host_name <%= fqdn %>
+
+# A list of addresses that are allowed to connect. This must be a
+# regular expression, due to brain damage in Net::Server, which
+# doesn't understand CIDR-style network notation. You may repeat
+# the allow line as many times as you'd like
+allow <%= munin_allow %>
diff --git a/templates/munin-node.conf.Debian.sarge b/templates/munin-node.conf.Debian.sarge
new file mode 120000
index 0000000..e0646b9
--- /dev/null
+++ b/templates/munin-node.conf.Debian.sarge
@@ -0,0 +1 @@
+munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Debian.sid b/templates/munin-node.conf.Debian.sid
new file mode 120000
index 0000000..e0646b9
--- /dev/null
+++ b/templates/munin-node.conf.Debian.sid
@@ -0,0 +1 @@
+munin-node.conf.Debian.etch \ No newline at end of file
diff --git a/templates/munin-node.conf.Gentoo b/templates/munin-node.conf.Gentoo
new file mode 100644
index 0000000..f10349e
--- /dev/null
+++ b/templates/munin-node.conf.Gentoo
@@ -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 <%= munin_host_real %>
+port <%= munin_port_real %>
+user root
+group root
+setsid yes
+
+# Regexps for files to ignore
+
+ignore_file ~$
+ignore_file \.bak$
+ignore_file %$
+ignore_file \.dpkg-(tmp|new|old|dist)$
+ignore_file \.rpm(save|new)$
+
+# Set this if the client doesn't report the correct hostname when
+# telnetting to localhost, port 4949
+#
+#host_name localhost.localdomain
+host_name <%= fqdn %>
+
+# A list of addresses that are allowed to connect. This must be a
+# regular expression, due to brain damage in Net::Server, which
+# doesn't understand CIDR-style network notation. You may repeat
+# the allow line as many times as you'd like
+allow ^127\.0\.0\.1$
+allow <%= munin_allow1 %>
+allow <%= munin_allow2 %>
+
diff --git a/templates/munin-node.conf.Gentoo. b/templates/munin-node.conf.Gentoo.
new file mode 120000
index 0000000..fd16e50
--- /dev/null
+++ b/templates/munin-node.conf.Gentoo.
@@ -0,0 +1 @@
+munin-node.conf.Gentoo \ No newline at end of file