Server Monitoring With munin And monit On CentOS 5.2

This tutorial exists for these OS versions

    On this page

    1. 1 Preliminary Note
    2. 2 Enable The RPMforge Repository
    3. Output Directory (Optional)

    In this article I will describe how you can monitor your CentOS 5.2 server with munin and monit. munin produces nifty little graphics about nearly every aspect of your server (load average, memory usage, CPU usage, MySQL throughput, eth0 traffic, etc.) without much configuration, whereas monit checks the availability of services like Apache, MySQL, Postfix and takes the appropriate action such as a restart if it finds a service is not behaving as expected. The combination of the two gives you full monitoring: graphics that lets you recognize current or upcoming problems (like "We need a bigger server soon, our load average is increasing rapidly."), and a watchdog that ensures the availability of the monitored services.

    Although munin lets you monitor more than one server, we will only discuss the monitoring of the system where it is installed here.

    This tutorial was written for CentOS 5.2, but the configuration should apply to other distributions with little changes as well.

    I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!


    1 Preliminary Note

    Our system's hostname is, and we have a web site on it with the document root /var/www/


    2 Enable The RPMforge Repository

    On CentOS 5.2, munin and monit are not available in the default CentOS repositories. Fortunately we can install them from the RPMforge repository. To enable the RPMforge repository, we run

    rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

    rm -f rpmforge-release-0.3.6-1.el5.rf.i386.rpm

    on i386 hosts and

    rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

    rm -f rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

    on x86_64 hosts (please check out for the latest versions).


    3 Install And Configure munin

    To install munin on CentOS 5.2, we do this:

    yum install munin munin-node

    Then we create the system startup links for munin and start it:

    chkconfig --levels 235 munin-node on
    /etc/init.d/munin-node start

    Next, we must edit the munin configuration file /etc/munin/munin.conf. We want munin to put its output into the directory /var/www/, therefore we change the value of htmldir, and we want it to use the name instead of localhost.localdomain in the HTML output, therefore we replace localhost.localdomain with Without the comments, the changed file looks like this:

    vi /etc/munin/munin.conf

    dbdir   /var/lib/munin
    htmldir /var/www/
    logdir  /var/log/munin
    rundir  /var/run/munin
    # Where to look for the HTML templates
    tmpldir /etc/munin/templates
    # a simple host tree
        use_node_name yes

    Next we create the directory /var/www/ and change its ownership to the user and group munin, otherwise munin cannot place its output in that directory. Then we restart munin:

    mkdir -p /var/www/
    chown munin:munin /var/www/
    /etc/init.d/munin-node restart

    Now wait a few minutes so that munin can produce its first output, and then go to in your browser, and you see the first statistics. After a few days this could look like this:

    (This is just a small excerpt of the many graphics that munin produces...)


    4 Password-Protect The munin Output Directory (Optional)

    Now it is a good idea to password-protect the directory /var/www/ unless you want everybody to be able to see every little statistic about your server.

    To do this, we create an .htaccess file in /var/www/

    vi /var/www/

    AuthType Basic
    AuthName "Members Only"
    AuthUserFile /var/www/
    <limit GET PUT POST>
    require valid-user

    Then we must create the password file /var/www/ We want to log in with the username admin, so we do this:

    htpasswd -c /var/www/ admin

    Enter a password for admin, and you're done!

    Share this page:

    10 Comment(s)

    Add comment


    From: Matthew

    Latest packages of munin place html to /var/www/html/munin

    nano /etc/httpd/conf.d/munin.conf    and paste the following (change *  to the ip of your pc)

     Alias /monitoring /var/www/html/munin

    <Location /usage>
        Order deny,allow
        Deny from all
        Allow from
        Allow from *.*.*.*


     +After restart Apache deamon

    service httpd restart

    From: Anonymous

    These steps are not solving problem with the munin install on centos. I tried and go through each step but same result. Its giving me the same error as mention aboved. So it means these steps are not worth it. Dont follow these steps.

    From: Anonymous

    I don't mean to be rude, but if you can't figure this out I don't know if you will have any luck using the stats this produces.

     Let's pretend you have a Vhost in apache called with a docroot of /www/

     Ok... all you do is create a directory called /www/

    Change ownership and group to munin or just do chmod 777 monitoring

     Munin will put html/image files inside whatever directory you tell it to in the config, and you access it by putting in the web address to that directory (in this case

     Bottom line, create a new directory inside of a website you already have setup and running, then set the munin conf to use that directory, then access the stats by accessing that website/directory.

    From: tracepath

    I followed all steps but i have i problem. The output folder is /var/www/html/egw/web/monitoring and when i put "" is empty. No charts.

     What can i do ?


    From: jindowin

    can u help me clearly?

    i get error the same..but i dont know where i have to "include /html"

    From: jindowin

    i get error when i type to my browser:

    Not Found

    The requested URL /monitoring/ was not found on this server.

    Apache/2.2.3 (CentOS) Server at Port 80
    can u help me? do i need install apache before install munin?


    From: Anonymous

    By changing the ownership to munin you are unable to see the content. Also you need to include /html

    From: Haider



    I'd installed munin monitoring tool in centos 5.2

    I'd completed all the step, but when i open my web browser and try to access 

    i get error 

    NOT Found

    The Request URL/ monitoring/ was not found on this server

    Can u please help me out 


    From: royalcharlie

    Followed instructions and encountered a problem that just got solved due to comments from an anonymous. Many thanks to you!

    Am using centos 5.5 64-bit.
    and only changed htmldir to /var/www/html/munin

    Waited for a while and checked via browser only to get a link to localhost and that's it. Nothing else is displayed. Checked the logs and the munin directory itself and there are files being created. Tried rebooting but no effect.

    Read through the steps again and this time including the comments and read about editing /etc/httpd/conf.d/munin.conf and noticed that the alias is pointing to /var/www/munin rather than /var/www/html/munin.

    After changing this and restarting apache daemon... the munin site is working. Cheers.

    From: ahmet

    This is my working way if you have more then one web site
    Centos 6.0

    vim /etc/munin/munin.conf

     dbdir  /var/lib/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

    # (Exactly one) directory to include all files from.
    includedir /etc/munin/munin-conf.d

    # a simple host tree
    #    address
    #    use_node_name yes

        use_node_name yes

    vim /etc/httpd/conf/httpd.conf

    DocumentRoot "/var/www/html/munin"
    <Directory "/var/www/html/munin">
    allow from all
    Options +Indexes