Showing posts with label nagios. Show all posts
Showing posts with label nagios. Show all posts

Wednesday, 31 May 2017

How To Install NRPE On Redhat or CentOS Linux Server


Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Step 01: Install NRPE Plugins in Nagios monitoring host

wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

tar -zxvf nrpe-2.15.tar.gz

cd nrpe-2.15

./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Now build and install NRPE and its xinetd startup script with these commands:
make all
sudo make install
sudo make install-xinetd
sudo make install-daemon-config
  
Step 01: On client server that you want to monitor, install the EPEL repository:
    NRPE packages and plugins are available under epel yum repository
sudo yum install epel-release
or
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RPM (Red Hat Package Manager) is an default open source and most popular package management utility for Red Hat based systems like (RHEL, CentOS and Fedora). The tool allows system administrators and users to install, update, uninstall, query, verify and manage system software packages in Unix/Linux operating systems.
   
Now install Nagios Plugins and NRPE:
yum --enablerepo=epel -y install nrpe nagios-plugins
update private IP address of your Nagios server in allowed host
sudo vi /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1,10.132.224.168

Add new commands or update existing commands like below in same file.
 command[check_root_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
 command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
Step 02: Start NRPE Service:
Reboot nrpe once to read new configuration, Also configure nrpe to auto start on system boot.
service nrpe start
chkconfig nrpe on
Step 03: Test NRPE from Nagios server
Login to Nagios server and run the following command. On successful connection it will print the version of nrpe package.
/usr/local/nagios/libexec/check_nrpe -H 10.132.224.168
NRPE v2.15
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

How to Install Nagios on RHEL,CentOS or Fedora Linux Operating System.

In this tutorial i will tell you how to install Nagios Core 4.1.1 and Nagios Plugins 2.1.1 on RHEL Linux server. Following all steps were performed and tested on RHEL 7.3 Linux Server.

Step 01 : Disable SELinux
Disable the SELinux by running the following command with root user.
$ setenforce 0
Basically this a security feature of the Linux kernel. It is designed to protect the server against misconfigurations and/or compromised daemons.

Note: setenforce is a command line utility that is used to switch the mode SELinux is running in from enforcing to permissive and vice versa without requiring a reboot.

Modify /etc/selinux/config and change enforcing to disabled
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Step 02: Install the required packages
Make sure you have installed the following packages on your Linux system before continuing.
Apache 2
PHP
GCC compiler and development libraries
GD development libraries

If you did not install then please run the following commands:

sudo yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget unzip -y
Note:
GCC compiler and development libraries :
GNU Compiler Collection. gcc, formerly known as the GNU C Compiler, compiles multiple languages (C, C++, Objective-C, Ada, FORTRAN, and Java) to machine code.

GD development libraries :
The GD library is a graphics drawing library that provides tools for manipulating image data. In Shopp, the GD library is used to process images for generating gallery preview and thumbnail size images automatically.

net-snmp:
Simple Network Management Protocol (SNMP) is a widely used protocol for monitoring the health and welfare of network equipment (eg. routers), computer equipment and even devices like UPSs.
And helps Nagios for notification emails.

openssl-devel:
OpenSSL is a toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.

php-cli : PHP Command Line Interface

Step 03: Create Account Information
Create the Nagios user
  useradd nagios
Create a new nagcmd group for allowing external commands to be submitted through the web interface.
  groupadd nagcmd
Add both the nagios user and the apache user to the group nagcmd.
  usermod -a -G nagcmd nagios
  usermod -a -G nagcmd apache
Where :
The usermod command modifies the system account files to reflect the changes that are specified on the command line.
-a, --append
           Add the user to the supplementary group(s). Use only with the -G option.

-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
           A list of supplementary groups which the user is also a member of.
         
Step 04: Download and Install Nagios
Run the following commands to download and extract Nagios and Nagios plugins in /tmp directory.
cd /tmp

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

tar zxf nagios-4.1.1.tar.gz

tar zxf nagios-plugins-2.1.1.tar.gz
Go to nagios-4.1.1 directory and start compiling Nagios.
    cd nagios-4.1.1

Run the Nagios configure script, passing the name of the group you created earlier like so:
./configure --with-command-group=nagcmd
Compile the Nagios source code.
make all
Install binaries, init script, sample config files and set permissions on the external command directory.
make install
make install-init
make install-config
make install-commandmode
Configure the Web Interface
make install-webconf
Same way install the Nagios plugin as well.
cd /tmp/nagios-plugins-2.1.1

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl

make all

make install
Step 05: Creating a password for nagiosadmin
We now need to create a password for the nagiosadmin user. This will be used to login to your core web GUI.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Step 06: Start Nagios and Apache server
service httpd start
service nagios start (or) /etc/init.d/nagios start
Step 07: Login to the Web Interface
Enter the following url into the browser, replace your public IP of nagios server. It will ask to enter username and password. In this configuration we have username as nagiosadmin and password also as nagiosadmin.

http://<public_ip_of_nagios_server>/nagios/

Step 08: Troubleshooting
If you cannot access the Nagios web page, it may be related to your firewall rules. The following command will open up port 80 on your Nagios Core machine.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
If you don't have firewall-cmd then try the following rule into your iptables
iptables -A INPUT -p tcp --dport http -j ACCEPT
iptables -A INPUT -p tcp --dport https -j ACCEPT
iptables-save > /etc/sysconfig/iptables
/etc/init.d/iptables restart
If you are still unable to access the web GUI, your web server may be only listening on IPv6. Modify /etc/httpd/conf/httpd.conf
and look for the part that says 'Listen :80'. Modify it to be 'Listen 0.0.0.0:80'. Then, run service httpd restart.
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Sunday, 25 September 2016

How To Install NRPE on Ubuntu 16.04, 14.04, 12.04 and LinuxMint

NRPE is stands for Nagios Remote Plugin Executor. In previous post i had described about installation of Nagios Server on Ubuntu operating system(link). This article will help you to install NRPE on Ubuntu 15.04, 14.04, 12.04 & LinuxMint systems.

The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor "local" resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent like NRPE must be installed on the remote Linux/Unix machines.
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Note: It is possible to execute Nagios plugins on remote Linux/Unix machines through SSH. There is a check_by_ssh plugin that allows you to do this. Using SSH is more secure than the NRPE addon, but it also imposes a larger (CPU) overhead on both the monitoring and remote machines. This can become an issue when you start monitoring hundreds or thousands of machines. It is useful to use NRPE to lower load on monitoring and remote host as well.












 As showing in above image the NRPE addon consists of two pieces:

– The check_nrpe plugin, which resides on the local monitoring machine.
– The NRPE daemon, which runs on the remote Linux/Unix machine.

Step 1. Install NRPE and Nagios Plugins

NRPE is available under default apt repositories of Ubuntu systems. Execute the following command to install it

$ sudo apt-get install nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard

Step 2. Configure NRPE

Edit the /etc/nagios/nrpe.cfg file and in allowed_hosts give the ip address of Nagios monitoring Server from which monitoring will be done. For example nagios monitoring host server ip is 192.168.182.130, then add this IP address to allowed_hosts list.

allowed_hosts=127.0.0.1,192.168.182.130

Step 3. Restart the NRPE service

Restart the nrpe service in client machine with following command.

$ sudo /etc/init.d/nagios-nrpe-server restart
Step 4. Install nagios-nrpe-plugin package in your nagios monitoring server. 
Run the following command to install the check_nrpe plugin on your Nagios server. It will install check_nrpe plugin under /usr/lib/nagios/plugins/.

$ sudo apt-get install nagios-nrpe-plugin

Step 5. Verification 

Now login to the nagios server and sudo nagios user. To verify if nagios are able to communicate with nrpe agent in client machine run check_nrpe plugin by passing client machine IP address ( In my case client machine IP is 192.168.182.131 )as following. If you are not able to find check_nrpe plugin please follow the setp 4 to install check_nrpe plugin.

nagios@ubuntu:~$ /usr/lib/nagios/plugins/check_nrpe -H 192.168.182.131
NRPE v2.12

The output "NRPE v2.12" shows that the nagios server was successfully communicating with NRPE agent.

Step 6. Add nagios check command in NRPE

By defaults all nagios installed in /usr/lib/nagios/plugins/ directory. You can add new service check as per your requirements in /etc/nagios/nrpe.cfg. Folloing are the default check commans in nrpe.cfg file.

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

Step 7. Start/Stop/Restart NRPE service

Each time when we make change into the configuration file which are in client machine that time we need to restart the nrpe srevice.

$ sudo /etc/init.d/nagios-nrpe-server stop
$ sudo /etc/init.d/nagios-nrpe-server start
$ sudo /etc/init.d/nagios-nrpe-server restart


   
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Wednesday, 11 May 2016

Standard Nagios Plugins

Plugins are compiled executable s or scripts (Perl scripts, shell scripts, etc.) that can be run from a command line to check the status or a host or service. Nagios uses the results from plugins to determine the current status of hosts and services on your network.

Following is list of standard Nagios Plugins, commands and their usages.
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

check_by_ssh
check_disk
check_disk_smb
check_dns
check_dummy
check_flexlm
check_ftp
check_http
check_imap
check_ircd
check_load
check_log
check_mailq
check_mrtg
check_mrtgtraf
check_nagios
check_nntp
check_ntp
check_nwstat
check_overcr
check_ping
check_pop
check_procs
check_real
check_rpc
check_sensors
check_smtp
check_ssh
check_swap
check_tcp
check_time
check_udp
check_ups
check_users
check_vsz
check_wave

Following the detailed description of each command with their usage.

Top

check_by_ssh

This plugin will execute a command on a remote host using SSH

Usage:

check_by_ssh [-f46] [-t timeout] [-i identity] [-l user] -H <host> -C <command> [-n name] [-s servicelist] [-O outputfile] [-p port]
check_by_ssh -V prints version info
check_by_ssh -h prints more detailed help

Options:

-H, --hostname=HOST name or IP address of remote host
-C, --command='COMMAND STRING' command to execute on the remote machine
-f tells ssh to fork rather than create a tty
-t, --timeout=INTEGER specify timeout (default: 10 seconds) [optional]
-p, --port=PORT port to connect to on remote system [optional]
-l, --logname=USERNAME SSH user name on remote host [optional]
-i, --identity=KEYFILE identity of an authorized key [optional]
-O, --output=FILE external command file for nagios [optional]
-s, --services=LIST list of nagios service names, separated by ':' [optional]
-n, --name=NAME short name of host in nagios configuration [optional]
-4, --use-ipv4 tell ssh to use IPv4
-6, --use-ipv6 tell ssh to use IPv6

The most common mode of use is to refer to a local identity file with the '-i' option. In this mode, the identity pair should have a null passphrase and the public key should be listed in the authorized_keys file of the remote host. Usually the key will be restricted to running only one command on the remote server. If the remote SSH server tracks invocation agruments, the one remote program may be an agent that can execute additional commands as proxy

To use passive mode, provide multiple '-C' options, and provide all of -O, -s, and -n options (servicelist order must match '-C' options)

Top

check_disk

This plugin will check the percent of used disk space on a mounted file system and generate an alert if percentage is above one of the threshold values.

Usage:

check_disk -w limit -c limit [-p path] [-t timeout] [-m] [--verbose]
check_disk (-h|--help)
check_disk (-V|--version)

Options:

-w, --warning=INTEGER Exit with WARNING status if less than INTEGER kilobytes of disk are free
-w, --warning=PERCENT% Exit with WARNING status if more than PERCENT of disk space is free
-c, --critical=INTEGER Exit with CRITICAL status if less than INTEGER kilobytes of disk are free
-c, --critical=PERCENT% Exit with CRITCAL status if more than PERCENT of disk space is free
-p, --path=PATH, --partition=PARTTION Path or partition (checks all mounted partitions if unspecified)
-m, --mountpoint Display the mountpoint instead of the partition
-v, --verbose Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_disk_smb

This plugin will check the percent of used disk space on a mounted file system and generate an alert if percentage is above one of the threshold values.

Usage:

check_disk -w limit -c limit [-p path] [-t timeout] [-m] [--verbose]
check_disk (-h|--help)
check_disk (-V|--version)

Options:

-w, --warning=INTEGER Exit with WARNING status if less than INTEGER kilobytes of disk are free
-w, --warning=PERCENT% Exit with WARNING status if more than PERCENT of disk space is free
-c, --critical=INTEGER Exit with CRITICAL status if less than INTEGER kilobytes of disk are free
-c, --critical=PERCENT% Exit with CRITCAL status if more than PERCENT of disk space is free
-p, --path=PATH, --partition=PARTTION Path or partition (checks all mounted partitions if unspecified)
-m, --mountpoint Display the mountpoint instead of the partition
-v, --verbose Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_dns

Usage:

check_dns -H host [-s server] [-a expected-address] [-t timeout]
check_dns --help
check_dns --version

Option:

-H, --hostname=HOST The name or address you want to query
-s, --server=HOST Optional DNS server you want to use for the lookup
-a, --expected-address=IP-ADDRESS Optional IP address you expect the DNS server to return
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-h, --help Print detailed help
-V, --version Print version numbers and license information

This plugin uses the nslookup program to obtain the IP address for the given host/domain query. A optional DNS server to use may be specified. If no DNS server is specified, the default server(s) specified in /etc/resolv.conf will be used.

Top

check_dummy

Usage:

./check_dummy <integer state>

This plugin will simply return the state corresponding to the numeric value of the <state> argument.

Top

check_flexlm

Check available flexlm license managers

Usage:

check_flexlm -F <filename> [--verbose]
check_flexlm --help
check_flexlm --version

Options:

-F, --filename=FILE Name of license file
-v, --verbose Print some extra debugging information (not advised for normal operation)
-V, --version Show version and license information
-h, --help Show this help screen

Top

check_ftp

This plugin tests FTP connections with the specified host.

Usage:

check_ftp -H host -p port [-w warn_time] [-c crit_time] [-s send] [-e expect] [-W wait] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric
address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-s, --send=STRING String to send to the server
-e, --expect=STRING String to expect in server response -W, --wait=INTEGER Seconds to wait between sending string and polling for response
-w, --warning=DOUBLE Response time to result in warning status (seconds)
-c, --critical=DOUBLE Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-v Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_http

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] [-f <ok | warn | critcal | follow>] [-e <expect>] [-s string] [-r <regex> | -R <case-insensitive regex>] [-P string]
check_http (-h | --help) for detailed help
check_http (-V | --version) for version information

