A lot of powerful monitoring tools are freely available from linux world. One of them is Nagios.
Nagios is a fairly complex linux monitoring tool that determines current status of target host or equipment. Two good things about Nagios is that Nagios supports web-enabled administration page and user view-only mode account. The other one is that Nagios' task can be expanded variably using extended plugins and addons for Nagios.
This blog entry covers how to install and configure Nagios binary package from a Fedora box and make it act as part of a monitoring utility server for polling device status.
Nagios web pages says:
Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external "plugins" which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.
Here's how to install Nagios and Nagios-Plugins using yum
NAGIOS INSTALLATION
===================
The default nagios installation can be done by doing like so
# yum -y install nagios
This linux blog entry would only cover Nagios setup and installation aimed to generate a long-term uptime/downtime graph status of host and device based on ICMP echo replies sent against the target host IP address.
If you wish to install more Nagios plugins and addons.
# yum -y install nagios-plugins nagios-plugins-all
Additional Nagios Plugins
==========================
There are more Nagios addons and plugins available for downloads using yum. To name a several Nagios plugins and addons:
a. nagios-plugins-pqsql
b. nagios-plugins-ntp
c. nagios-plugins-ping
d. nagios-plugins-dns
e. nagios-plugins-disk
f. nagios-plugins-udp
g. nagios-plugins-mrtg
h. nagios-plugins-dig
i. nagios-plugins-log
j. nagios-plugins-dhcp
k. nagios-plugins-sensors
l. nagios-plugins-http
m. nagios-plugins-ups
n. nagios-plugins-rpc
o. nagios-plugins-game
p. nagios-plugins-icmp
q. nagios-plugins-real
r. nagios-plugins-nt
s. nagios-plugins-swap
t. nagios-plugins-overcr
u. nagios-plugins-tcp
v. nagios-plugins-users
w. nagios-plugins-mysql
x. nagios-plugins-ldap
y. nagios-plugins-perl
z. nagios-plugins-ide_smart
and a lot more!
Nagios Default Folder Locations
================================
By default Nagios yum installation, Nagios stores the following file location into your harddisk
a. /etc/nagios/ - Nagios configuration folder locations
b. /var/log/nagios/ - Nagios log and messages folder locations
c. /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations
d. /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location
e. /usr/bin - Nagios binaries
f. /etc/httpd/conf.d/ - Nagios Apache folder files
g. /etc/logrotate.d/nagios/ - Nagios log rotation file
As a blog entry example, I am going to take a sample of creating uptime/downtime graph say one of my remote broadband router with an IP address of 123.123.123.123 located remotely.
To create a Nagios configuration for this device and IP address, follow these simple steps.
# cd /etc/nagios/
do your backup kungfu
# cp nagios.cfg-sample nagios.cfg
# cp localhost.cfg-sample localhost.cfg
# cp cgi-cfg-sample cgi-cfg.cfg
# cp commands.cfg-sample commands.cfg
With old version of Nagios, Nagios configuration files are being stored separately. This separate config files refers to nagios functions, nagios services, nagios target host and nagios users. The recent Nagios rpm package version makes it more easy to configure Nagios configuration file.
A simple generic template can now be edited in less than three files assuming a basic Nagios setup with default Nagios feature values on RedHat-based distro like Fedora.
Sample Nagios Generic Template
==============================
Here's a generic basic template for that.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define host{
name DEVICE-NAME
use generic-host
check_period 24x7
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 120
notification_options d,u,r
contact_groups admins
register 0
}
define host{
use DEVICE-NAME
host_name DEVICE-NAME
alias DEVICE-NAME
address REMOTE-DEVICE-IP-ADDRESS
}
define service{
use local-service
host_name DEVICE-NAME
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can edit DEVICE-NAME to refer to group name of selected set of host with similar function. Say your FQDN name for a router is Gateway1.google.com , you can replace DEVICE-NAME and change it to Gateway1. Following the pattern, REMOTE-DEVICE-IP-ADDRESS can be replaced by a reachable host or device IP address.
More legends are shown below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a. DEVICE-NAME - reference name for the target device or equipment that would appear from graph
b. REMOTE-DEVICE-IP-ADDRESS - the IP address of remote device or host being monitored
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This generic template should be inserted or appended into your /etc/nagios/localhost.cfg file.
As an example reference, I am assuming a default Nagios time period interval given from default config of its /etc/localhost.cfg in Nagios polling interval time. You may alter this time interval pattern that may fit your own GMT. If you decided to change the Nagios polling interval, this would affect how the device would be drawn to graph as well.
See a basic sample of Nagios polling interval below. The timeperiod is tagged as nonworkhours as shown:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, proceed on creating a host group for that particular router.
Say for example, if you have 10 Ciscos router and 10 Non-Ciscos router, you can reference them with a single group name of Network-A
-Routers or Routers alone.
From /etc/nagios/localhost, find the line that says:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define hostgroup{
hostgroup_name DEVICE-NAME-GROUP-ALIAS
alias DEVICE-NAME-GROUP
members DEVICE-NAME
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and edit the BOLD characters shown above.
For reference:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEVICE-NAME-GROUP-ALIAS - Refers to the group alias
DEVICE-NAME-GROUP - Refers to group name. If you have say 10 routers, you can refer them
by this categorical group name. There are features in Nagios that
shows host or device sorted and shown in group name or alias
DEVICE-NAME - Refers to device or target host identity name in Nagios
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NAGIOS CONFIG VERIFICATION
==========================
For sanity checking, make sure you verify Nagios config files. This can be done like so
# nagios -v /etc/nagios/nagios.cfg
The above command would show you for any erroneous lines frin Nagios config file.
NAGIOS LINUX SERVICE
==========================
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.
Reload your apache service together with your Nagios service like so
# service httpd restart
# service Nagios stop
# service Nagios start
# service Nagios status
Nagios Further Configuration
============================
If you wish to customize more of the basic config shown above, continue editing /etc/nagios/localhost. Find these lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
define contact{
contact_name nagios-admin
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
host_notification_commands notify-by-email
email YOUR-EMAIL-ADDR
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Legend:
YOUR-EMAIL-ADDR refers to admin's email address if you wish to receive email alerts.
If you wish to change more of Nagios default configuration setup files, this can be done by editing /etc/nagios/nagios.cfg file.
Besides from an extensible feature of Nagios having more plugins and addons, Nagios can also be configured to produce audio, SMS and email alerts for proactive response from admins.
Additionally, Nagios config files comes with helpful tips and comments inserted before the actual Nagios config lines. This is highly noticeable from nagios.cfg and localhost.cfg Nagios files as well.
Remember to verify all your Nagios config files before restarting the Nagios service.
And finally, point your browser to Nagios page. By default, it should be located from your apache root folder, say /var/www/html/nagios, the interface would be http://yourdoma.com/nagios/
Congratulations for browsing your Nagios page!
NAGIOS ADDITIONAL SECURITY
==========================
For additional package security, username and password authentication mechanism is highly supported by Apache config files. This mechanism also includes IP address access list. Being paranoid admin and enabling HTTPS would also enhance Nagios restrictions with Apache.
Launching Nagios daemon as normal nagios user is advisable as well. This can be changed from nagios.cfg file.
Unfortunately, further security with apache would not be covered here.
See my nagios screenshots in action:
Hope this helps and have a nice weekend!
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
September
(58)
- Dear Linux SysAd Blog Readers
- Proactive monitoring from linux terminal
- deleting new lines and return line from text file
- Google chat setup using PSI howto
- PSI messenger - a truly promising open messaging a...
- Google chat setup using GAIM Pidgin howto
- Linux command line shell variables defined
- ls - displaying directory contents in many ways
- Control of alternative linux executables
- Searching using whereis linux command
- Witchy which linux command
- NeroLinux - diehard Nero burning software
- Google Sky - Explore and Rediscover the Sky
- Celestia - 3D Earth and Sky visualization
- Earth3D - real-time 3D Earth visualization
- GcStar - managing personal collection items
- DStat - resource statistics linux tool
- Bandwidth Monitor-NG - terminal-based interface ba...
- KNemo - KDE network interface monitoring tool
- EtherApe - graphical network activity monitoring tool
- Beauty of Math using Linux
- print leading/trailing lines before/after a matchi...
- Nagios Monitoring - install and generic setup howto
- ChRT- change real-time attribute process scheduling
- squeezed out multiple commented lines
- UNIX to DOS text file format converter
- totally squeezed out multiple blank lines
- squeezed multiple blank lines into single line
- fmt - simple optimal text formatter
- Linux backup powered by RDiff-Backup
- Linux Ping command explained
- read and display text file from terminal
- URLView - URL and email extractor
- TFTP server - setup and install howto
- NMap - Linux port scanning
- removing garbage characters from screen terminal
- invert string match using grep
- RDesktop - remote desktop howto
- Graveman on Linux - burn baby burn burn
- HTOP - interactive process viewer alternative
- Caching DNS server install howto
- BitTorrent - downloading large files made easy
- PHPAlbum - web photo album install howto
- MRTG graph creation with Cisco routers
- Tree view of directories and file listings from co...
- MAC address packet filtering using IPTables
- GTK-based GNOME Linux Tools
- Linux backups powered by RSnapShot
- MRTG tutorial, install and howtos
- FindSMB - view shared folders from network
- Squid - upgrade and install howto
- prompt and press a key between script lines
- Devede - DVD/VCD video authoring and creation tool
- display file and file system status
- determine file type
- GNOME GUI task scheduler install howto
- Linux backups powered by Rsync
- KPackage - GUI package administration and manageme...
-
▼
September
(58)
Friday, September 14, 2007
Nagios Monitoring - install and generic setup howto
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment