Server Monitoring With munin And monit On Fedora 7

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Mon, 2007-10-15 16:45. :: Fedora | Monitoring

Server Monitoring With munin And monit On Fedora 7

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 10/04/2007

In this article I will describe how you can monitor your Fedora 7 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 Fedora 7, 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 server1.example.com, and we have a web site www.example.com on it with the document root /var/www/www.example.com/web.

 

2 Install And Configure munin

To install munin on Fedora 7, 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/www.example.com/web/monitoring, therefore we change the value of htmldir, and we want it to use the name server1.example.com instead of localhost.localdomain in the HTML output, therefore we replace localhost.localdomain with server1.example.com. Without the comments, the changed file looks like this:

vi /etc/munin/munin.conf

[...]
dbdir   /var/lib/munin
htmldir /var/www/www.example.com/web/monitoring
logdir  /var/log/munin
rundir  /var/run/munin

# Where to look for the HTML templates
tmpldir /etc/munin/templates
[...]
# a simple host tree
[server1.example.com]
    address 127.0.0.1
    use_node_name yes
[...]

Next we create the directory /var/www/www.example.com/web/monitoring 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/www.example.com/web/monitoring
chown munin:munin /var/www/www.example.com/web/monitoring
/etc/init.d/munin-node restart

Now wait a few minutes so that munin can produce its first output, and then go to http://www.example.com/monitoring/ 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...)

 

3 Password-Protect The munin Output Directory (Optional)

Now it is a good idea to password-protect the directory /var/www/www.example.com/web/monitoring 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/www.example.com/web/monitoring:

vi /var/www/www.example.com/web/monitoring/.htaccess

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

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

htpasswd -c /var/www/www.example.com/.htpasswd admin

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Martin (not registered) on Sat, 2008-12-06 14:33.

Installed properly based on the tutorial, but no graphs are generated, CRON keeps sending the message bellow.

OS:  Fedora release 8 (Werewolf), Linux 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 i686 i386 GNU/Linux

A have found an article describing the bug but it wasn't related to my subject.

Any clue?

From munin@  Sat Dec  6 14:20:11 2008
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <munin@atlantis> test -x /usr/bin/munin-cron && /usr/bin/munin-cron
Date: Sat,  6 Dec 2008 14:20:01 0100 (CET)
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/var/lib/munin>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=munin>
X-Cron-Env: <USER=munin>


(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;

(process:25245): Pango-WARNING **: pango_layout_set_markup_with_accel: Error on line 1: Character ' ' is not valid a
t the start of an entity name; the & character begins an entity; if this ampersand isn't supposed to be an entity, e
scape it as &amp;
cp: accessing `/home/virtualhosts/munin/': Permission denied
cp: accessing `/home/virtualhosts/munin/': Permission denied
cp: accessing `/home/virtualhosts/munin/': Permission denied
Cannot open /home/virtualhosts/munin/localhost/localhost-cpu.html at /usr/share/munin/munin-h
tml line 488.

Submitted by JayJay (not registered) on Sun, 2010-03-07 13:12.

http://munin.projects.linpro.no/ticket/537

 This error is caused by an invalid character and is an easy fix. Browse to /usr/share/munin/plugins/interrupts and replace the two & with &amp