NOTE: One or both of -H and -I must be specified

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (virtual host)
-I, --IP-address=ADDRESS IP address or name (use numeric address if possible to bypass DNS lookup).
-e, --expect=STRING String to expect in first (status) line of server response (default: HTTP/1.)
If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)
-s, --string=STRING String to expect in the content
-u, --url=PATH URL to GET or POST (default: /)
-p, --port=INTEGER Port number (default: 80)
-P, --post=STRING URL encoded http POST data
-w, --warning=INTEGER Response time to result in warning status (seconds)
-c, --critical=INTEGER Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-a, --authorization=AUTH_PAIR Username:password on sites with basic authentication
-L, --link=URL Wrap output in HTML link (obsoleted by urlize)
-f, --onredirect=<ok|warning|critical|follow> How to handle redirected pages
-S, --ssl Connect via SSL
-C, --certificate=INTEGER Minimum number of days a certificate has to be valid.
(when this option is used the url is not checked.)
-v, --verbose Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

This plugin can also check whether an SSL enabled web server is able to serve content (optionally within a specified time) or whether the X509 certificate is still valid for the specified number of days.

CHECK CONTENT: check_http -w 5 -c 10 --ssl www.debian.org

When the 'www.debian.org' server returns its content within 5 seconds, a STATE_OK will be returned. When the server returns its content but exceeds the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,a STATE_CRITICAL will be returned.

