De Help Desk punt NL
Kennisbank
De Helpdesk > De Helpdesk > Kennisbank

Server Monitoren met Munin en Monit op Fedora 12

Oplossing Installatie en Configuratie van munin

Om munin te installeren op Fedora 12 gebruiken we de volgende opdrachtregel: (alles wat achter de hekjes staat zijn opdrachtregels die je op de prompt moet uitvoeren)

# yum -y install munin munin-node

Vervolgens passen we de configuratiefile aan naar onze wensen.

# vi /etc/munin/munin.conf

En we halen de hekjes web bij de volgende regels:

dbdir /var/lib/munin
htmldir /var/www/html/munin (let op pas dit aan voor het juiste path)
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

En we slaan de config op.

Nu moeten we de opstart links maken:

# chkconfig --levels 235 munin-node on

En we starten munin:

# /etc/init.d/munin-node start

Deze map (/var/www/html/munin) moeten we aanmaken en ook de juiste rechten geven:

# mkdir -p /var/www/html/munin
# chown munin:munin /var/www/html/munin

En we herstarten munin.

# /etc/init.d/munin-node restart

Nu moeten we nog een gebruiker toevoegen om de pagina te mogen bekijken en de map te berschermen:

# vi /var/www/html/munin/.htaccess

En we zorgen dat daar hetvolgende in staat:

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

Sla dit op en dan maken we een gebruiker aan:
# htpasswd -c /var/www/html/.htpasswd admin
Geef een wachtwoord op voor admin en je bent klaar.

Na een paar minuten kun je op de pagina (http:www.jouwdomein.nl/munin) gaan kijken en moeten we de eerste resultaten zien.


Nu gaan we monit installeren:

# yum -y install monit

En we maken een opstartlink:

# chkconfig --levels 235 monit on

De standaard-configuratie staat in /etc/monit.conf en hier staan een hoop voorbeelden in, meer voorbeelden vindt je op: http://mmonit.com/wiki/Monit/ConfigurationExamples of op: /etc/monit.conf (of je kan mijn voorbeeld downloaden op: http://colani.nl/helpdesk/upload/monit/monit.conf )
Het minste wat we moeten doen is:
Haal het hekje weg voor:
set httpd port 2812
set deamon 60

Nu maken we nog het volgende bestand aan: (of je kan mijn voorbeeld downloaden op: http://colani.nl/helpdesk/upload/monit/monit )

# vi /etc/default/monit

Met de volgende inhoudt:
# Defaults for monit initscript
# sourced by /etc/init.d/monit
# installed at /etc/default/monit by maintainer scripts
# Terry van Erp <colani@live.nl>

# You must set this variable to for monit to start
startup=1

# To change the intervals which monit should run uncomment
# and change this variable.
CHECK_INTERVALS=60
En dit slaan we op.

Om te testen of de config klopt:
# monit -t


En we starten monit:
# /etc/init.d/monit start

Volgende stap is het aanpassen van onze /etc/httpd/httpd.conf, hier maken we gebruik van mod_status, die normaal gesproken meegecompuleerd met apache. Dus voegen we de volgende regels toe bijvoorbeeld bij een van de virtuele hosts:

# vi /etc/httpd/httpd.conf

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
En we zijn klaar.

Apache herstarten:
# service httpd restart

Serverstaus testen:
# http://www.uwdomein.nl/server-status?auto

De info die we krijgen te zien hangt af van de belasting van de server, maar als we hier een paar regels zien is het oke, hier haald monit zijn info vandaan.

Deze howto komt natuurlijk weer zonder enige garantie, wij zijn niet aansprakelijk voor wat voor schade dan ook die ontstaan is door het gebruik van deze handleiding ;-)
Vragen? Je weet me te vinden.
Suc6

Hier nog een stukje voorbeeld config.

# Amavis
#check process amavisd with pidfile /var/run/amavis/amavisd.pid
# group mail
# start program = "/etc/init.d/amavis start"
# stop program = "/etc/init.d/amavis stop"
# if failed port 10024 protocol smtp then restart
# if 5 restarts within 5 cycles then timeout

check process amavisd with pidfile /var/run/amavis/amavisd.pid
group mail
start program = "/etc/init.d/amavis start"
stop program = "/etc/init.d/amavis stop"
if failed port 10024 protocol smtp then restart
if 5 restarts within 5 cycles then timeout
depends on amavisd_bin
depends on amavisd_rc

check file amavisd_bin with path /usr/sbin/amavisd-new
group mail
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

check file amavisd_rc with path /etc/init.d/amavis
group mail
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

# Apache2
check process apache with pidfile /var/run/apache2.pid
group www
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if failed port 80 protocol http then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 1500 MB for 5 cycles then restart
if children > 512 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout

# Clamd
check process clamd with pidfile /var/run/clamav/clamd.pid
group virus
start program = "/etc/init.d/clamav-daemon start"
stop program = "/etc/init.d/clamav-daemon stop"
if failed unixsocket /var/run/clamav/clamd.ctl then restart
if 5 restarts within 5 cycles then timeout
depends on clamavd_bin
depends on clamavd_rc

