Munin Installation on FAMP ( FreeBSD 8.2, Apache 2.2, MySQL 5.0.92, PHP 5.3.6 )

Munin - is a simple RRDTool-based networked resource monitoring tool.
Munin plugins - http://exchange.munin-monitoring.org/

Munin consists of a server that collect data (Munin-Master) and nodes which are monitored (Munin-Node)

Best Current Practices for good plugin graphs http://munin-monitoring.org/wiki/plugin-bcp


1) Munin-Master
a) install
cd /usr/ports/sysutils/munin-master
make install clean
b) Configure
Crontab
*/5 * * * * munin /usr/local/bin/munin-cron
Rights
# chown -R munin:munin /usr/local/www/munin

c) Add Node to Master
# mcedit /usr/local/etc/munin/munin.conf
# a simple host tree
[testip.example.com]
    address 9.9.9.8
    use_node_name yes   
d) Start Munin-Node
#/usr/local/etc/rc.d/munin-node restart   

e) Additional Information
Master-exec - /usr/local/share/munin
Logs - /var/log/munin-main
RRDs - /usr/local/var/munin
ETCs - /usr/local/etc/munin
WWW - /usr/local/www/munin 

Manual Munin Polling Execution
su -m munin /usr/local/bin/munin-cron


2) Munin-Node Config File
# cd /usr/ports/sysutils/munin-node/
# make install clean
....
Starting munin_node.
Pid_file "/var/run/munin/munin-node.pid" already exists.  Overwriting!
Would you like me to set up log rotation [y]?
********************************************************************
Unless this file already existed, a sample configuration file
has been placed in /usr/local/etc/munin/munin-node.conf.
Please edit it according to your needs.
********************************************************************
The Munin client will *not* be started automatically. To allow it
to start, put this line in /etc/rc.conf:

munin_node_enable="YES"

Then, it will be started on the next boot. If this line is already
present, the client will be started now.  Otherwise, edit
/etc/rc.conf and execute this command:

    /usr/local/etc/rc.d/munin-node start
********************************************************************
===>  Cleaning for munin-node-1.4.6
# echo 'munin_node_enable="YES"' >> /etc/rc.conf
# munin-node-configure --suggest
# mcedit /usr/local/etc/munin/munin-node.conf
host_name ns2.v6
# A list of addresses that are allowed to connect.  (munin-master IP)
allow ^172\.17\.10\.1$
Start Munin-Node if not started
# /usr/local/etc/rc.d/munin-node restart
munin_node not running? (check /var/run/munin/munin-node.pid).
Starting munin_node.
#
 Check Munin-Node status and configuration
# telnet localhost 4949
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
# munin node at munin-node1.mydomain.local
fetch cpu
user.value 2218490427
nice.value 70883135
system.value 761809361
interrupt.value 94500030
idle.value 8906705207
.
quit
Connection closed by foreign host.
3) Plugins configuration
Create symlinks from /usr/local/share/munin/plugins/  to  /usr/local/etc/munin/plugins
...
ln -s  /usr/local/share/munin/plugins/if_  /zzz/munin/etc/plugins/if_fxp0
ln -s  /usr/local/share/munin/plugins/if_  /zzz/munin/etc/plugins/if_fxp1
...

a) APACHE
# mcedit /usr/local/etc/apache22/httpd.conf

SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 9.9.9

# apachectl graceful

# ./apache_accesses
LWP::UserAgent not found at ./apache_accesses line 86.

# cpan
cpan[1]> install LWP::UserAgent

b) MYSQL
CREATE USER 'mysqlmunin'@'localhost' IDENTIFIED BY 'mun1npa55';

GRANT USAGE ON * . * TO ' mysqlmunin '@'localhost' IDENTIFIED BY '
mun1npa55' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

# ./mysql_
Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib/perl5/5.10.1/BSDPAN
# cpan
install DBI
install DBI:mysql
install CPAN::DistnameInfo
install IPC::ShareLite
/usr/local/etc/munin/plugin-conf.d/plugins.conf
[mysql*]
user root
group wheel
env.mysqladmin /usr/local/bin/mysqladmin
env.mysqlshow /usr/local/bin/mysqlshow
env.mysqlopts -u  mysqlmunin -pmun1npa55

c) mcedit /usr/local/etc/munin/plugin-conf.d/plugins.conf
[apache_*]
env.url   http://127.0.0.1:%d/server-status?auto
env.ports 80
[mysql*]
user root
group wheel
env.mysqlopts -umysqlmonitor -ps5e6etre5EvA

d) VMSTAT customization
Exclude sleep from monitoring (for me only diskstate and running processes are essential)
/^Processes:/ {
        print "running.value", $3;
        print "diskwait.value", $6;
        print "pagewait.value", $9;
        print "sleep.value", 0;
e) WEATHER
Download https://github.com/munin-monitoring/contrib/blob/master/plugins/other/weather_
Create symlink 'weather_CODE' to /munin/etc/plugins
ex: For London, UK is http://www.weather.com/weather/today/London+United+Kingdom+UKXX0085
 ./weather_UKXX0085
temperature.value 2
humidity.value 8.2

4) Problems
Sometime when system is unavaible or busy, RRD writes values that are not so real and 'spikes' are formed.


To remove spikes,
download http://oss.oetiker.ch/rrdtool/pub/contrib/removespikes-20080226-mkn.tar.gz
./removespikes.pl -d -a [-l number] [-t maxval] name_of_database

This graph shows the traffic of the eth0 network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: On 32 bit systems the data source for this plugin uses 32bit counters, which makes the plugin unreliable and unsuitable for most 100Mb (or faster) interfaces, where traffic is expected to exceed 50Mbps over a 5 minute period. This means that this plugin is unsuitable for most 32 bit production environments. To avoid this problem, use the ip_ plugin instead. There should be no problems on 64 bit systems running 64 bit kernels.

5) Read system stats based on munin stored information:




1 comment :