CHECK CERTIFICATE: check_http www.debian.org -C 14

When the certificate of 'www.debian.org' is valid for more than 14 days, a STATE_OK is returned. When the certificate is still valid, but for less than 14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when the certificate is expired.

Top

check_imap

This plugin tests IMAP connections with the specified host.

Usage:

check_imap -H host -p port [-w warn_time] [-c crit_time] [-s send] [-e expect] [-W wait] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric
address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-s, --send=STRING String to send to the server
-e, --expect=STRING String to expect in server response -W, --wait=INTEGER Seconds to wait between sending string and polling for response -w, --warning=DOUBLE Response time to result in warning status (seconds)
-c, --critical=DOUBLE Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-v Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_ircd

Perl Check IRCD plugin for Nagios

Usage:

check_ircd -H <host> [-w <warn>] [-c <crit>] [-p <port>]

Options:

-H, --hostname=HOST Name or IP address of host to check
-w, --warning=INTEGER Number of connected users which generates a warning state (Default: 50)
-c, --critical=INTEGER Number of connected users which generates a critical state (Default: 100)
-p, --port=INTEGER Port that the ircd daemon is running on <host> (Default: 6667)
-v, --verbose Print extra debugging information

Top

check_load

This plugin tests the current system load average.

Usage:

check_load -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15
check_load --version
check_load --help

Options:

-w, --warning=WLOAD1,WLOAD5,WLOAD15 Exit with WARNING status if load average exceeds WLOADn
-c, --critical=CLOAD1,CLOAD5,CLOAD15 Exit with CRITICAL status if load average exceed CLOADn
-h, --help Print detailed help screen
-V, --version Print version information

the load average format is the same used by "uptime" and "w"

Top

check_log

Usage: check_log -F logfile -O oldlog -q query
Usage: check_log --help
Usage: check_log --version

Log file pattern detector plugin for Nagios

Top

check_mailq

Usage:

check_mailq [-w <warn>] [-c <crit>] [-t <timeout>] [-v verbose]

Checks the number of messages in the mail queue Feedback/patches to support non-sendmail mailqueue welcome

Options:

-w (--warning) = Min. number of messages in queue to generate warning
-c (--critical) = Min. number of messages in queu to generate critical alert ( w < c )
-t (--timeout) = Plugin timeout in seconds (default = 15)
-h (--help)
-V (--version)
-v (--verbose) = deebugging output

Top

check_mrtg

This plugin will check either the average or maximum value of one of the
two variables recorded in an MRTG log file.

Usage:

check_mrtg -F log_file -a <AVG | MAX> -v variable -w warning -c critical [-l label] [-u units] [-e expire_minutes] [-t timeout] [-v]
check_mrtg (-h | --help) for detailed help
check_mrtg (-V | --version) for version information

Options:

-F, --logfile=FILE The MRTG log file containing the data you want to monitor
-e, --expires=MINUTES Minutes before MRTG data is considered to be too old
-a, --aggregation=AVG|MAX Should we check average or maximum values?
-v, --variable=INTEGER Which variable set should we inspect? 1 or 2?
-w, --warning=INTEGER Threshold value for data to result in WARNING status
-c, --critical=INTEGER Threshold value for data to result in CRITICAL status
-l, --label=STRING Type label for data (Examples: Conns, "Processor Load", In, Out)
-u, --units=STRING Option units label for data (Example: Packets/Sec, Errors/Sec,
"Bytes Per Second", "% Utilization")
-h, --help Print detailed help screen
-V, --version Print version information

If the value exceeds the <vwl> threshold, a WARNING status is returned. If the value exceeds the <vcl> threshold, a CRITICAL status is returned. If the data in the log file is older than <expire_minutes> old, a WARNING status is returned and a warning message is printed.

This plugin is useful for monitoring MRTG data that does not correspond to bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).It can be used to monitor any kind of data that MRTG is monitoring - errors,packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows
me to track processor utilization, user connections, drive space, etc and this plugin works well for monitoring that kind of data as well.

Notes:- This plugin only monitors one of the two variables stored in the MRTG log file. If you want to monitor both values you will have to define two commands with different values for the <variable> argument. Of course,you can always hack the code to make this plugin work for you.

- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from here

Top

check_mrtgtraf

This plugin tests the UPS service on the specified host.

Usage:

check_mrtgtraf -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>
[-e expire_minutes] [-t timeout] [-v]
check_mrtgtraf --help
check_mrtgtraf --version

Options:

-F, --filename=STRING File to read log from
-e, --expires=INTEGER  Minutes after which log expires
-a, --aggregation=(AVG|MAX) Test average or maximum -w, --warning
Warning threshold pair "<incoming>,<outgoing>"
-c, --critical Critical threshold pair "<incoming>,<outgoing>"
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_nagios

This plugin attempts to check the status of the Nagios process on the local machine. The plugin will check to make sure the Nagios status log is no older than the number of minutes specified by the <expire_minutes> option. It also uses the /bin/ps command to check for a process matching whatever you specify
by the <process_string> argument.

Usage:

check_nagios -F <status log file> -e <expire_minutes> -C <process_string>

Options:

-F, --filename=FILE Name of the log file to check
-e, --expires=INTEGER Seconds aging afterwhich logfile is condsidered stale
-C, --command=STRING Command to search for in process table
-h, --help Print this help screen
-V, --version Print version information

Example:

./check_nagios -H /usr/local/nagios/var/status.log -e 5 -C /usr/local/nagios/bin/nagios

Top

check_nntp

This plugin tests NNTP connections with the specified host.

Usage:

check_nntp -H host -p port [-w warn_time] [-c crit_time] [-s send] [-e expect] [-W wait] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-s, --send=STRING String to send to the server
-e, --expect=STRING String to expect in server response -W, --wait=INTEGER Seconds to wait between sending string and polling for response
-w, --warning=DOUBLE Response time to result in warning status (seconds)
-c, --critical=DOUBLE Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-v Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_ntp

Usage:

check_ntp -H <host> [-w <warn>] [-c <crit>] [-v verbose]

Options:

<warn> = Clock offset in seconds at which a warning message will be generated.Defaults to 60.
<crit> = Clock offset in seconds at which a critical message will be generated.Defaults to 120.

The same warning and critical values are used to check against the dispersion column of ntpdc/xntpdc for the host being queried.

Top

check_nwstat

This plugin attempts to contact the MRTGEXT NLM running on a Novell server to gather the requested system information.

Usage:

check_nwstat -H host [-v variable] [-w warning] [-c critical] [-p port] [-t timeout]
check_nwstat (-h | --help) for detailed help
check_nwstat (-V | --version) for version information