check file clamavd_bin with path /usr/sbin/clamd
group virus
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

check file clamavd_rc with path /etc/init.d/clamav-daemon
group virus
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

# Courier_authdaemon
check process authdaemon with pidfile /var/run/courier/authdaemon/pid
group services
start program = "/etc/init.d/courier-authdaemon start"
stop program = "/etc/init.d/courier-authdaemon stop"
if 5 restarts within 5 cycles then timeout

# Cron
check process cron with pidfile /var/run/crond.pid
start program = "/etc/init.d/cron start"
stop program = "/etc/init.d/cron stop"
group system
depends cron_init, cron_bin

check file cron_init with path /etc/init.d/cron
group system

check file cron_bin with path /usr/sbin/cron
group system

# fail2ban
check process fail2ban with pidfile /var/run/fail2ban/fail2ban.pid
group services
start program = "/etc/init.d/fail2ban start"
stop program = "/etc/init.d/fail2ban stop"
if 5 restarts within 5 cycles then timeout

# Courier_imapd
check process imap with pidfile /var/run/courier/imapd.pid
group mail
start program = "/etc/init.d/courier-imap start"
stop program = "/etc/init.d/courier-imap stop"
if failed port 143 then restart
if 5 restarts within 5 cycles then timeout

# Courier_immapd-ssl
check process imapd-ssl with pidfile /var/run/courier/imapd-ssl.pid
group mail
start program = "/etc/init.d/courier-imap-ssl start"
stop program = "/etc/init.d/courier-imap-ssl stop"
if failed port 143 then restart
if 5 restarts within 5 cycles then timeout

# Munin-node
check process munin-node with pidfile /var/run/munin/munin-node.pid
group services
start program = "/etc/init.d/munin-node start"
stop program = "/etc/init.d/munin-node stop"
if 5 restarts within 5 cycles then timeout

#MyDNS
check process named with pidfile /var/run/mydns.pid
start program = "/etc/init.d/mydns start"
stop program = "/etc/init.d/mydns stop"
if failed host 127.0.0.1 port 53 then alert
if 5 restarts within 5 cycles then timeout

# MySQL
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host 127.0.0.1 port 3306 protocol mysql then restart
if 5 restarts within 5 cycles then timeout

# Courier_pop3d
check process pop3 with pidfile /var/run/courier/pop3d.pid
group mail
start program = "/etc/init.d/courier-pop start"
stop program = "/etc/init.d/courier-pop stop"
if failed port 110 then restart
if 5 restarts within 5 cycles then timeout

# Courier_pop3-ssl
check process pop3-ssl with pidfile /var/run/courier/pop3d-ssl.pid
group mail
start program = "/etc/init.d/courier-pop-ssl start"
stop program = "/etc/init.d/courier-pop-ssl stop"
if failed port 995 then restart
if 5 restarts within 5 cycles then timeout

#postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if failed port 25 protocol smtp then restart
if 5 restarts within 5 cycles then timeout
depends on postfix_rc

check file postfix_rc with path /etc/init.d/postfix
group mail
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

#PureFTPd
check process pure-ftpd with pidfile /var/run/pure-ftpd/pure-ftpd.pid
start program "/etc/init.d/pure-ftpd-mysql start"
stop program "/etc/init.d/pure-ftpd-mysql stop"
if failed host 127.0.0.1 port 21 then restart
if 5 restarts within 5 cycles then timeout

# SSHd
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
#if failed port 22 protocol ssh then restart
if failed port 22 then restart
if 5 restarts within 5 cycles then timeout

# Spamassassin
check process spamd with pidfile /var/run/spamd.pid
group mail
start program = "/etc/init.d/spamassassin start"
stop program = "/etc/init.d/spamassassin stop"
if 5 restarts within 5 cycles then timeout
if cpu usage > 99% for 5 cycles then alert
if mem usage > 99% for 5 cycles then alert

check file spamd_bin with path /usr/sbin/spamd
group mail
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

check file spamd_rc with path /etc/init.d/spamassassin
group mail
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor

# Rsyslogd
check process syslogd with pidfile /var/run/rsyslogd.pid
start program = "/etc/init.d/rsyslog start"
stop program = "/etc/init.d/rsyslog stop"
if 5 restarts within 5 cycles then timeout
check file syslogd_file with path /var/log/syslog
 
Was dit artikel bruikbaar? ja / nee
Gerelateerde artikelen Wachtwoord herstel MySQL root wachtwoord
Linux: Logitech G15 with Ubuntu 9.04 Jaunty
Nagios installeren op CentOS 7
Nagios installeren op Fedora 12
Wachtwoord MariaDB en Mysql herstellen
Disable SSH root access
PureFTPD installeren Fedora 11
Scan CentOS for Malware, Viruses, and Rootkits
Curl installeren Ubuntu LAMP
wachtwoord kwijt van computer met linux
Artikel details
Artikel ID: 81
Categorie: Log en monitor
Zoekwoorden
Datum toegevoegd: 22-Dec-2009 14:53:46
Aantal bekeken: 1046
Beoordeling (Stemmen): Artikel beoordeeld 3.8/5.0 (224)

 
« Ga terug