Open source softwares - Nagios

Back to Course

Lesson Description

Lession - #1545 Nagios Checks and States

Once the host and services are configured on Nagios, checks are used to see if the hosts and services are working as they're supposed to or not. Let us see an illustration to perform checks on host − Consider that you have put your host definitions insidehost1.cfg file in/ usr/ local/ nagios/ etc/ objects directory.   ```plaintext cd usr/ local/ nagios/ etc/ objects gedithost1.cfg ```   This is how your host definitions look presently −   ```plaintext define host{ host1 address10.0.0.1 ``` Now let us addcheck\_interval directive. This directive is used to perform scheduled checks of the hosts for the number you set; by default it's in minutes. Using the definition below, checks on the host will be performed after every 3 minutes.   ```plaintext define host{ host1 address10.0.0.1 3 ``` In Nagios, 2 types of checks are performed on hosts and services − Active Checks Passive Checks   #### Active Checks Active checks are initiated by Nagios process and also run on a regular scheduled basis. The check logic inside Nagios process starts the Active check. To monitor hosts and services running on remote machines, Nagios executes plugins and tells what information to collect. Plugin also gets executed on the remote machine where is collects the required information and sends also back to Nagios daemon. Depending on the status received on hosts and services, appropriate action is taken.   These are executed on regular intervals, as defined bycheck\_interval andretry\_interval.   Passive checks are performed by external processes and the results are given back to Nagios for processing. Passive checks work as explained then − An external operation checks the status on hosts services and writes the result to External Command File. When Nagios daemon reads external command file, it reads and sends all the passive checks in the queue to process them later. Periodically when these checks are processed, notifications or alerts are sent depending on the information in check result.   #### Passive check Thus, the difference between active and passive check is that active checks are run by Nagios and passive checks are run by external applications.  These checks are useful when you can not monitor hosts services on a regular basis.  Nagios stores the status of the hosts and services it's monitoring to determine if they're working properly or not. There would be numerous cases when the failures will be randomly and they're temporary; hence Nagios uses states to check the current status of a host or service.   #### There are two types of states − * Soft state * Hard state #### Soft state * When a host or service is down for a very short duration of time and its status isn't known or different from previous one, also soft states are used. The host or the services will be tested again and again till the time the status is permanent.   #### Hard State * Whenmax\_check\_attempts is executed and status of the host or service is still not OK, also hard state is used. Nagios executes event handlers to handle hard states. ```plaintext