Options:

-H, --hostname=HOST Name of the host to check
-v, --variable=STRING Variable to check. Valid variables include:
LOAD1 = 1 minute average CPU load
LOAD5 = 5 minute average CPU load
LOAD15 = 15 minute average CPU load
CONNS = number of currently licensed connections
VPF<vol> = percent free space on volume <vol>
VKF<vol> = KB of free space on volume <vol>
LTCH = percent long term cache hits
CBUFF = current number of cache buffers
CDBUFF = current number of dirty cache buffers
LRUM = LRU sitting time in minutes
DSDB = check to see if DS Database is open
LOGINS = check to see if logins are enabled
UPRB = used packet receive buffers
PUPRB = percent (of max) used packet receive buffers
SAPENTRIES = number of entries in the SAP table
SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>
OFILES = number of open files
VPP<vol> = percent purgeable space on volume <vol>
VKP<vol> = KB of purgeable space on volume <vol>
VPNP<vol> = percent not yet purgeable space on volume <vol>
VKNP<vol> = KB of not yet purgeable space on volume <vol>
ABENDS = number of abended threads (NW 5.x only)
CSPROCS = number of current service processes (NW 5.x only)
-w, --warning=INTEGER Threshold which will result in a warning status
-c, --critical=INTEGER Threshold which will result in a critical status
-p, --port=INTEGER Optional port number (default: 9999)
-t, --timeout=INTEGER Seconds before connection attempt times out (default: 10)
-o, --osversion Include server version string in results
-h, --help Print this help screen
-V, --version Print version information

Notes:
- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG extension for NetWare be loaded on the Novell servers you wish to check.(available from http://www.engr.wisc.edu/~drews/mrtg/)
- Values for critical thresholds should be lower than warning thresholds when the following variables are checked: VPF, VKF, LTCH, CBUFF, and LRUM.

Top

check_overcr

This plugin attempts to contact the Over-CR collector daemon running on the remote UNIX server in order to gather the requested system information. This plugin requres that Eric Molitors' Over-CR collector daemon be running on the remote server. Over-CR can be downloaded from http://www.molitor.org/overcr
(This plugin was tested with version 0.99.53 of the Over-CR collector)

Usage:

check_overcr -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]

Options:

-H, --hostname=HOST Name of the host to check
-p, --port=INTEGER Optional port number (default: 2000)
-v, --variable=STRING Variable to check. Valid variables include:
LOAD1 = 1 minute average CPU load
LOAD5 = 5 minute average CPU load
LOAD15 = 15 minute average CPU load
DPU<filesys> = percent used disk space on filesystem <filesys>
PROC<process> = number of running processes with name <process>
NET<port> = number of active connections on TCP port <port>
UPTIME = system uptime in seconds
-w, --warning=INTEGER Threshold which will result in a warning status
-c, --critical=INTEGER Threshold which will result in a critical status
-t, --timeout=INTEGER Seconds before connection attempt times out (default: 10)
-h, --help Print this help screen
-V, --version Print version information

Notes:
- For the available options, the critical threshold value should always be higher than the warning threshold value, EXCEPT with the uptime variable (i.e. lower uptimes are worse).

Top

check_ping

Use ping to check connection statistics for a remote host.

Usage:

check_ping -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%% [-p packets] [-t timeout] [-L]
check_ping (-h | --help) for detailed help
check_ping (-V | --version) for version information

Options:

-H, --hostname=HOST host to ping
-w, --warning=THRESHOLD warning threshold pair
-c, --critical=THRESHOLD critical threshold pair
-p, --packets=INTEGER number of ICMP ECHO packets to send (Default: 5)
-t, --timeout=INTEGER optional specified timeout in second (Default: 10)
-L, --link show HTML in the plugin output (obsoleted by urlize)
THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the percentage of packet loss to trigger an alarm state.

This plugin uses the ping command to probe the specified host for packet loss (percentage) and round trip average (milliseconds). It can produce HTML output linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in the contrib area of the downloads section at http://www.nagios.org/

Top

check_pop

This plugin tests POP connections with the specified host.

Usage:

check_pop -H host -p port [-w warn_time] [-c crit_time] [-s send] [-e expect] [-W wait] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-s, --send=STRING String to send to the server
-e, --expect=STRING String to expect in server response -W, --wait=INTEGER Seconds to wait between sending string and polling for response
-w, --warning=DOUBLE Response time to result in warning status (seconds)
-c, --critical=DOUBLE Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-v Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_procs

Check the number of currently running processes and generates WARNING or CRITICAL states if the process count is outside the specified threshold ranges. The process count can be filtered by process owner, parent process PID, current state (e.g., 'Z'), or may be the total number of running processes

Usage:

check_procs -w <range> -c <range> [-s state] [-p ppid] [-u user] [-a argument-array] [-C command]
check_procs --version
check_procs --help

Required Arguments:

-w, --warning=RANGE generate warning state if process count is outside this range
-c, --critical=RANGE generate critical state if process count is outside this range

Optional Filters:

-s, --state=STATUSFLAGS Only scan for processes that have, in the output of `ps`, one or more of the status flags you specify (for example R, Z, S, RS,RSZDT, plus others based on the output of your 'ps' command).
-p, --ppid=PPID Only scan for children of the parent process ID indicated.
-u, --user=USER Only scan for proceses with user name or ID indicated.
-a, --argument-array=STRING Only scan for ARGS that match up to the length of the given STRING
-C, --command=COMMAND Only scan for exact matches to the named COMMAND.

RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If specified 'max:min', a warning status will be generated if the count is inside the specified range

Top

check_real

This plugin tests the REAL service on the specified host.

Usage:

check_real -H host [-e expect] [-p port] [-w warn] [-c crit] [-t timeout] [-v]
check_real --help
check_real --version

Options:

-H, --hostname=STRING or IPADDRESS Check this server on the indicated host
-I, --IPaddress=STRING or IPADDRESS Check server at this host address
-p, --port=INTEGER Make connection on the indicated port (default: 554)
-u, --url=STRING Connect to this url
-e, --expect=STRING String to expect in first line of server response (default: RTSP/1.)
-w, --warning=INTEGER Seconds necessary to result in a warning status
-c, --critical=INTEGER Seconds necessary to result in a critical status
-t, --timeout=INTEGER Seconds before connection attempt times out (default: 10)
-v, --verbose Print extra information (command-line use only)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_rpc

Check if a rpc service is registered and running using rpcinfo -H host -C rpc_command

Usage:

check_rpc -H host -C rpc_command [-p port] [-c program_version] [-u|-t] [-v]

Options:

check_rpc [-h | --help]
check_rpc [-V | --version]

<host> The server providing the rpc service
<rpc_command> The program name (or number).
<program_version> The version you want to check for (one or more)
Should prevent checks of unknown versions being syslogged
e.g. 2,3,6 to check v2, v3, and v6
[-u | -t] Test UDP or TCP
[-v] Verbose
[-v -v] Verbose - will print supported programs and numbers

Top

check_sensors

This plugin checks hardware status using the lm_sensors package.

Top

check_smtp

This plugin test the SMTP service on the specified host.

Usage:

check_smtp -H host [-e expect] [-p port] [-f from addr] [-w warn] [-c crit] [-t timeout] [-v]
check_smtp --help
check_smtp --version

Options:

