Munin

From Segfault
Jump to navigation Jump to search

Installation

Packages

The package "munin" needs to be installed on the "server", the machine that is collecting the data from all the client machines where "munin-node" is installed:

apt-get install munin munin-node              # Debian, Ubuntu
    yum install munin munin-node              # Fedora
   port install munin                         # MacOS

Note: For Munin to work on MacOS, we need to create a user (and a group):

sudo dscl . create /Groups/munin PrimaryGroupId 4949
sudo dscl . create /Users/munin UniqueId 4949
sudo dscl . create /Users/munin PrimaryGroupId 4949
sudo dscl . create /Users/munin UserShell /bin/false
sudo dscl . create /Users/munin NFSHomeDirectory /nohome
sudo dscl . create /Users/munin RealName Munin
sudo dscl . create /Groups/munin GroupMembership munin

Source

The following prerequisites should be installed before building Munin:

apt-get install librrds-perl libhtml-template-perl liblog-log4perl-perl \
                libnet-ssleay-perl libnet-snmp-perl libnet-server-perl

Install a munin user:

useradd -d /var/lib/munin -m -r -s /bin/false -U munin
git clone git://github.com/munin-monitoring/munin.git munin-git
cd munin-git

Edit Makefile.config, e.g. like this:

PREFIX     = $(DESTDIR)/opt/munin
CONFDIR    = $(PREFIX)/etc
DBDIR      = $(PREFIX)/var/lib
STATEDIR   = $(PREFIX)/var/run
PERLLIB    = $(PREFIX)$(PERLSITELIB)

Build & install:

make
sudo make install

Configuration

munin.conf

This configuration file is really minimal and only holds something like this:

graph_period minute
# contact.email.command mail -s "Munin: ${var:host}" admin@example.com
# contact.email.always_send warning critical
includedir /etc/munin/munin-conf.d

munin-conf.d/node-foo.conf

A configuration file for each host:

[node-foo.example.com]
       address 10.0.0.12
       port 4949
       use_node_name yes
       load.load.warning  15
       load.load.critical 20

munin-node.conf

Each client should have a configuration similar to this:

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 root

# Files to ignore when locating plugins.
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$

# Override local hostname, usually not needed
# host_name node-foo.example.com

# Regular expression of hosts that may query the munin-node process
# May be replaced by cidr_allow which is much more readable.
allow ^127\.0\.0\.1$
allow ^10\.0\.0\.2$
cidr_allow 10.2.0.0/24

# Address to bind to
host 10.0.0.33
port 4949

plugins/

The active plugins are being linked in /etc/munin/plugins:

$ pwd
/etc/munin/plugins

$ ls -lgo
lrwxrwxrwx. 1 28 Jul  4 02:42 cpu -> /usr/share/munin/plugins/cpu
lrwxrwxrwx. 1 27 Jul  4 02:42 df -> /usr/share/munin/plugins/df
lrwxrwxrwx. 1 28 Jul  4 02:42 if_eth0 -> /usr/share/munin/plugins/if_
lrwxrwxrwx. 1 43 Jul  4 02:42 du_multidirs -> /usr/local/share/munin/plugins/du_multidirs
lrwxrwxrwx. 1 35 Jul  4 02:42 interrupts -> /usr/share/munin/plugins/interrupts
lrwxrwxrwx. 1 31 Jul  4 02:42 iostat -> /usr/share/munin/plugins/iostat
lrwxrwxrwx. 1 33 Jul  4 02:42 irqstats -> /usr/share/munin/plugins/irqstats
lrwxrwxrwx. 1 29 Jul  4 02:42 load -> /usr/share/munin/plugins/load
lrwxrwxrwx. 1 31 Jul  4 02:42 memory -> /usr/share/munin/plugins/memory
lrwxrwxrwx. 1 40 Jul  4 02:42 multiping -> /usr/local/share/munin/plugins/multiping
lrwxrwxrwx. 1 32 Jul  4 02:42 multips -> /usr/share/munin/plugins/multips
lrwxrwxrwx. 1 38 Jul  4 02:42 mysql_queries -> /usr/share/munin/plugins/mysql_queries
lrwxrwxrwx. 1 32 Jul  4 02:42 netstat -> /usr/share/munin/plugins/netstat
lrwxrwxrwx. 1 42 Jul  4 02:42 postfix_mailqueue -> /usr/share/munin/plugins/postfix_mailqueue
lrwxrwxrwx. 1 42 Jul  4 02:42 postfix_mailstats -> /usr/share/munin/plugins/postfix_mailstats
lrwxrwxrwx. 1 43 Jul  4 02:42 postfix_mailvolume -> /usr/share/munin/plugins/postfix_mailvolume
lrwxrwxrwx. 1 34 Jul  4 02:42 processes -> /usr/share/munin/plugins/processes
lrwxrwxrwx. 1 31 Jul  4 02:42 vmstat -> /usr/share/munin/plugins/vmstat

plugin-conf.d/

Some plugins might require some configuration directives:

$ cat munin-node
[df*]
env.exclude none unknown iso9660 squashfs udf romfs ramfs debugfs tmpfs
env.warning  92
env.critical 98

[smart_*]
user root

[...]

Usage

Usually the server will query all the client nodes via a cronjob:

$ cat /etc/cron.d/munin
*/5 * * * *  munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi

Each plugin can be queried manually as well:

$ sudo -u munin munin-run load
load.value 0.66

Or, via direct interaction with munin-node:

$ echo fetch if_eth0 | nc node-foo 4949
# munin node at node-foo.example.org
down.value 1897882515
up.value 129492565

When munin-node cannot be started as a daemon, we can emulate inetd behaviour:

while [ ! -f /tmp/no_munin ]; do nc -e /bin/munin-node -l -p 4949; done

Links