How to install Munin on CentOS 6 and RedHat Enterprise 6
This guide will go over a basic installation of Munin on a CentOS 6.x or RedHat Enterprise 6.x server.
Per Munin’s site “Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems. It is designed to be very plug and play. A default installation provides a lot of graphs with almost no work.”
I personally deploy it on my own Linux systems for resource monitoring. Let’s jump into the installation:
1. The first step is to install the RedHat EPEL rpm which adds the EPEL repo:
# rpm -ivh http://download.fedora.redhat.com/pub/epel/6/ppc64/epel-release-6-5.noarch.rpm
2. Next, you’ll need to install the required packages via yum:
# yum install -y munin munin-node
3. Once installed, we need to configure the munin-node via the /etc/munin/munin-node.conf and alter the following values:
user root group root
For security reason, I like to change this to a less risky user such as apache I.e.:
user apache group apache
You can also alter the listening address and port that the service runs on:
# Which address to bind to; host * # host 127.0.0.1 # And which port port 4949
I generally leave this setting alone as my servers run behind a firewall that blocks external access to the port. If you are exposed to the internet (I’d at least run iptables) then I’d change the bind address value to 127.0.0.1
4. Now that the node is configured, the next step is to adjust the following values in /etc/munin/munin.conf:
# dbdir /var/lib/munin # htmldir /var/www/html/munin # logdir /var/log/munin # rundir /var/run/munin
You can simply uncomment these values and adjust the htmldir accordingly dpending on where you would like the files to be generated.
Example is below:
dbdir /var/lib/munin htmldir /var/www/vhosts/somedomain/htdocs logdir /var/log/munin rundir /var/run/munin
The host tree should be adjusted as well:
# a simple host tree [enter.yourservernamehere] address 127.0.0.1 use_node_name yes
You can set a custom name for your server where indicated above.
5. Once the munin.conf has been updated, next you’ll need to adjust the permissions on the html directory. In the example above I set my html directory to /var/www/vhosts/somedomain/htdocs so to allow munin to write to it I’ll change ownership to the correct user:
chown munin:munin /var/www/vhosts/somedomain/htdocs
6. Now you can start the munin daemon with the following command:
# /etc/init.d/munin-node start
Once done you can verify the service with ps and netstat:
#ps aux | grep munin apache 17835 0.2 0.8 141140 8480 ? Ss 07:51 0:00 /usr/sbin/munin-node root 18186 0.0 0.0 103220 844 pts/0 S+ 07:52 0:00 grep munin # netstat -anp | grep munin-node tcp 0 0 0.0.0.0:4949 0.0.0.0:* LISTEN 17835/munin-node
In the example above, you can see that the daemon process is running and that it is listening on tcp port 4949.
7. Now we’ll need to use chkconfig to have the service load on startup:
# chkconfig munin-node on # chkconfig --list | grep munin munin-node 0:off 1:off 2:on 3:on 4:on 5:on 6:off
That covers the basic installation process and you should be up and running. If you set the html directory to a existing website, you can access it there.
In my case, I setup a dedicated subdomain for my installation and set the html directory to the document root and setup http basic auth to prevent someone from snooping.
I’ll share my nginx configuration for those who use it:
server {
listen 80;
server_name munin.somedomain.com;
access_log /var/www/vhosts/munin.somedomain.com/logs/access.log;
error_log /var/www/vhosts/munin.somedomain.com/logs/error.log;
rewrite_log on;
root /var/www/vhosts/munin.somedomain.com/htdocs;
index index.php index.html index.htm;
location / {
auth_basic "Restricted";
auth_basic_user_file /var/www/vhosts/munin.somedomain.com/auth/.htpasswd;
}
# Enable FastCGI on unix:/tmp/php-fpm.sock
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Deny hidden file types
location ~ /(\.ht|\.git|\.svn) {
deny all;
}
}If you have any questions feel free to comment – Dustin