-H, --hostname=STRING or IPADDRESS Check server on the indicated host
-p, --port=INTEGER Make connection on the indicated port (default: 25)
-e, --expect=STRING String to expect in first line of server response (default: 220)
-f, --from=STRING from address to include in MAIL command (default NULL, Exchange2000 requires one)
-w, --warning=INTEGER Seconds necessary to result in a warning status
-c, --critical=INTEGER Seconds necessary to result in a critical status
-t, --timeout=INTEGER Seconds before connection attempt times out (default: 10)
-v, --verbose Print extra information (command-line use only)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_ssh

Usage:

check_ssh -t [timeout] -p [port] <host>
check_ssh -V prints version info
check_ssh -h prints more detailed help
by default, port is 22

Top

check_swap

This plugin will check all of the swap partitions and return an error if the the avalable swap space is less than specified.

Usage:

check_swap -w <used_percentage>% -c <used_percentage>%
check_swap -w <bytes_free> -c <bytes_free>
check_swap (-V|--version)
check_swap (-h|--help)

Options:

-w, --warning=INTEGER Exit with WARNING status if less than INTEGER bytes of swap space are free
-w, --warning=PERCENT% Exit with WARNING status if more than PERCENT of swap space has been used
-c, --critical=INTEGER Exit with CRITICAL status if less than INTEGER bytes of swap space are free
-c, --critical=PERCENT% Exit with CRITCAL status if more than PERCENT of swap space has been used
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_tcp

This plugin tests TCP connections with the specified host.

Usage:

check_tcp -H host -p port [-w warn_time] [-c crit_time] [-s send] [-e expect] [-W wait] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric
address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-s, --send=STRING String to send to the server
-e, --expect=STRING String to expect in server response -W, --wait=INTEGER Seconds to wait between sending string and polling for response
-w, --warning=DOUBLE Response time to result in warning status (seconds)
-c, --critical=DOUBLE Response time to result in critical status (seconds)
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-v Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_time

Check time on the specified host.

Usage:

check_time -H <host_address> [-p port] [-w variance] [-c variance] [-W connect_time] [-C connect_time] [-t timeout]
check_time (-h | --help) for detailed help
check_time (-V | --version) for version information

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric
address if possible to bypass DNS lookup).
-w, --warning-variance=INTEGER Time difference (sec.) necessary to result in a warning status
-c, --critical-variance=INTEGER Time difference (sec.) necessary to result in a critical status
-W, --warning-connect=INTEGER Response time (sec.) necessary to result in warning status
-C, --critical-connect=INTEGER Response time (sec.) necessary to result in critical status
-t, --timeout=INTEGER Seconds before connection times out (default: 10)
-p, --port=INTEGER Port number (default: 37)
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_udp

This plugin tests an UDP connection with the specified host.

Usage:

check_udp -H <host_address> [-p port] [-w warn_time] [-c crit_time] [-e expect] [-s send] [-t to_sec] [-v]

Options:

-H, --hostname=ADDRESS Host name argument for servers using host headers (use numeric
address if possible to bypass DNS lookup).
-p, --port=INTEGER Port number
-e, --expect=STRING <optional> String to expect in first line of server response
-s, --send=STRING <optional> String to send to the server when initiating the connection
-w, --warning=INTEGER <optional> Response time to result in warning status (seconds)
-c, --critical=INTEGER <optional> Response time to result in critical status (seconds)
-t, --timeout=INTEGER <optional> Seconds before connection times out (default: 10)
-v, --verbose <optional> Show details for command-line debugging (do not use with nagios server)
-h, --help Print detailed help screen and exit
-V, --version Print version information and exit

Top

check_ups

This plugin tests the UPS service on the specified host. Network UPS Tools from www.networkupstools.org must be running for this plugin to work.

Usage:

check_ups -H host -u ups [-p port] [-v variable] [-w warn_value] [-c crit_value] [-to to_sec] [-T]

Options:

-h, --help
Print detailed help screen
-V, --version
Print version information
--extra-opts=[section][@file]
Read options from an ini file. See
https://www.monitoring-plugins.org/doc/extra-opts.html
for usage and examples.
-H, --hostname=ADDRESS
Host name, IP Address, or unix socket (must be an absolute path)
-p, --port=INTEGER
Port number (default: 3493)
-u, --ups=STRING
Name of UPS
-T, --temperature
Output of temperatures in Celsius
-v, --variable=STRING
Valid values for STRING are LINE, TEMP, BATTPCT or LOADPCT
-w, --warning=DOUBLE
Response time to result in warning status (seconds)
-c, --critical=DOUBLE
Response time to result in critical status (seconds)
-t, --timeout=INTEGER
Seconds before connection times out (default: 10)

This plugin attempts to determine the status of a UPS (Uninterruptible Power Supply) on a local or remote host. If the UPS is online or calibrating, the plugin will return an OK state. If the battery is on it will return a WARNING state. If the UPS is off or has a low battery the plugin will return a CRITICAL state.

Notes:
You may also specify a variable to check (such as temperature, utility voltage, battery load, etc.) as well as warning and critical thresholds for the value of that variable. If the remote host has multiple UPS that are being monitored you will have to use the --ups option to specify which UPS to check.

This plugin requires that the UPSD daemon distributed with Russell Kroll's Network UPS Tools be installed on the remote host. If you do not have the package installed on your system, you can download it from http://www.networkupstools.org

Top

check_users

This plugin checks the number of users currently logged in on the local system and generates an error if the number exceeds the thresholds specified.

Usage:

check_users -w <users> -c <users>

Options:

-w, --warning=INTEGER Set WARNING status if more than INTEGER users are logged in
-c, --critical=INTEGER Set CRITICAL status if more than INTEGER users are logged in
-h, --help Print detailed help screen
-V, --version Print version information

Top

check_vsz

This plugin checks the image size of a running program and returns an error if the number is above either of the thresholds given.

Usage:

check_vsz -w <wsize> -c <csize> [-C command]
check_vsz --help
check_vsz --version

Options:

-h, --help Print detailed help
-V, --version Print version numbers and license information
-w, --warning=INTEGER Program image size necessary to cause a WARNING state
-c, --critical=INTEGER Program image size necessary to cause a CRITICAL state
-C, --command=STRING Program to search for [optional]

Top

check_wave

Usage:

check_wave -H <host> [-w <warn>] [-c <crit>]

<warn> = Signal strength at which a warning message will be generated.
<crit> = Signal strength at which a critical message will be generated.




                     **************************************************


 
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Wednesday, 13 April 2016

How to install nagios-4.43 in Ubuntu 18.04 LTS, 16.04 LTS, and 14.04 LTS and Debian systems

Step 01 : Install the required packages

Make sure you have installed the following packages on your Ubuntu system before continuing.
Apache 2
PHP
GCC compiler and development libraries
GD development libraries

If you did not install then please run the following commands:

sudo apt-get update
sudo apt-get install wget build-essential unzip openssl libssl-dev
sudo apt-get install apache2 php libapache2-mod-php php-gd libgd-dev
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Step 02 Create Account Information for nagios user

Create a new nagios user account and give it a password.
sudo adduser nagios

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.

sudo groupadd nagcmd or /usr/sbin/groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Step 03 Download and install Nagios core service

Create a directory for storing the downloads.

mkdir ~/downloads
cd ~/downloads

Download the source code for both Nagios core by following commands.

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz
tar xzf nagios-4.4.3.tar.gz

After extracting cd to nagios-4.4.3 directory and install using configure and make command.
cd nagios-4.4.3

sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-config
sudo make install-commandmode
sudo make install-exfoliation

Now copy event handlers scripts under libexec directory. These binaries provides multiple events triggers for your Nagios web interface.
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
Step 04: Setup Apache with Authentication

