Installing Munin on CentOS
Munin is a tool for monitoring network devices with the ability to keep a history of their performance. You can view the performance graphs in a browser.
With Munin you can keep track of servers, applications, the weather in Siberia, or whatever else comes to mind. Based on the performance graphs you can pinpoint the moment something went wrong with a server (for example, memory usage went up)
To install it, enable the Epel repository:
5.4:
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
6.8:
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Installing the agent/client:
yum install munin-node
Installing the server:
yum install munin
Client-side settings
The config lives in the /etc/munin/munin.conf file.
You can change the default location of directories and files using the following directives in the file:
dbdir /var/lib/munin
htmldir /var/www/html/munin
logdir /var/log/munin
rundir /var/run/munin
Right after install only localhost will be available on the server. To add more servers, find the following lines:
# a simple host tree
[localhost]
address 127.0.0.1
use_node_name yes
Add the servers you need using the following template:
[server_name]
address 12.34.56.78
use_node_name yes
Keep in mind that if you changed the htmldir value in the /etc/munin/munin.conf file, you need to create that folder yourself and copy all the files from /var/www/html/munin into it
After that you need to edit the Apache settings file (/etc/httpd/conf.d/munin.conf)
Alias /munin /**path_to_htmldir**/munin
The directory tags need to be edited accordingly.
Next, generate a password for authentication on the munin page:
htpasswd -cmb /etc/munin/munin-htpasswd munin_user munin_password
Client-side settings
lives in the /etc/munin/munin-node.conf file.
We’re interested in the lines that control which ip addresses can connect to the agent. Right after install, only 127.0.0.1 is allowed to connect.
allow ^127\.0\.0\.1$
I think it’s obvious that you need to add here the ip address of the server running the munin daemon, to let it collect data.
Set munin to start on boot
chkconfig -add munin-node
Start it
/etc/init.d/munin-node start
By default munin polls all servers once every 5 minutes. So the step on all graphs will be 5 minutes. To get more precise info you need to edit the following file:
/etc/cron.d/munin
And change 5 minutes to 1.
In the browser open http://<strong>ip_address_of_your_server</strong>/munin/
Monitoring MySQL:
Need to edit the plugin and put in it the username and password for mysql access:
vim /usr/share/munin/plugins/mysql_
From there it’s straightforward - next to mysqlpassword put the admin password. Change the username if needed.
All that’s left is to enable the plugin:
cd /etc/munin/plugins
ln -sf /usr/share/munin/plugins/mysql_ mysql_
The following command outputs the list of graphs you can get with the plugin:
/usr/share/munin/plugins/mysql_ suggest
To enable all the suggested plugins run:
for i in \`./mysql_ suggest\`; do ln -sf /usr/share/munin/plugins/mysql_ $i; done
To apply the changes restart the daemon:
service munin-node restart
Resetting the data:
Sometimes you have to remove one of the servers, but its graphs stick around. Or you find out something’s configured wrong and want to wipe everything in munin and start fresh.
Munin keeps its data in two folders. Those are the ones you need to clear out:
rm -rf /var/www/html/munin/*
rm -rf /var/lib/munin/*
Next you need to manually run munin-cron
su - munin -shell=/bin/bash
/usr/bin/munin-cron
Enabling Apache2 monitoring:
First, let’s make sure status_module is installed and enabled in the Apache2 config:
apachectl -t -D DUMP_MODULES 2>&1|grep status_module
If everything’s OK - create the config file
nano /etc/httpd/conf.d/status.conf
With the following content:
<IfModule mod_status.c>
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost ip6-localhost
Allow from 127.0.0.1
Allow from 192.168.100.0/24
</Location>
</IfModule>
Enable the munin plugins:
sudo ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/apache_processes
sudo ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/apache_accesses
sudo ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/apache_volume

