Professional Documents
Culture Documents
Documentation Of: Ministry of Education, Youth and Sport
Documentation Of: Ministry of Education, Youth and Sport
Documentation Of: Ministry of Education, Youth and Sport
Documentation of
YYFMarch 1, 2012GZZ
Ministry of Education, Youth and Sport, #201, Norodom Blvd., Phnom Penh Kingdom of Cambodia
website: www.moeys.gov.kh, Email: info@moeys.gov.kh
Fax: +855 23 210 134
Document History
VERSION
V1.0
V1.0
March 1, 2012
DATE
FEBROURY 01, 2012
FEBROURY 02, 2012
DESCRIPTION
NAGIOS CORE AND PLUGINS INSTALATION
By Vannath KANN
Page 2 of 77
Table of Content
1.
2.
3.
1.2.
Introduction ..........................................................................................................................................................6
2.2.
2.3.
Prerequisites..........................................................................................................................................................7
2.4.
2.5.
2.6.
2.7.
2.8.
2.9.
2.10.
2.11.
2.12.
2.13.
2.14.
2.15.
Introduction ........................................................................................................................................................18
3.2.
Overview..............................................................................................................................................................19
3.3.
3.4.
3.5.
Customizing Your Configuration......................................................................................................................31
3.5.1. Remote Host Configuration .............................................................................................................................31
3.5.2. Monitoring Host Configuration .......................................................................................................................32
3.6.
4.
Introduction ........................................................................................................................................................35
March 1, 2012
By Vannath KANN
Page 3 of 77
5.
6.
7.
4.2.
Overview..............................................................................................................................................................35
4.3.
4.4.
Prerequisites........................................................................................................................................................36
4.5.
4.6.
Configuring Nagios.............................................................................................................................................40
4.7.
4.8.
Restarting Nagios................................................................................................................................................44
Introduction ........................................................................................................................................................45
5.2.
Overview..............................................................................................................................................................45
5.3.
Steps .....................................................................................................................................................................46
5.4.
5.5.
Prerequisites........................................................................................................................................................47
5.6.
Configuring Nagios.............................................................................................................................................47
5.7.
Monitoring Services............................................................................................................................................48
5.8.
5.9.
5.10.
5.11.
Restarting Nagios................................................................................................................................................50
Introduction ........................................................................................................................................................51
6.2.
Overview..............................................................................................................................................................51
6.3.
Steps .....................................................................................................................................................................52
6.4.
6.5.
Prerequisites........................................................................................................................................................52
6.6.
Configuring Nagios.............................................................................................................................................53
6.7.
Restarting Nagios................................................................................................................................................54
Introduction ........................................................................................................................................................55
7.2.
7.3.
7.4.
March 1, 2012
By Vannath KANN
Page 4 of 77
8.
9.
7.5.
Monitoring HTTP...............................................................................................................................................56
7.6.
7.7.
7.8.
Monitoring SMTP...............................................................................................................................................64
7.9.
Monitoring POP3................................................................................................................................................66
7.10.
7.11.
Introduction ........................................................................................................................................................70
5.2.
Configuration ......................................................................................................................................................70
Icon Images.................................................................................................................................... 72
11. Reference........................................................................................................................................ 77
March 1, 2012
By Vannath KANN
Page 5 of 77
1.2.
Introduction
This guide is intended to provide you with simple instructions on how to install Nagios from
source (code) on Fedora and have it monitoring your local machine inside of 20 minutes. No
advanced installation options are discussed here - just the basics that will work for 95% of users
who want to get started.
These instructions were written based on a standard CentOS 6.0 version Linux distribution.
March 1, 2012
By Vannath KANN
Page 6 of 77
2.2.
2.3.
Prerequisites
During portions of the installation you'll need to have root access to your machine.
You also need to give it a static IP address.
Make sure you've installed the following packages on your Fedora installation before
continuing.
Apache
PHP
GCC compiler
GD development libraries
You can use yum to install these packages by running the following commands (as root):
2.4.
[vannath@cent60 ~]$ su -l
Password:
[root@cent60 ~]#
By Vannath KANN
Page 7 of 77
Create a new nagcmd group for allowing external commands to be submitted through the web
interface. Add both the nagios user and the apache user to the group.
[root@cent60
[root@cent60
[root@cent60
[root@cent60
2.5.
~]# groupaddnagcmd
~]# usermod -a -G nagcmdnagios
~]# usermod -a -G nagcmd apache
~]#
[root@cent60
[root@cent60
[root@cent60
[root@cent60
~]#
~]# mkdir -p /opt/NagiosCore3.3
~]# cd /opt/NagiosCore3.3/
NagiosCore3.3]#
Download the source code tarballs of both Nagios and the Nagios plugins (visit
http://www.nagios.org/download/ for links to the latest versions). These directions were tested
with Nagios 3.3.1 and Nagios Plugins 1.4.15.
Make that you Server can access to internet.
[root@cent60 NagiosCore3.3]# wgethttp://prdownloads.sourceforge.net/
sourceforge/nagios/ nagios-3.3.1.tar.gz
[root@cent60 NagiosCore3.3]# wgethttp://prdownloads.sourceforge.net/
sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
2.6.
[root@cent60 NagiosCore3.3]# ll
total 3724
-rw-r--r--. 1 root root 1714630 Dec 14 14:56 nagios-3.3.1.tar.gz
-rw-r--r--. 1 root root 2095419 Dec 14 14:57 nagios-plugins-1.4.15.tar.gz
[root@cent60 NagiosCore3.3]# tar xvf nagios-3.3.1.tar.gz
[root@cent60 NagiosCore3.3]# ll
total 3728
drwxr-xr-x. 16 nagiosnagios
4096 Jul 26 2011nagios
March 1, 2012
By Vannath KANN
Page 8 of 77
-rw-r--r--.
-rw-r--r--.
[root@cent60
[root@cent60
1 root
root
1714630 Dec 14 14:56 nagios-3.3.1.tar.gz
1 root
root
2095419 Dec 14 14:57 nagios-plugins-1.4.15.tar.gz
NagiosCore3.3]# cdnagios
nagios]#
Run the Nagios configure script, passing the name of the group you created earlier like so:
[root@cent60 nagios]# ./configure --with-command-group=nagcmd
Install binaries, init script, sample config files and set permissions on the external command
directory.
[root@cent60
[root@cent60
[root@cent60
[root@cent60
nagios]#
nagios]#
nagios]#
nagios]#
make
make
make
make
install
install-init
install-config
install-commandmode
Don't start Nagios yet - there's still more that needs to be done......
2.7.
2.8.
March 1, 2012
By Vannath KANN
Page 9 of 77
Create a nagiosadmin account for logging into the Nagios web interface. Remember the
password you assign to this account - you'll need it later.
[root@cent60 nagios]# htpasswd -c /usr/local/nagios/htpasswd.usersnagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
[root@cent60 nagios]#
You will experience with above httpd error message so fix is issue we have go and edit file
/etc/httpd/conf/httpd.conf
[root@cent60 conf]# pwd
/etc/httpd/conf
[root@cent60 conf]# vimhttpd.conf
March 1, 2012
By Vannath KANN
[
[
OK
OK
]
]
Page 10 of 77
[root@cent60 nagios]#
2.9.
March 1, 2012
By Vannath KANN
Page 11 of 77
Things look okay - No serious problems were detected during the pre-flight
check
[root@cent60 nagios-plugins-1.4.15]#
To make this change permanent, you'll have to modify the settings in /etc/selinux/config and
reboot.
[root@cent60 nagios-plugins-1.4.15]# vim /etc/selinux/config
#
disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
[root@cent60 nagios-plugins-1.4.15]# reboot
March 1, 2012
By Vannath KANN
Page 12 of 77
Instead of disabling SELinux or setting it to permissive mode, you can use the following
command to run the CGIs under SELinux enforcing/targeted mode:
[root@cent60 nagios-plugins-1.4.15]# chcon -R -t httpd_sys_content_t
/usr/local/nagios/sbin
[root@cent60 nagios-plugins-1.4.15]# chcon -R -t httpd_sys_content_t
/usr/local/nagios/share/
[root@cent60 nagios-plugins-1.4.15]#
For information on running the Nagios CGIs under Enforcing mode with a targeted policy, visit
the Nagios Support Portal or Nagios Community Wiki.
March 1, 2012
By Vannath KANN
Page 13 of 77
Click on the "Service Detail" navbar link to see details of what's being monitored on your local
machine. It will take a few minutes for Nagios to check all the services associated with your
machine, as the checks are spread out over time.
March 1, 2012
By Vannath KANN
Page 14 of 77
By Vannath KANN
Page 15 of 77
SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Orderdeny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
By Vannath KANN
Page 16 of 77
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Orderdeny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
</VirtualHost>
March 1, 2012
By Vannath KANN
Page 17 of 77
Introduction
This document describes how you can monitor "private" services and attributes of Linux/UNIX
servers, such as:
CPU load
Memory usage
March 1, 2012
By Vannath KANN
Page 18 of 77
Disk usage
Logged in users
Running processes
etc.
Publicly available services that are provided by Linux servers (HTTP, FTP, SSH, SMTP, etc.)
can be monitored easily by following the documentation on monitoring publicly available
services.
3.2.
Overview
There are several different ways to monitor attributes or remote Linux/Unix servers. One is by
using shared SSH keys and the check_by_ssh plugin to execute plugins on remote servers. This
method will not be covered here, but can result in high load on your monitoring server if you
are monitoring hundreds or thousands of services. The overhead of setting up/destroying SSH
connections is the cause of this.
Another common method of monitoring remote Linux/Unix hosts is to use the NRPE addon.
NRPE allows you to execute plugins on remote Linux/Unix hosts. This is useful if you need to
monitor local resources/attributes like disk usage, CPU load, memory usage, etc. on a remote
host.
Use th NRPE daemon to execute Nagios plugins on the remote server and report back to the
monitoring host server.
3.3.
By Vannath KANN
Page 19 of 77
Save file to directory /opt/Nagios. As of this writing Nagios 3.3.1 (Stable) and Nagios Plugins
1.4.15 (Stable)
Extract Files:
[root@cent61 Nagios]# tarxvf nagios-plugins-1.4.15.tar.gz
[root@cent61 Nagios]# ll
total 2456
drwxrwxrwx. 16 501 root
4096 Jul 28 2010 nagios-plugins-1.4.15
-rw-r--r--. 1 root root 2095419 Dec 14 14:57 nagios-plugins-1.4.15.tar.gz
-rw-r--r--. 1 root root 411768 Jan 29 14:02 nrpe-2.13.tar.gz
[root@cent61 Nagios]# cd nagios-plugins-1.4.15
[root@cent61 nagios-plugins-1.4.15]#
By Vannath KANN
Page 20 of 77
Install Plugin:
[root@cent61 nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios -with-nagios-group=nagios
[root@cent61 nagios-plugins-1.4.15]# make
[root@cent61 nagios-plugins-1.4.15]# make install
The permissions on the plugin directory and the plugins will need to be changed to nagios user
[root@cent61 nagios-plugins-1.4.15]# chownnagios.nagios /usr/local/nagios/
[root@cent61 nagios-plugins-1.4.15]# chown -R nagios.nagios
/usr/local/nagios/libexec/
[root@cent61 nagios-plugins-1.4.15]#
March 1, 2012
By Vannath KANN
Page 21 of 77
nrpe-2.13]#
nrpe-2.13]#
nrpe-2.13]#
nrpe-2.13]#
nrpe-2.13]#
nrpe-2.13]#
make
make
make
make
make
all
install-plugin
install-daemon
install-daemon-config
install-xinetd
March 1, 2012
By Vannath KANN
Page 22 of 77
[
[
OK
OK
]
]
LISTEN
3.4.
1 23:08 nagios
14 14:56 nagios-3.3.1.tar.gz
2 00:09 nagios-plugins-1.4.15
14 14:57 nagios-plugins-1.4.15.tar.gz
29 14:02 nrpe-2.13.tar.gz
By Vannath KANN
Page 23 of 77
You need the openssl-devel package installed to compile NRPE with ssl support.
[root@cent60 nrpe-2.13]# yum install openssl-devel
[root@cent60 nrpe-2.13]# ./configure
*** Configuration summary for nrpe 2.13 11-11-2011 ***:
General Options:
------------------------NRPE port:
5666
NRPE user:
nagios
NRPE group:
nagios
Nagios user: nagios
Nagios group: nagios
Lets now make sure that the NRPE on our Nagios server can talk to the NRPE daemon on the
remote server we want to monitor. Replace <IP of Remote Server> with the remote servers IP
address.
[root@cent60 nrpe-2.13]# /usr/local/nagios/libexec/check_nrpe -H 192.168.10.2
NRPE v2.13
[root@cent60 nrpe-2.13]#
Make sure that the firewall is disable on the remote linux Server
[root@cent61 nrpe-2.13]# system-config-firewall-tui
Firewall Configuration
March 1, 2012
By Vannath KANN
Page 24 of 77
Firewall: [ ] Enabled
OK
Customize
Cancel
A command definition needs to be created in order for the check_nrpe plugin to be used by
nagios. Add the following:
[root@cent60 nrpe-2.13]# vim /usr/local/nagios/etc/objects/commands.cfg
##################################################################################
#
NRPE CHECK COMMAND
#
#
Command to use NRPE to check remote host systems
##################################################################################
define command{
command_namecheck_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
D
5. Create Linux Object template
In order to be able to add the remote linux machine to Nagios we need to create an object
template file adn add some object definitions.
Create new linux-box-remote object template file:
[root@cent60 nrpe-2.13]# vim /usr/local/nagios/etc/objects/linux-box-remote.cfg
Add the following and replace the values host_name alias address with the values that
match your setup:
The host_name you set for the define_host section must match the host_name in the
define_service section
March 1, 2012
By Vannath KANN
Page 25 of 77
define host{
namelinux-box-remote
; Name of this template
use
generic-host
; Inherit default values
check_period
24x7
check_interval
5
retry_interval
1
max_check_attempts
10
check_command
check-host-alive
notification_period
24x7
notification_interval 30
notification_optionsd,r
contact_groups
admins
register
0
; DONT REGISTER THIS - ITS A TEMPLATE
}
define host{
uselinux-box-remote
; Inherit default values from a template
host_name Cent61
; The name we're giving to this server
alias
Cent61 ; A longer name for the server
address
192.168.10.2
; IP address of the server
}
define service{
use
generic-service
host_name
Cent61
service_description CPU Load
check_commandcheck_nrpe!check_load
}
define service{
use
generic-service
host_name
Cent61
service_description Current Users
check_commandcheck_nrpe!check_users
}
define service{
use
generic-service
host_name
Cent61
service_description /dev/hda1 Free Space
check_command
check_nrpe!check_hda1
}
March 1, 2012
By Vannath KANN
Page 26 of 77
define service{
use
generic-service
host_name
Cent61
service_description Total Processes
check_commandcheck_nrpe!check_total_procs
}
define service{
use
generic-service
host_name
Cent61
service_description Zombie Processes
check_commandcheck_nrpe!check_zombie_procs
Restart Nagios:
[root@cent60 ~]# servicenagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@cent60 ~]#
March 1, 2012
By Vannath KANN
Page 27 of 77
Check Nagios Monitoring server that the remote linux box was added and is being monitored !
6. Trouble Shooting
On Status Information you will encounter error message DISK CRITICAL - /dev/hda1 is not
accessible: No such file or directory
March 1, 2012
By Vannath KANN
Page 28 of 77
Solution you need you check you systems hard disk architecture on the remote server
[root@cent61 ~]# df -h
FilesystemSize Used Avail Use% Mounted on
/dev/sda2
9.9G 382M 9.0G
4%
tmpfs
504M
0 504M
0%
/dev/sda1
97M
24M
69M 26%
/dev/sda5
3.9G 973M 2.7G 27%
/dev/sr0
4.4G 4.4G
0 100%
[root@cent61 ~]#
/
/dev/shm
/boot
/usr
/mnt/iso/dvd
As you can the systems hard disk architecture is sda not hda so change it to fix this.
[root@cent61 ~]# vim /usr/local/nagios/etc/nrpe.cfg
#command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p
/dev/hda1
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% p/dev/sda2
March 1, 2012
By Vannath KANN
Page 29 of 77
You see on Service manu it display /dev/hda1 it is not really on exactly systems Change
command to the right one. This is done on the remote server
[root@cent61 ~]# vim /usr/local/nagios/etc/nrpe.cfg
#command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p
/dev/hda1
command[check_disk_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p
/dev/sda2
March 1, 2012
By Vannath KANN
Page 30 of 77
3.5.
You can use the check_swap plugin to monitor swap usage on the machine. Assuming you
followed theinstallation instructions in this document, the check_swap plugin should already be
installed in/usr/local/nagios/libexec
March 1, 2012
By Vannath KANN
Page 31 of 77
Now that you know the command line that should be execute, open the NRPE configuration
file.
[root@cent61 etc]# pwd
/usr/local/nagios/etc
[root@cent61 etc]# vimnrpe.cfg
Add a new check_swap command definition that uses the command line from above and save
the file.
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c
200
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
# The following examples allow user-supplied arguments and can
If you're running the NRPE daemon as a standalone daemon you'll need to restart it. If you're
running it under theinetd/xinetdsuperserver you don't need to do anything more.
3.5.2. Monitoring Host Configuration
On the monitoring host, you need to define a new service for monitoring the swap usage on the
remote host. Addthe following entry to one of your object configuration files
define service{
use
generic-service
host_name
Cent62
service_description Swap Partition
check_commandcheck_nrpe!check_swap
}.
Notice that the check commands is passing check_swap to check_nrpe command definition.
This will cause the NRPE daemon to run the check_swap command that was definded in the
nrpe.cfg file on the remote host in the previous step.
March 1, 2012
By Vannath KANN
Page 32 of 77
Thats it! You are now monitoring a new service on the remote host using the NRPE addon
3.6.
March 1, 2012
By Vannath KANN
Page 33 of 77
check_aptcheck_flexlmcheck_mailqcheck_oraclecheck_ssmtp
check_breezecheck_ftpcheck_mrtgcheck_overcrcheck_swap
check_by_sshcheck_httpcheck_mrtgtrafcheck_pingcheck_tcp
check_clamdcheck_icmpcheck_nagioscheck_popcheck_time
check_clustercheck_ide_smartcheck_nntpcheck_procscheck_udp
check_dhcpcheck_ifoperstatuscheck_nntpscheck_realcheck_ups
check_digcheck_ifstatuscheck_nrpecheck_rpccheck_users
check_diskcheck_imapcheck_ntcheck_sensorscheck_wave
check_disk_smbcheck_ircdcheck_ntpcheck_simap
negate
check_dnscheck_jabbercheck_ntp_peercheck_smtpurlize
check_dummycheck_loadcheck_ntp_timecheck_spop
utils.pm
check_file_agecheck_logcheck_nwstatcheck_ssh
utils.sh
[root@cent61 libexec]#
[root@cent61 libexec]# ./check_dhcp -h
check_dhcp v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
Copyright (c) 2001-2007 Nagios Plugin Development Team
<nagiosplug-devel@lists.sourceforge.net>
This plugin tests the availability of DHCP servers on a network.
Usage:
check_dhcp [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]
[-i interface] [-m mac]
Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
-v, --verbose
Show details for command-line debugging (Nagios may truncate output)
-s, --serverip=IPADDRESS
IP address of DHCP server that we must hear from
-r, --requestedip=IPADDRESS
IP address that should be offered by at least one DHCP server
-t, --timeout=INTEGER
Seconds to wait for DHCPOFFER before timeout occurs
-i, --interface=STRING
Interface to to use for listening (i.e. eth0)
-m, --mac=STRING
March 1, 2012
By Vannath KANN
Page 34 of 77
Introduction
This document describes how you can monitor "private" services and attributes of Windows
machines, such as:
Memory usage
CPU load
Disk usage
Service states
Running processes
etc.
Publicly available services that are provided by Windows machines (HTTP, FTP, POP3, etc.)
can be monitored easily by following the documentation on monitoring publicly available
services.
4.2.
Overview
Monitoring private services or attributes of a Windows machine requires that you install an
agent on it. This agent acts as a proxy between the Nagios plugin that does the monitoring and
the actual service or attribute of the Windows machine. Without installing an agent on the
Windows box, Nagios would be unable to monitor private services or attributes of the Windows
box.
For this example, we will be installing the NSClient++ (http://sourceforge.net/projects/nscplus/)
addon on the Windows machine and using the check_nt plugin to communicate with the
NSClient++ addon. The check_nt plugin should already be installed on the Nagios server if you
followed the quickstart guide.
March 1, 2012
By Vannath KANN
Page 35 of 77
The NSClient++ agent must be installed on the target Windows machine and configured before
Nagios can monitor system metrics, services, processes, or performance data on the target
machine
4.3.
4.4.
Prerequisites
The first time you configure Nagios to monitor a Windows machine, you'll need to do a bit of
extra work. Remember, you only need to do this for the *first* Windows machine you monitor.
Edit the main Nagios config file.
Remove the leading pound (#) sign from the following line in the main configuration file:
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
By Vannath KANN
Page 36 of 77
What did you just do? You told Nagios to look to the /usr/local/nagios/etc/objects/windows.cfg
to find additional object definitions. That's where you'll be adding Windows host and service
definitions. That configuration file already contains some sample host, hostgroup, and service
definitions. For the *first* Windows machine you monitor, you can simply modify the sample
host and service definitions in that file, rather than creating new ones.
4.5.
Read through the End User License Agreement. Once you have agreed to its terms, check the
acceptance box and click Next to continue.
March 1, 2012
By Vannath KANN
Page 37 of 77
You may customize the installation options on the next screen if you wish. No changes are
required for an working installation of the agent. Click Next to continue.
If an existing NSClient++ installation exists on the target machine, you will have the option of
using the old configuration file. This option is not enable if this is the first time you are
installing the client. Click Next to continue
March 1, 2012
By Vannath KANN
Page 38 of 77
In the next step you will need to configure the NSClient++ agent. These steps are important!
Make sure you:
Enter the IP address of the Nagios Core server in the Allowed hosts box.
Enter a password in the NSClient password box that will be required for
communication between the Nagios server and the Windows machine.
Check the following boxes in the Modules to load section:
Enable common check plugins
Enable nsclient server (check_nt)
Click Next to continue.
Click the Install button on the next screen to begin the installation.
March 1, 2012
By Vannath KANN
Page 39 of 77
When the installation completes, make sure to check the Start service option and click Finish
to complete the setup.
The NSClient++ agent will now be running as a service, which means the Windows machine is
ready to be monitored with Nagios.
4.6.
Configuring Nagios
Now it's time to define some object definitions in your Nagios configuration files in order to
monitor the new Windows machine.
March 1, 2012
By Vannath KANN
Page 40 of 77
Add a new host definition for the Windows machine that you're going to monitor. If this is the
*first* Windows machine you're monitoring, you can simply modify the sample host definition
in windows.cfg. Change the host_name, alias, and address fields to appropriate values for the
Windows box.
# Change the host_name, alias, and address to fit your situation
define host{
use
template
host_name
alias
host
address
}
windows-server
w2k81
; The name we're giving to this host
Windows Server 2008; A longer name associated with the
192.168.10.3
Good. Now you can add some service definitions (to the same configuration file) in order to tell
Nagios to monitor different aspects of the Windows machine. If this is the *first* Windows
machine you're monitoring, you can simply modify the sample service definitions in
windows.cfg.
Note: Replace "w2k81" in the example definitions below with the name you specified in the
host_name directive of the host definition you just added.
Add the following service definition to monitor the version of the NSClient++ addon that is
running on the Windows server. This is useful when it comes time to upgrade your Windows
servers to a newer version of the addon, as you'll be able to tell which Windows machines still
need to be upgraded to the latest version of NSClient++.
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
NSClient++ Version
check_nt!CLIENTVERSION
Add the following service definition to monitor the uptime of the Windows server.
March 1, 2012
By Vannath KANN
Page 41 of 77
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
Uptime
check_nt!UPTIME
Add the following service definition to monitor the CPU utilization on the Windows server and
generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if
the 5-minute load is 80% or greater.
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
CPU Load
check_nt!CPULOAD!-l 5,80,90
Add the following service definition to monitor memory usage on the Windows server and
generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory
usage is 80% or greater.
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
Memory Usage
check_nt!MEMUSE!-w 80 -c 90
Add the following service definition to monitor usage of the C:\ drive and D:\drive on the
Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING
alert if disk usage is 80% or greater.
define service{
use
#
host_name
host_name
service_description
check_command
}
March 1, 2012
generic-service
winserver
w2k81
C:\ Drive Space
check_nt!USEDDISKSPACE!-l c -w 80 -c 90
By Vannath KANN
Page 42 of 77
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
D:\ Drive Space
check_nt!USEDDISKSPACE!-l d -w 80 -c 90
Add the following service definition to monitor the W3SVC service state on the Windows
machine and generate a CRITICAL alert if the service is stopped.
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
W3SVC
check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
Add the following service definition to monitor the Explorer.exe process on the Windows
machine and generate a CRITICAL alert if the process is not running.
define service{
use
#
host_name
host_name
service_description
check_command
}
generic-service
winserver
w2k81
Explorer
check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
That's it for now. You've added some basic services that should be monitored on the Windows
box. Save the configuration file.
4.7.
Password Protection
If you specified a password in the NSClient++ configuration file on the Windows machine,
you'll need to modify the check_nt command definition to include the password. Open the
commands.cfg file for editing.
Change the definition of the check_nt command to include the "-s <PASSWORD>" argument
(where PASSWORD is the password you specified on the Windows machine) like this:
March 1, 2012
By Vannath KANN
Page 43 of 77
4.8.
Restarting Nagios
You're done with modifying the Nagios configuration, so you'll need to verify your
configuration files and restart Nagios.
If the verification process produces any errors messages, fix your configuration file before
continuing. Make sure that you don't (re)start Nagios until the verification process completes
without any errors!
[root@cent60 ~]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
Checking misc settings...
Total Warnings: 0
Total Errors:
0
Things look okay - No serious problems were detected during the pre-flight
check
[root@cent60 ~]#
[root@cent60 ~]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@cent60 ~]#
Ok now we monitor it !
March 1, 2012
By Vannath KANN
Page 44 of 77
Introduction
This document describes how you can monitor the status of network switches and routers. Some
cheaper "unmanaged" switches and hubs don't have IP addresses and are essentially invisible on
your network, so there's not any way to monitor them. More expensive switches and routers
have addresses assigned to them and can be monitored by pinging them or using SNMP to
query status information.
I'll describe how you can monitor the following things on managed
switches, hubs, and routers:
Packet loss, round trip average
SNMP status information
Bandwidth / traffic rate
5.2.
Overview
Monitoring switches and routers can either be easy or more involved - depending on what
equipment you have and what you want to monitor. As they are critical infrastructure
components, you'll no doubt want to monitor them in at least some basic manner.
Switches and routers can be monitored easily by "pinging" them to determine packet loss, RTA,
etc. If your switch supports SNMP, you can monitor port status, etc. with the check_snmp
plugin and bandwidth (if you're using MRTG) with the check_mrtgtraf plugin.
March 1, 2012
By Vannath KANN
Page 45 of 77
The check_snmp plugin will only get compiled and installed if you have the net-snmp and netsnmp-utils packages installed on your system. Make sure the plugin exists in
/usr/local/nagios/libexec before you continue. If it doesn't, install net-snmp and net-snmp-utils
and recompile/reinstall the Nagios plugins.
5.3.
Steps
There are several steps you'll need to follow in order to monitor a new router or switch. They
are:
Perform first-time prerequisites
Create new host and service definitions for monitoring the device
Restart the Nagios daemon
5.4.
March 1, 2012
By Vannath KANN
Page 46 of 77
before doing so. For the time being, just follow the directions outlined below and you'll be
monitoring your network routers/switches in no time.
5.5.
Prerequisites
The first time you configure Nagios to monitor a network switch, you'll need to do a bit of extra
work. Remember, you only need to do this for the *first* switch you monitor.
Edit the main Nagios config file.
5.6.
Configuring Nagios
You'll need to create some object definitions in order to monitor a new router/switch.
Open the switch.cfg file for editing.
Add a new host definition for the switch that you're going to monitor. If this is the *first* switch
you're monitoring, you can simply modify the sample host definition in switch.cfg. Change the
host_name, alias, and address fields to appropriate values for the switch.
# Define the switch that we'll be monitoring
define host{
use
generic-switch ; Inherit default values from a template
#
host_name
linksys-srw224p ; The name we're giving to this switch
host_name
icteo-sw01
; The name we're giving to this switch
alias
ICTEO Switch 01 ; A longer name associated with the
switch
address
192.168.10.10 ; IP address of the switch
hostgroups
switches
; Host groups this switch is associated with
}
March 1, 2012
By Vannath KANN
Page 47 of 77
5.7.
Monitoring Services
Now you can add some service definitions (to the same configuration file) to monitor different
aspects of the switch. If this is the *first* switch you're monitoring, you can simply modify the
sample service definition in switch.cfg.
Note: Replace "linksys-srw224p" in the example definitions below with the name you specified
in the host_name directive of the host definition you just added.
5.8.
5.9.
March 1, 2012
By Vannath KANN
Page 48 of 77
In the check_command directive of the service definition above, the "-C public" tells the plugin
that the SNMP community name to be used is "public" and the "-o sysUpTime.0" indicates
which OID should be checked.
f you want to ensure that a specific port/interface on the switch is in an up state, you could add a
service definition like this:
if you want to ensure that a specific port/interface on the switch is in an up state, you could add
a service definition like this:
# Monitor Port 1 status via SNMP
define service{
use
generic-service ; Inherit values from a template
#
host_name
linksys-srw224p
host_name
icteo-sw01
; The name we're giving to this switch
service_description
Port 1 Link Status
check_command
check_snmp!-C public -o ifOperStatus.1 -r 1 -m
RFC1213-MIB
}
In the example above, the "-o ifOperStatus.1" refers to the OID for the operational status of port
1 on the switch. The "-r 1" option tells the check_snmp plugin to return an OK state if "1" is
found in the SNMP result (1 indicates an "up" state on the port) and CRITICAL if it isn't found.
The "-m RFC1213-MIB" is optional and tells the check_snmp plugin to only load the
"RFC1213-MIB" instead of every single MIB that's installed on your system, which can help
speed things up.
That's it for the SNMP monitoring example. There are a million things that can be monitored
via SNMP, so its up to you to decide what you need and want to monitor. Good luck!
Tip: You can usually find the OIDs that can be monitored on a switch by running the following
command (replace 192.168.10.10 with the IP address of the switch): snmpwalk -v1 -c public
192.168.1.253 -m ALL .1
March 1, 2012
By Vannath KANN
Page 49 of 77
If you're monitoring bandwidth usage on your switches or routers using MRTG, you can have
Nagios alert you when traffic rates exceed thresholds you specify. The check_mrtgtraf plugin
(which is included in the Nagios plugins distribution) allows you to do this.
You'll need to let the check_mrtgtraf plugin know what log file the MRTG data is being stored
in, along with thresholds, etc. In my example, I'm monitoring one of the ports on a Linksys
switch. The MRTG log file is stored in /var/lib/mrtg/192.168.1.253_1.log. Here's the service
definition I use to monitor the bandwidth data that's stored in the log file...
# Monitor bandwidth via MRTG logs
define service{
use
generic-service ; Inherit values from a template
#
host_name
linksys-srw224p
host_name
icteo-sw01
; The name we're giving to this switch
service_description
Port 1 Bandwidth Usage
check_command
check_local_mrtgtraf!/var/lib/mrtg/192.168.10.10_1.log!AVG!1000000,1000000!5000000
,5000000!10
}
In the example above, the "/var/lib/mrtg/192.168.10.10_1.log" option that gets passed to the
check_local_mrtgtraf command tells the plugin which MRTG log file to read from. The "AVG"
option tells it that it should use average bandwidth statistics. The "1000000,2000000" options
are the warning thresholds (in bytes) for incoming traffic rates. The "5000000,5000000" are
critical thresholds (in bytes) for outgoing traffic rates. The "10" option causes the plugin to
return a CRITICAL state if the MRTG log file is older than 10 minutes (it should be updated
every 5 minutes).
Save the file.
March 1, 2012
By Vannath KANN
Page 50 of 77
Total Warnings: 0
Total Errors:
0
Things look okay - No serious problems were detected during the pre-flight
check
[root@cent60 etc]#
Introduction
This document describes how you can monitor the status of networked printers. Specifically,
HP printers that have internal/external JetDirect cards/devices, or other print servers (like the
Troy PocketPro 100S or the Netgear PS101) that support the JetDirect protocol.
The check_hpjd plugin (which is part of the standard Nagios plugins distribution) allows you to
monitor the status of JetDirect-capable printers which have SNMP enabled. The plugin is
capable of detecting the following printer states:
6.2.
Paper Jam
Out of Paper
Printer Offline
Intervention Required
Toner Low
Insufficient Memory
Open Door
Output Tray is Full
and more...
Overview
Monitoring the status of a networked printer is pretty simple. JetDirect-enabled printers usually
have SNMP enabled, which allows Nagios to monitor their status using the check_hpjd plugin
The check_hpjd plugin will only get compiled and installed if you have the net-snmp and netsnmp-utils packages installed on your system. Make sure the plugin exists in
/usr/local/nagios/libexec before you continue. If it doesn't, install net-snmp and net-snmp-utils
and recompile/reinstall the Nagios plugins.
March 1, 2012
By Vannath KANN
Page 51 of 77
6.3.
Steps
There are several steps you'll need to follow in order to monitor a new network printer. They
are:
Perform first-time prerequisites
Create new host and service definitions for monitoring the printer
Restart the Nagios daemon
6.4.
6.5.
Prerequisites
The first time you configure Nagios to monitor a network printer, you'll need to do a bit of extra
work. Remember, you only need to do this for the *first* printer you monitor.
Edit the main Nagios config file.
Remove the leading pound (#) sign from the following line in the main configuration file:
March 1, 2012
By Vannath KANN
Page 52 of 77
6.6.
Configuring Nagios
You'll need to create some object definitions in order to monitor a new printer.
Open the printer.cfg file for editing.
Add a new host definition for the networked printer that you're going to monitor. If this is the
*first* printer you're monitoring, you can simply modify the sample host definition in
printer.cfg. Change the host_name, alias, and address fields to appropriate values for the printer
define host{
use
#
host_name
host_name
alias
address
hostgroups
associated with
}
Now you can add some service definitions (to the same configuration file) to monitor different
aspects of the printer. If this is the *first* printer you're monitoring, you can simply modify the
sample service definition in printer.cfg.
Note: Replace "icteo-pr01" in the example definitions below with the name you specified in the
host_name directive of the host definition you just added.
Add the following service definition to check the status of the printer. The service uses the
check_hpjd plugin to check the status of the printer every 10 minutes by default. The SNMP
community string used to query the printer is "public" in this example.
define service{
use
#
host_name
with
March 1, 2012
generic-service
; Inherit values from a template
hplj2605dn ;The name of the host the service is associated
By Vannath KANN
Page 53 of 77
host_name
icteo-pr01
service_description
rinter Status
; The service description
check_command
heck_hpjd!-C public ; The command used to monitor the
service
normal_check_interval
10
under normal conditions
retry_check_interval
1
until its final/hard state is determined
}
Add the following service definition to ping the printer every 10 minutes by default. This is
useful for monitoring RTA, packet loss, and general network connectivity.
#Create a service for "pinging" the printer occassionally.
monitoring RTA, packet loss, etc.
Useful for
define service{
use
generic-service
#
host_name
hplj2605dn
host_name
icteo-pr01
service_description
PING
check_command
check_ping!3000.0,80%!5000.0,100%
normal_check_interval
10
retry_check_interval
1
}
6.7.
Restarting Nagios
Once you've added the new host and service definitions to the printer.cfg file, you're ready to
start monitoring the printer. To do this, you'll need to verify your configuration and restart
Nagios.
If the verification process produces any errors messages, fix your configuration file before
continuing. Make sure that you don't (re)start Nagios until the verification process completes
without any errors!
By Vannath KANN
Page 54 of 77
Things look okay - No serious problems were detected during the pre-flight
check
[root@cent60 objects]#
[root@cent60 objects]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@cent60 objects]#
Introduction
This document describes how you can monitor publicly available services, applications and
protocols. By "public" I mean services that are accessible across the network - either the local
network or the greater Internet. Examples of public services include HTTP, POP3, IMAP, FTP,
and SSH. There are many more public services that you probably use on a daily basis. These
services and applications, as well as their underlying protocols, can usually be monitored by
Nagios without any special access requirements.
Private services, in contrast, cannot be monitored with Nagios without an intermediary agent of
some kind. Examples of private services associated with hosts are things like CPU load,
memory usage, disk usage, current user count, process information, etc. These private services
or attributes of hosts are not usually exposed to external clients. This situation requires that an
intermediary monitoring agent be installed on any host that you need to monitor such
information on.
D
d
7.2.
March 1, 2012
By Vannath KANN
Page 55 of 77
If you don't happen to find an appropriate plugin for monitoring what you need, you can always
write your own. Plugins are easy to write, so don't let this thought scare you off. Read the
documentation on developing plugins for more information.
I'll walk you through monitoring some basic services that you'll probably use sooner or later.
Each of these services can be monitored using one of the plugins that gets installed as part of
the Nagios plugins distribution. Let's get started...
7.3.
define host{
use
template
host_name
alias
address
}
linux-box-remote
Cent61
; The name we're giving to this server
Cent61 ; A longer name for the server
192.168.10.2
; IP address of the server
Now that a definition has been added for the host that will be monitored, we can start defining
services that should be monitored. As with host definitions, service definitions can be placed in
any object configuration file.
7.4.
7.5.
Monitoring HTTP
March 1, 2012
By Vannath KANN
Page 56 of 77
Chances are you're going to want to monitor web servers at some point - either yours or
someone else's. The check_http plugin is designed to do just that. It understands the HTTP
protocol and can monitor response time, error codes, strings in the returned HTML, server
certificates, and much more.
The commands.cfg file contains a command definition for using the check_http plugin. It looks
like this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim commands.cfg
# 'check_http' command definition
define command{
command_name
check_http
command_line
$USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}
A simple service definition for monitoring the HTTP service on the remotehost machine might
look like this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim linux-box-remote.cfg
define service{
use
host_name
service_description
check_command
}
generic-service
Cent61
HTTP
check_http
You will experience with HTTP deamon with warning HTTP/1.1 403 Forbidden.
March 1, 2012
By Vannath KANN
Page 57 of 77
Nagios is checking in the apache or HTTP Root directory , is looking for index pages .
the solution is to create index there :
[root@cent61
[root@cent61
total 0
[root@cent61
[root@cent61
~]# cd /var/www/html/
html]# ll
html]# touch index.html
html]#
Restart httpd :
[root@cent61 html]# service httpd restart
Stopping httpd:
Starting httpd
[root@cent61 html]#
[ OK ]
[ OK ]
Restart nagios :
[root@cent60 objects]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@cent60 objects]#
March 1, 2012
By Vannath KANN
Page 58 of 77
This simple service definition will monitor the HTTP service running on remotehost. It will
produce alerts if the web server doesn't respond within 10 seconds or if it returns HTTP errors
codes (403, 404, etc.). That's all you need for basic monitoring
Tip: For more advanced monitoring, run the check_http plugin manually with --help as a
command-line argument to see all the options you can give the plugin. This --help syntax works
with all of the plugins I'll cover in this document.
[root@cent60 libexec]# pwd
/usr/local/nagios/libexec
[root@cent60 libexec]#
[root@cent60 libexec]# ./check_http -h
check_http v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
Copyright (c) 1999-2008 Nagios Plugin Development Team
<nagiosplug-devel@lists.sourceforge.net>
This plugin tests the HTTP service on the specified host. It can test
normal (http) and secure (https) servers, follow redirects, search for
strings and regular expressions, check connection times, and report on
certificate expiration times.
Usage:
check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
[-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]
[-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]
[-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive
regex>]
March 1, 2012
By Vannath KANN
Page 59 of 77
By Vannath KANN
Page 60 of 77
By Vannath KANN
Page 61 of 77
7.6.
Monitoring FTP
When you need to monitor FTP servers, you can use the check_ftp plugin. The commands.cfg
file contains a command definition for using the check_ftp plugin, which looks like this:
A simple service definition for monitoring the FTP server on remotehost would look like this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim linux-box-remote.cfg
define service{
use
generic-service
host_name
Cent61
service_description FTP
check_command
check_ftp
}
March 1, 2012
By Vannath KANN
Page 62 of 77
This service definition will monitor the FTP service and generate alerts if the FTP server doesn't
respond within 10 seconds.
A more advanced service definition is shown below. This service will check the FTP server
running on port 1023 on remotehost. It will generate an alert if the server doesn't respond within
5 seconds or if the server response doesn't contain the string "Pure-FTPd [TLS]".
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim commands.cfg
define service{
use
generic-service
host_name
Cent61
service_description Special FTP
check_command
check_ftp !-p 1023 -t 5 -e "Pure-FTPd [TLS]"
}
7.7.
Monitoring SSH
When you need to monitor SSH servers, you can use the check_ssh plugin. The commands.cfg
file contains a command definition for using the check_ssh plugin, which looks like this:
A simple service definition for monitoring the SSH server on remotehost would look like this:
March 1, 2012
By Vannath KANN
Page 63 of 77
This service definition will monitor the SSH service and generate alerts if the SSH server
doesn't respond within 10 seconds.
A more advanced service definition is shown below. This service will check the SSH server and
generate an alert if the server doesn't respond within 5 seconds or if the server version string
string doesn't match "OpenSSH_4.2".
define service{
use
host_name
service_description
check_command
}
7.8.
generic-service
Cent61
SSH Version Check
check_ssh !-t 5 -r "OpenSSH_4.2"
Monitoring SMTP
The check_smtp plugin can be using for monitoring your email servers. The commands.cfg file
contains a command definition for using the check_smtp plugin, which looks like this:
A simple service definition for monitoring the SMTP server on remotehost would look like this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim linux-box-remote.cfg
March 1, 2012
By Vannath KANN
Page 64 of 77
define service{
use
host_name
service_description
check_command
}
generic-service
Cent61
SMTP
check_smtp
Testing to see whether SMPT Service on Cent61 is run or not from Nagios Server
[root@cent60 objects]# telnet 192.168.10.2 25
Trying 192.168.10.2...
Connected to 192.168.10.2.
Escape character is '^]'.
220 cent61.localdomain ESMTP Postfix
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@cent60 objects]#
This service definition will monitor the SMTP service and generate alerts if the SMTP server
doesn't respond within 10 seconds.
A more advanced service definition is shown below. This service will check the SMTP server
and generate an alert if the server doesn't respond within 5 seconds or if the response from the
server doesn't contain "mygreatmailserver.com".
define service{
use
host_name
service_description
check_command
March 1, 2012
generic-service
Cent61
SMTP Response Check
check_smtp! t 5 e mygreatmailserver.com
By Vannath KANN
Page 65 of 77
7.9.
Monitoring POP3
The check_pop plugin can be using for monitoring the POP3 service on your email servers. The
commands.cfg file contains a command definition for using the check_pop plugin, which looks
like this:
A simple service definition for monitoring the POP3 service on remotehost would look like
this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim linux-box-remote.cfg
define service{
use
host_name
service_description
check_command
}
generic-service
Cent61
POP3
check_pop
This service definition will monitor the POP3 service and generate alerts if the POP3 server
doesn't respond within 10 seconds.
Then you will see as below:
March 1, 2012
By Vannath KANN
Page 66 of 77
A more advanced service definition is shown below. This service will check the POP3 service
and generate an alert if the server doesn't respond within 5 seconds or if the response from the
server doesn't contain "mygreatmailserver.com".
define service{
use
host_name
service_description
check_command
}
generic-service
Cent61
POP3
check_pop !-t 5 -e "mygreatmailserver.com"
March 1, 2012
By Vannath KANN
Page 67 of 77
A simple service definition for monitoring the IMAP4 service on remotehost would look like
this:
[root@cent60 objects]# pwd
/usr/local/nagios/etc/objects
[root@cent60 objects]# vim linux-box-remote.cfg
define service{
use
host_name
service_description
check_command
}
generic-service
Cent61
IMAP
check_imap
This service definition will monitor the IMAP4 service and generate alerts if the IMAP server
doesn't respond within 10 seconds.
A more advanced service definition is shown below. This service will check the IMAP4 service
and generate an alert if the server doesn't respond within 5 seconds or if the response from the
server doesn't contain "mygreatmailserver.com".
define service{
use
host_name
service_description
check_command
}
March 1, 2012
generic-service
Cent61
IMAP
check_imap !-t 5 -e "mygreatmailserver.com"
By Vannath KANN
Page 68 of 77
If the verification process produces any errors messages, fix your configuration file before
continuing. Make sure that you don't (re)start Nagios until the verification process completes
without any errors!
March 1, 2012
By Vannath KANN
Page 69 of 77
Introduction
An important feature of Nagios is the ability to create parent child relationships. Each switch,
router, server, and hosts the packet encounters or passes through is considered a hop and will
require that you define a parent/child host relationship in Nagios. Then you want to add the
parent host to all the children using the following host definition option: parent <parent host>.
5.2.
Configuration
March 1, 2012
By Vannath KANN
Page 70 of 77
define host{
use
host_name
alias
switch
address
hostgroups
parents
}
windows-server
winserver
; The name we're giving to this host
My Windows Server
; A longer name associated with
w2k81
; The name we're giving to this host
Windows Server 2008
; A longer name associated with
192.168.10.3
127.0.0.3
icteo-sw01
March 1, 2012
generic-printer
hplj2605dn
icteo-pr01
ICTEO Printer 01
192.168.10.20
127.0.0.6
network-printers
icteo-sw02
By Vannath KANN
Page 71 of 77
And other host configuration are the same just user option: parent and then we will see the
result as the following:
9. Icon Images
The icons has to be put with your favorite SSH explorer in /usr/local/nagios/share/images
March 1, 2012
By Vannath KANN
Page 72 of 77
linux-server
By Vannath KANN
Page 73 of 77
March 1, 2012
generic-switch
linksys-srw224p
icteo-sw01
By Vannath KANN
Page 74 of 77
alias
switch
address
127.0.0.1
hostgroups
switches
associated with
#
parents
Cent62
icon_image switch40.png
vrml_image switch40.png
statusmap_image switch40.png
}
By Vannath KANN
Page 75 of 77
10.Trouble shooting
If you've forgotten to enter some critical data or misconfigured things, Nagios will spit out a
warning or error message that should point you to the location of the problem. Error messages
generally print out the line in the configuration file that seems to be the source of the problem.
On errors, Nagios will often exit the pre-flight check and return to the command prompt after
printing only the first error that it has encountered. This is done so that one error does not
cascade into multiple errors as the remainder of the configuration data is verified. If you get any
error messages you'll need to go and edit your configuration files to remedy the problem.
Warning messages can generally be safely ignored, since they are only recommendations and
not requirements.
Processing object config file '/usr/local/nagios/etc/objects/printer02.cfg'...
Warning: Duplicate definition found for hostgroup 'network-printers' (config
file '/usr/local/nagios/etc/objects/printer02.cfg', starting on line 47)
Error: Could not add object property in file
'/usr/local/nagios/etc/objects/printer02.cfg' on line 48.
Error processing object config files!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
[root@cent60 etc]#
March 1, 2012
By Vannath KANN
Page 76 of 77
Once you've verified your configuration files and fixed any errors you can go ahead and
(re)start Nagios.
11.Reference
http://nagios.sourceforge.net/docs/nagioscore/3/en/toc.html
http://www.kernelhardware.org/nagios-nrpe-to-monitor-remote-linux-server/
http://ideasnet.wordpress.com/2011/11/19/ides-server-x-how-to-set-the-parent-childrelationships-between-router-switchserver-and-hosts-with-nagios-and-how-they-are-connectedto-each-other/
http://exchange.nagios.org/directory/Graphics-and-Logos/Images-and-Logos
March 1, 2012
By Vannath KANN
Page 77 of 77