create an Apache configuration file for your Nagios server as below:

sudo vi /etc/apache2/conf-available/nagios.conf
Paste the following content in nagios.cfg and save
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"


  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Restricted Area"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd.users
  Require valid-user


Alias /nagios "/usr/local/nagios/share"


  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Restricted Area"
  AuthType Basic
  AuthUserFile /usr/local/nagios/etc/htpasswd.users
  Require valid-user

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you will need it later.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now enable Apache configuration and restart Apache service to make the new settings take effect.

sudo a2enconf nagios
sudo a2enmod cgi rewrite
sudo service apache2 restart (or) /etc/init.d/apache2 reload

Step 5 – Installing Nagios Plugins

Download and extract the Nagios source code from tar as following.
tar -zxvf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1

sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
sudo make
sudo make install

Step 06: Verify settings

Use the Nagios commands to verify the Nagios installation and configuration setting.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You should get following output at end.
Total Warnings: 0
Total Errors: 0

Start nagios service
service nagios start

Also configure Nagios to auto start on system boot.
sudo systemctl enable nagios

Step 7 – Access Nagios Web Interface

Enter the following url into the browser , it will ask to enter username and password. In this configuration we have username as nagiosadmin and password also as nagios admin.
http://localhost/nagios/
or
http://Ip_addreess_of_nagios_server/nagios/
Step 8 Customize Configuration

Sample configuration files have now been installed in its default location /usr/local/nagios/etc directory. Before procceding ahead edit the /usr/local/nagios/etc/objects/contacts.cfg file to place your email address.
Email address should be associated with nagiosadmin contact definition on which you would like to receive email alerts.

vi /usr/local/nagios/etc/objects/contacts.cfg






Step 9 Other Modifications


If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.

sudo apt-get install mailx
sudo apt-get install postfix

You'll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change any '/bin/mail' references to '/usr/bin/mail'. Once you do that you'll need to restart Nagios to make the configuration changes live.

sudo /etc/init.d/nagios restart
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges

Tuesday, 12 April 2016

Nagios Questions and Answers

Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges
1). What is Nagios Core ?

Nagios is an Open Source system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better.

Nagios Core was originally designed to run under Linux, although it should work under most other unices as well.

Some of the main features of Nagios Core include:
  • Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
  • Monitoring of host resources (processor load, disk usage, etc.)
  • Simple plugin design that allows users to easily develop their own service checks
  • Parallelized service checks
  • Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
  • Contact notifications when service or host problems occur and get resolved (via email,sms, pager, or user-defined method)
  • Ability to define event handlers to be run during service or host events for proactive problem resolution
  • Automatic log file rotation
  • Support for implementing redundant monitoring hosts
  • Optional web interface for viewing current network status, notification and problem history, log file, etc.
2) What are the system requirements to install Nagios core ?

It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. If you want CGI included with Nagios core , you may need to install following software :
  • A web server (preferrably Apache)
  • Thomas Boutell's gd library required by the statusmap and trends CGIs

3) What are the main Nagios configurations files and its locations ?

The default location of Nagios main configurations file is "/usr/local/nagios/etc/" in my case it is "/etc/nagios/"
1.Resource File : It is used to store sensitive information like username,passwords with out making them available to the CGIs.
Default path: /usr/local/nagios/etc/resource.cfg

2.Object Definition Files: It is the location were you define all you want to monitor and how you want to monitor. It is used to Define hosts,services, hostgroups, contacts, contact groups, commands, etc
Default Path: /usr/local/nagios/etc/objects/

3.CGI Configuration File  : The CGI configuration file contains a number of directives that affect the operation of the CGIs. It also contains a reference the main configuration file, so the CGIs know how you've configured Nagios and where your object definitions are stored.
Default Path: /usr/local/nagios/sbin/


4) Explain Ngaios files and its location?

The main configuration file is usually named nagios.cfg and located in the /usr/local/nagios/etc/ directory default. You can find the following entries of directives into nagios.cfg file.

Here is the default nagios.cfg files

Object Configuration Files: This directive is used to specify an object configuration file containing object definitions that Nagios should use for monitoring.

cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg

Object Configuration Directory: This directive is used to specify a directory which contains object configuration files that Nagios should use for monitoring.

cfg_dir=/usr/local/nagios/etc/commands
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/hosts

Object Cache File:This directive is used to specify a file in which a cached copy of object definitions should be stored.
object_cache_file=/usr/local/nagios/var/objects.cache

Precached Object File: Line Number 83
precached_object_file=/usr/local/nagios/var/objects.precache

This is used to specify an optional resource file that can contain $USERn$ macro definitions. $USERn$ macros are useful for storing usernames, passwords, and items commonly used in command definitions.

Temp File: temp_path=/tmp
This is a directory that Nagios can use as scratch space for creating temporary files used during the monitoring process. You should run tmpwatch, or a similiar utility, on this directory occasionally to delete files older than 24 hours.

Status File:  Line Number 106
status_file=/usr/local/nagios/var/status.dat

This is the file that Nagios uses to store the current status, comment, and downtime information. This file is used by the CGIs so that current monitoring status can be reported via a web interface. The CGIs must have read access to this file in order to function properly. This file is deleted every time Nagios stops and recreated when it starts.

Log Archive Path:  Line Number 267
log_archive_path=/usr/local/nagios/var/archives/

This is the directory where Nagios should place log files that have been rotated. This option is ignored if you choose to not use the log rotation functionality.

External Command File:
command_file=/usr/local/nagios/var/rw/nagios.cmd

This is the file that Nagios will check for external commands to process. The command CGI writes commands to this file. The external command file is implemented as a named pipe (FIFO), which is created when Nagios starts and removed when it shuts down. If the file exists when Nagios starts, the Nagios process will terminate with an error message. Always keep read only permission to submit the commands from authorized users only.

Lock File :  lock_file=/tmp/nagios.lock

This option specifies the location of the lock file that Nagios should create when it runs as a daemon (when started with the -d command line argument). This file contains the process id (PID) number of the running Nagios process.

State Retention File:
state_retention_file=/usr/local/nagios/var/retention.dat

This is the file that Nagios will use for storing status, downtime, and comment information before it shuts down. When Nagios is restarted it will use the information stored in this file for setting the initial states of services and hosts before it starts monitoring anything. In order to make Nagios retain state information between program restarts, you must enable the retain_state_information option.

Check Result Path :
check_result_path=/var/spool/nagios/checkresults

This options determines which directory Nagios will use to temporarily store host and service check results before they are processed.

Host Performance Data File : 
host_perfdata_file=/usr/local/nagios/var/host-perfdata.da

This option allows you to specify a file to which host performance data will be written after every host check. Data will be written to the performance file as specified by the host_perfdata_file_template option. Performance data is only written to this file if the process_performance_data option is enabled globally and if the process_perf_data directive in the host definition is enabled.

Service Performance Data File:
service_perfdata_file=/usr/local/nagios/var/service-perfdata.dat

This option allows you to specify a file to which service performance data will be written after every service check. Data will be written to the performance file as specified by the service_perfdata_file_template option. Performance data is only written to this file if the process_performance_data option is enabled globally and if the process_perf_data directive in the service definition is enabled

Debug File :
debug_file=/usr/local/nagios/var/nagios.debug

This option determines where Nagios should write debugging information. What (if any) information is written is determined by the debug_level and debug_verbosity options. You can have Nagios automatically rotate the debug file when it reaches a certain size by using the max_debug_file_size option.

Nagios log file :
  log_file=/usr/local/nagios/var/nagios.log[ Default location ]
  or log_file=/var/log/nagios/nagios.log [ My custom location ]

