Hi,
i've created a blog post and script to setup nagios on centos
i know how hard it is to setup and configure but it's also very powerful when it's setup
the blog post is here
http://www.jgwynne.co.uk/2011/04/nag...-centos-64bit/
don't know if that's allowed but if not the script updates the centos box and installs the rpmforge package then install's nagios (and all the nagios goodies)
uses a custom nagios.cfg file (because we use directories and not individual files specified in the nagios config file)
here's the script
#!/bin/bash
#update all packages
yum -y update
#make sure apache is installed
yum -y install httpd
#setup nagios
wget
http://packages.sw.be/rpmforge-relea....rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
#install nagios
yum -y install nagios*
#Copy nagios configuration file
cd /etc/nagios
rm -f nagios.cfg
wget
http://www.jgwebhosting.co.uk/setup/nagios.cfg
mkdir printers
mkdir switches
mkdir routers
mkdir servers
#setup htpassword file for nagios
echo "enter the nagiosadmin user password below"
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
#restart apache and nagios
service httpd restart
service nagios restart
#check they are set for startup
chkconfig nagios on
chkconfig httpd on
echo "all done you can access nagios by going to http://localhost/nagios"
you will also need to create config files for devices you want to monitor
using the nagios command layout
we monitor our dns server hobbit using the host and service definition below
define host{
use generic-host ; Name of host template to use
host_name hobbit.jgwebhosting.co.uk
address 50.22.22.62
check_command check-host-alive
max_check_attempts 10
notification_interval 30
notification_period 24x7
notification_options d,u,r
contact_groups guest
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description check_users
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_users
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description check_disk
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_disk
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description check_load
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_load
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description check_processes
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_total_procs
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description Ping check
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description DNS check
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_dns!hobbit.jgwebhosting.co.uk
}
define service{
use generic-service ; Name of service template to use
host_name hobbit.jgwebhosting.co.uk
service_description Free RAM check
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
notification_interval 30
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_mem
}
this is saved in a filename.cfg and placed in /etc/nagios/servers (you could also put it in switches, routers etc)
you will need to reload/restart nagios everytime you add a new definition file using the command service nagios restart (if nagios fails there's something wrong with your config file)
you will also need to edit /etc/nagios/objects/contacts.cfg
to add your email address (edited in the config file)
i hope this helps someone get nagios setup easily
joe