12/June/2005 tested on openSUSE 10.1
Nagios is an open source and network resource monitoring software. It can monitor hosts and services that you specify, alerting you when things get bad and when they get better.
RPMs are available for openSuSE10.1. However rpms are not included in CD nor DVD. rpms are only available at the Internet Installation Repository.
i.e. http://download.opensuse.org/distribution/SL-10.1/inst-source/
nagios-1.3-14.i586.rpm nagios-nagat-1.0a2-289.noarch.rpm nagios-nrpe-2.2-15.i586.rpm nagios-plugins-1.4.2-16.i586.rpm nagios-plugins-extras-1.4.2-16.i586.rpm nagios-www-1.3-14
ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi/ <Directory /usr/lib/nagios/cgi/> Options ExecCGI order deny,allow deny from all allow from 127.0.0.1 192.168.0.0/24 AuthName "Nagios Access" AuthType Basic AuthUserFile /etc/nagios/htpasswd.users require valid-user </Directory> Alias /nagios/ /usr/share/nagios/ <Directory /usr/share/nagios/> Options None order deny,allow deny from all allow from 127.0.0.1 192.168.0.0/24 AuthName "Nagios Access" AuthType Basic AuthUserFile /etc/nagios/htpasswd.users require valid-user </Directory>Edit /etc/apache2/conf.d/nagat.conf, and give the same configuration.
Alias /nagat/ /usr/share/nagat/ <Directory /usr/share/nagat/> Options None order deny,allow deny from all allow from 127.0.0.1 192.168.0.0/24 php_flag register_globals on </Directory>This will create a username and password for nagiosamin. If you change the username, you must chage the corresponding lines at cgi.cfg for the user as well.
# htpasswd2 -c /etc/nagios/htpasswd.users nagiosadminEdit /etc/nagios/cgi.cfg, and make sure use_authentication=1
... use_authentication=1 ...Restart Apache
# /etc/init.d/apache2 restart
srv1(nagios) (192.168.66.128)
|
Firewall (192.168.254.254)-- ISP1 (85.115.193.253) -- ISP2 (213.248.68.33)
|
winxp1(192.168.66.1)
# Generic host definition template
define host{
name generic-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
max_check_attempts 3
notification_interval 240
register 0
}
# 'srv1' host definition
define host{
use generic-host
host_name srv1
alias srv1.test1.kg
address 192.168.66.128
check_command check-host-alive
}
# 'winxp1' host definition
define host{
use generic-host
host_name winxp1
alias winxp1.test1.kg
address 192.168.66.1
check_command check-host-alive
}
# 'firewall' host definition
define host{
use generic-host
host_name firewall
alias firewall.test1.kg
address 192.168.254.254
check_command check-host-alive
}
# 'isp1-router' host definition
define host{
use generic-host
host_name isp1-router
alias ISP1 Router
address 85.115.193.253
parents firewall
check_command check-host-alive
}
# 'isp2-router' host definition
define host{
use generic-host
host_name isp2-router
alias ISP2 Router
address 213.248.68.33
parents isp1-router
check_command check-host-alive
}
Edit /etc/nagios/hostgroups.cfg
# 'local-servers' host group definition
define hostgroup{
hostgroup_name local-servers
alias Local Servers
contact_groups admin-contactgroup
members srv1,winxp1,firewall
}
# 'isp-routers' host group definition
define hostgroup{
hostgroup_name isp-routers
alias IPS Routers
contact_groups admin-contactgroup
members isp1-router,isp2-router
}
Edit /etc/nagios/services.cfg
# Generic service definition template
define service{
name generic-service
notifications_enabled 1
event_handler_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
check_period 24x7
notification_interval 240
notification_period 24x7
notification_options w,c,r
contact_groups admin-contactgroup
register 0
}
# Service definition
define service{
use generic-service
host_name firewall
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name isp1-router
service_description PING
check_command check_ping!500.0,20%!1000.0,60%
}
define service{
use generic-service
host_name isp2-router
service_description PING
check_command check_ping!500.0,20%!1000.0,60%
}
define service{
use generic-service
host_name srv1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name srv1
service_description HTTP
check_command check_http
}
define service{
use generic-service
host_name srv1
service_description POP
check_command check_pop
}
define service{
use generic-service
host_name srv1
service_description SMTP
check_command check_smtp
}
define service{
use generic-service
host_name srv1
service_description DNS
check_command check_dns
}
define service{
use generic-service
host_name winxp1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name winxp1
service_description HTTP
check_command check_http
}
## LOCAL SYSTEM
define service{
use generic-service
host_name srv1
service_description LOCAL DISK
check_command check_local_disk!20%!10%!/dev/sda6
}
define service{
use generic-service
host_name srv1
service_description LOCAL USERS
check_command check_local_users!75!150
}
define service{
use generic-service
host_name srv1
service_description LOCAL PROCS
check_command check_local_procs!150!200!RSZDT
}
Note that the following plugins are available for services.cfg
| check_breeze | check_http | check_mysql | check_procs | check_time |
| check_by_ssh | check_icmp | check_nagios | check_radius | check_udp |
| check_dhcp | check_ifoperstatus | check_nntp | check_real | check_udp2 |
| check_dig | check_ifstatus | check_nntps | check_rpc | check_ups |
| check_disk | check_imap | check_nrpe | check_sensors | check_users |
| check_disk_smb | check_ircd | check_nt | check_simap | check_wave |
| check_dns | check_jabber | check_ntp | check_smtp | negate |
| check_dummy | check_ldap | check_nwstat | check_snmp | urlize |
| check_file_age | check_load | check_oracle | check_spop | utils.pm |
| check_flexlm | check_log | check_overcr | check_ssh | utils.sh |
| check_fping | check_mailq | check_pgsql | check_ssmtp | |
| check_ftp | check_mrtg | check_ping | check_swap | |
| check_hpjd | check_mrtgtraf | check_pop | check_tcp |
# cd /usr/lib/nagios/plugins/
# ./check_imap -h
check_IMAP (nagios-plugins 1.4.2) 1.66
Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
Copyright (c) 1999-2004 Nagios Plugin Development Team
<nagiosplug-devel@lists.sourceforge.net>
This plugin tests IMAP connections with the specified host.
Usage: check_IMAP -H host -p port [-w <warning time>] [-c <critical time>]
[-s <send string>] [-e <expect string>] [-q <quit string>]
[-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]
[-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]
[-D <days to cert expiry>] [-S <use SSL>]
...
To check the imap, test as,
# ./check_imap -H 192.168.5.1 SSH OK - OpenSSH_4.2-chrootssh (protocol 1.99)Edit /etc/nagios/checkcommands.cfg, and define the template for the plugin, if it is not configured. For example,
define command{
command_name check_imap
command_line $USER1$/check_imap -H $HOSTADDRESS$
}
define command{
command_name check_ssh
command_line $USER1$/check_ssh $HOSTADDRESS$
}
define command{
command_name check_nt_cpu
command_line $USER1$/check_nt -H $HOSTADDRESS$ -v CPULOAD -l 60,90,95,120,90,95
}
define command{
command_name check_nt_mem
command_line $USER1$/check_nt -H $HOSTADDRESS$ -v MEMUSE
}
...
Note: For check_nt plugin, you need to install NSClient to Windows PC. Download from http://nsclient.ready2run.nl/
Open /etc/nagios/services.cfg, and add followings,
define service{
use generic-service
host_name srv1
service_description IMAP
check_command check_imap
}
define service{
use generic-service
host_name srv1
service_description SSH
check_command check_ssh
}
define service{
use generic-service
host_name winxp1
service_description CPU
check_command check_nt_cpu
}
define service{
use generic-service
host_name winxp1
service_description MEM
check_command check_nt_mem
}
define contact{
name generic-contact
contact_name daemon
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email,notify-by-epager
host_notification_commands host-notify-by-email
register 0
}
# 'user1' contact definition
define contact{
use generic-contact
contact_name admin
alias Admin
email user1@test1.kg
}
Edit /etc/nagios/contactgroups.cfg
# 'admin-contactgroup' contact group definition
define contactgroup{
contactgroup_name admin-contactgroup
alias admin-contactgroup
members admin
}
Edit /etc/nagios/escalations.cfg
# Hostgroup 'local-servers' escalation definition
define hostgroupescalation{
hostgroup_name local-servers
first_notification 2
last_notification 5
contact_groups admin-contactgroup
notification_interval 10
}
Edit /etc/nagios/dependencies.cfg. Delete all lines, but keep this file.
# nagios -v nagios.cfgIf there is not error, you will see as,
Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
# chkconfig nagios on # chkconfig nrpe on # chkconfig nagios-nrpe on # /etc/init.d/nagios restart # /etc/init.d/nrpe restart # /etc/init.d/xinetd restart