This is the main log file where service and host events are logged for historical purposes.  This should be the first option specified in the config file.

5. Nagios administrator is adding 100+ clients in monitoring but he don’t want to add every .cfg file entry in nagios.cfg file he want to enable a directory path. How can he configure directory for all configuration files?
He can able to achieve the above scenario by adding the directory path in nagios.cfg file, in line number 52 we have to add below line.

cfg_dir=/usr/local/nagios/etc/objects/monitor

6. Explain Host and Service Check Execution Option?

This option determines whether or not Nagios will execute Host/service checks when it initially (re)starts. If this option is disabled, Nagios will not actively execute any service checks and will remain in a sort of “sleep” mode. This option is most often used when configuring backup monitoring servers or when setting up a distributed monitoring environment.

Note: If you have state retention enabled, Nagios will ignore this setting when it (re)starts and use the last known setting for this option (as stored in the state retention file), unless you disable the use_retained_program_state option. If you want to change this option when state retention is active (and the use_retained_program_state is enabled), you’ll have to use the appropriate external command or change it via the web interface.

Values are as follows:
0 = Don’t execute host/service checks
1 = Execute host/service checks (default)

7. Explain active and Passive check in Nagios?
 
Nagios will monitor host and services in two ways actively and passively. Active checks are the most common method for monitoring hosts and services. The main features of actives checks are as following:
A. Active checks:
  • Active checks are run on a regularly scheduled basis
  • Active checks are initiated by the check logic in the Nagios daemon.
  • Active checks are initiated by the Nagios process
When Nagios needs to check the status of a host or service it will execute a plugin and pass it information about what needs to be checked. The plugin will then check the operational state of the host or service and report the results back to the Nagios daemon. Nagios will process the results of the host or service check and take appropriate action as necessary (e.g. send notifications, run event handlers, etc).

Active check are executed At regular intervals, as defined by the check_interval and retry_interval options in your host and service definitions

On-demand as needed.Regularly scheduled checks occur at intervals equaling either the check_interval or the retry_interval in your host or service definitions, depending on what type of state the host or service is in. If a host or service is in a HARD state, it will be actively checked at intervals equal to the check_interval option. If it is in a SOFT state, it will be checked at intervals equal to the retry_interval option.

On-demand checks are performed whenever Nagios sees a need to obtain the latest status information
about a particular host or service. For example, when Nagios is determining the reach ability of a host, it will often perform on-demand checks of parent and child hosts to accurately determine the status of a particular network segment. On-demand checks also occur in the predictive dependency check logic in order to ensure Nagios has the most accurate status information.

B.Passive checks:
They key features of passive checks are as follows:
  • Passive checks are initiated and performed external applications/processes
  • Passive check results are submitted to Nagios for processing
The major difference between active and passive checks is that active checks are initiated and performed by Nagios, while passive checks are performed by external applications.

Passive checks are useful for monitoring services that are:
  • Asynchronous in nature and cannot be monitored effectively by polling their status on a regularly scheduled basis.
  • Located behind a firewall and cannot be checked actively from the monitoring host
Examples of asynchronous services that lend themselves to being monitored passively include SNMP traps and security alerts. You never know how many (if any) traps or alerts you’ll receive in a given time frame, so it’s not feasible to just monitor their status every few minutes.Passive checks are also used when configuring distributed or redundant monitoring installations.

Here’s how passive checks work in more detail…
  • An external application checks the status of a host or service.
  • The external application writes the results of the check to the external command file.
  • The next time Nagios reads the external command file it will place the results of all passive checks into a queue for later processing. The same queue that is used for storing results from active checks is also used to store the results from passive checks.
  • Nagios will periodically execute a check result reaper event and scan the check result queue. Each service check result that is found in the queue is processed in the same manner – regardless of whether the check was active or passive. Nagios may send out notifications, log alerts, etc. depending on the check result information.
Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges
8. How to verify Nagios configuration ?

In order to verify your configuration, run Nagios with the -v command line option like so:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
 
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.

9. What Are Objects?

Objects are all the elements that are involved in the monitoring and notification logic.
Types of objects include:
Services  are one of the central objects in the monitoring logic. Services are associated with hosts Attributes of a host (CPU load, disk usage, uptime, etc.)

Service Groups :are groups of one or more services. Service groups can make it easier to (1) view the status of related services in the Nagios web interface and (2) simplify your configuration through the use of object tricks.

Hosts  are one of the central objects in the monitoring logic.Hosts are usually physical devices on your network (servers, workstations, routers, switches, printers, etc).

Host Groups  are groups of one or more hosts. Host groups can make it easier to (1) view the status of related hosts in the Nagios web interface and (2) simplify your configuration through the use of object tricks

Contacts Conact information of  people involved in the notification process
Contact Groups are groups of one or more contacts. Contact groups can make it easier to define all the people who get notified when certain host or service problems occur.

Commands are used to tell Nagios what programs, scripts, etc. it should execute to perform ,Host and service checks and when Notifications should send etc.

Time Periods are are used to control ,When hosts and services can be monitored
Notification Escalations Use for escalating the the notification

10. What Are Plugins?

Plugins are compiled executable s or scripts (Perl scripts, shell scripts, etc.) that can be run from a command line to check the status or a host or service. Nagios uses the results from plugins to determine the current status of hosts and services on your network.
Nagios will execute a plugin whenever there is a need to check the status of a service or host. The plugin does something (notice the very general term) to perform the check and then simply returns the results to Nagios. Nagios will process the results that it receives from the plugin and take any necessary actions (running event handlers, sending out notifications, etc).

11. How Do I Use Plugin X?

We have to download the plugins from nagios exchange https://exchange.nagios.org/. Then check the nagios plugin by running manually.
Most all plugins will display basic usage information when you execute them using ‘-h’ or ‘–help’ on the command line.

12. How to generate Performance graphs ?

In Nagios Core there is no inbuilt option to generate the performance graphs, We have to install pnp4nagios and add hosts and services URL’s in defination files.

13. What is the difference between NagiosXI and Nagios Core ?

NagiosXI is a Paid version and Nagios core is a free version.

NagiosXI includes lot of features which we can modify using web interface. Nagios Core default not include all the features we have to implement by installing plugins.

14. When Does Nagios Check For External Commands?


At regular intervals specified by the command_check_interval option in the main configuration file
Immediately after event handlers are executed. This is in addition to the regular cycle of external command checks and is done to provide immediate action if an event handler submits commands to Nagios.
External commands that are written to the command file have the following format
[time] command_id;command_arguments
where time is the time (in time_t format) that the external application submitted the external command to the command file. The values for the command_id and command_arguments arguments will depend on what command is being submitted to Nagios.

15. Explain Nagios State Types?

The current state of monitored services and hosts is determined by two components:
The status of the service or host (i.e. OK, WARNING, UP, DOWN, etc.)

There are two state types in Nagios – SOFT states and HARD states. These state types are a crucial part of the monitoring logic, as they are used to determine when event handlers are executed and when notifications are initially sent out.

A.Soft States:
When a service or host check results in a non-OK or non-UP state and the service check has not yet been (re)checked the number of times specified by the max_check_attempts directive in the service or host definition. This is called a soft error.
When a service or host recovers from a soft error. This is considered a soft recovery.
The following things occur when hosts or services experience SOFT state changes:
The SOFT state is logged. Event handlers are executed to handle the SOFT state. SOFT states are only logged if you enabled the log_service_retries or log_host_retries options in your main configuration file.
The only important thing that really happens during a soft state is the execution of event handlers. Using event handlers can be particularly useful if you want to try and proactively fix a problem before it turns into a HARD state. The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of “SOFT” when event handlers are executed, which allows your event handler scripts to know when they should take corrective action.

B.Hard states :
occur for hosts and services in the following situations:
When a host or service check results in a non-UP or non-OK state and it has been (re)checked the number of times specified by the max_check_attempts
option in the host or service definition. This is a hard error state.
When a host or service transitions from one hard error state to another error state (e.g. WARNING to CRITICAL).
When a service check results in a non-OK state and its corresponding host is either DOWN or UNREACHABLE.
When a host or service recovers from a hard error state. This is considered to be a hard recovery.
When a passive host check is received. Passive host checks are treated as HARD unless the passive_host_checks_are_soft option is enabled.
The following things occur when hosts or services experience HARD state changes:
The HARD state is logged.
Event handlers are executed to handle the HARD state.
Contacts are notifified of the host or service problem or recovery.
The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of “HARD” when event handlers are executed, which allows your event handler scripts to know when they should take corrective action.

16. What is State Stalking?

Stalking is purely for logging purposes.When stalking is enabled for a particular host or service, Nagios will watch that host or service very carefully and log any changes it sees in the output of check results. As you’ll see, it can be very helpful to you in later analysis of the log files. Under normal circumstances, the result of a host or service check is only logged if the host or service has changed state since it was last checked. There are a few exceptions to this, but for the most part, that’s the rule.
If you enable stalking for one or more states of a particular host or service, Nagios will log the results of the host or service check if the output from the check differs from the output from the previous check.

17. Explain how  Flap Detection works in Nagios?

Ans:  Nagios supports optional detection of hosts and services that are “flapping”. Flapping occurs when a service or host changes state too frequently, resulting in a storm of problem and recovery notifications. Flapping can be indicative of configuration problems (i.e. thresholds set too low), troublesome services, or real network problems.

Whenever Nagios checks the status of a host or service, it will check to see if it has started or stopped flapping. It does this by:

Storing the results of the last 21 checks of the host or ser vice
Analyzing the historical check results and determine where state changes/transitions occur
Using the state transitions to determine a percent state change value (a measure of change) for the host or service
Comparing the percent state change value against low and high flapping thresholds
A host or service is determined to have started flapping when its percent state change first exceeds a high flapping threshold.
A host or service is determined to have stopped flapping when its percent state goes below a low flapping threshold (assuming that is was previously flapping).
The historical service check results are examined to determine where state changes/transitions occur. State changes occur when an archived state is different from the archived state that immediately precedes it chronologically. Since we keep the results of the last 21 service checks in the array, there is a possibility of having at most 20 state changes. In this example there are 7 state changes, indicated by blue arrows in the image above.
The flap detection logic uses the state changes to determine an overall percent state change for the service. This is a measure of volatility/change for the service. Services that never change state will have a 0% state change value, while services that change state each time they’re checked will have 100% state change. Most services will have a percent state change somewhere in between.

18. Explain Distributed Monitoring ?

Nagios can be configured to support distributed monitoring of network services and resources.
When setting up a distributed monitoring environment with Nagios, there are differences in the way the central and distributed servers are configured.

The function of a distributed server is to actively perform checks all the services you define for a “cluster” of hosts. it basically just mean an arbitrary group of hosts on your network. Depending on your network layout, you may have several clusters at one physical location, or each cluster may be separated by a WAN, its own firewall, etc. There is one distributed server that runs Nagios and monitors the services on the hosts in each cluster. A distributed server is usually a bare-bones installation of Nagios. It doesn’t have to have the web interface installed, send out notifications, run event handler scripts, or do anything other than execute service checks if you don’t want it to.
The purpose of the central server is to simply listen for service check results from one or more distributed servers. Even though services are occasionally actively checked from the central server, the active checks are only performed in dire circumstances,

19. What is NRPE?

The Nagios Remote Plugin Executor addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor “local” resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent like NRPE must be installed on the remote Linux/Unix machines.

The NRPE addon consists of two pieces:
– The check_nrpe plugin, which resides on the local monitoring machine
– The NRPE daemon, which runs on the remote Linux/Unix machine

When Nagios needs to monitor a resource of service from a remote Linux/Unix machine:

– Nagios will execute the check_nrpe plugin and tell it what service needs to be checked
– The check_nrpe plugin contacts the NRPE daemon on the remote host over an (optionally) SSL-protected connection
– The NRPE daemon runs the appropriate Nagios plugin to check the service or resource
– The results from the service check are passed from the NRPE daemon back to the check_nrpe plugin, which then returns the check results to the Nagios process.

20.What is NDOUTILS ?

The NDOUTILS addon is designed to store all configuration and event data from Nagios in a database. Storing information from Nagios in a database will allow for quicker retrieval and processing of that data and will help serve as a foundation for the development of a new PHP-based web interface in Nagios 4.1.
MySQL databases are currently supported by the addon and PostgreSQL support is in development.

The NDOUTILS addon was designed to work for users who have:
– Single Nagios installations
– Multiple standalone or “vanilla” Nagios installations
– Multiple Nagios installations in distributed, redundant, and/or failover environments.

Each Nagios process, whether it is a standalone monitoring server or part of a distributed, redundant, or failover monitoring setup, is referred to as an “instance”. In order to maintain the integrity of stored data, each Nagios instance must be labeled with a unique identifier or name.

21. What are the components that make up the NDO utilities ?

There are four main components that make up the NDO utilities:

NDOMOD Event Broker Module : The NDO utilities includes a Nagios event broker module (NDOMOD.O) that exports data from the Nagios daemon.Once the module has been loaded by the Nagios daemon, itcan access all of the data and logic present in the running Nagios process.The NDOMOD module has been designed to export configuration data, as well as information about various run time events that occur in the monitoring process, from the Nagios daemon. The module can send this data to a standard file, a Unix domain socket, or a TCP socket.
LOG2NDO Utility : The LOG2NDO utility has been designed to allow you to import historical Nagios and NetSaint log files into a database via the NDO2DB daemon (described later). The utility works by sending historical log file data to a standard file, a Unix domain socket, or a TCP socket in a format the NDO2DB daemon understands. The NDO2DB daemon can then be used to process that output and store the historical log file  information in a database.
FILE2SOCK Utility :  The FILE2SOCK utility is quite simple. Its reads input from a standard file (or STDIN) and writes all of that data to either a Unix domain socket or TCP socket. The data that is read is not processed in any way before it is sent to the socket.
NDO2DB Daemon:   The NDO2DB utility is designed to take the data output from the NDOMOD and LOG2NDO components and store it in a MySQL or PostgreSQL database.When it starts, the NDO2DB daemon creates either a TCP or Unix domain socket and waits for clients to connect. NDO2DB can run either as a standalone, multi-process daemon or under INETD (if using a TCP socket). Multiple clients can connect to the NDO2DB daemon’s socket and transmit data simultaneously. A separate NDO2DB process is spawned to handle each new client that connects. Data is read from each client and stored in a user-specified database for later retrieval and processing.

22. What are the Operating Systems we can monitor using Nagios?

Any Operating System We can monitor using Nagios, OS should support to install Nagios Clinet either SNMP.

23. What is database is used by Nagios to store collected status data?


Ans: Nagios core will use default RRD database format to store status data





                             *****************************************

Need personal assistance on Nagios? Please contact me at

immukesh72@gmail.com

at very nominal charges
Related Posts Plugin for WordPress, Blogger...