Nagios: Exclude Specific Services
LINK >>> https://urllie.com/2tuVa8
Nagios: How to Exclude Specific Services from Monitoring
Nagios is a popular open source software that monitors network devices and services. It can alert you when something goes wrong or when a service needs attention. However, sometimes you may want to exclude specific services from monitoring, either temporarily or permanently. For example, you may want to exclude a service that is under maintenance, or a service that is not relevant for your network. In this article, we will show you how to exclude specific services from Nagios monitoring using two methods: using host groups and using service dependencies.
Method 1: Using Host Groups
One way to exclude specific services from Nagios monitoring is to use host groups. Host groups are collections of hosts that share some common characteristics, such as location, function, or operating system. You can define host groups in the Nagios configuration files and assign services to them. Then, you can use the hostgroup_name directive in the service definition to specify which host group the service belongs to. For example, suppose you have a host group called linux-servers that contains all your Linux servers. You can define a service called SSH that monitors the SSH daemon on these servers using the following syntax:
define service{
use generic-service
hostgroup_name linux-servers
service_description SSH
check_command check_ssh
}
Now, suppose you want to exclude the SSH service from monitoring on one of the Linux servers, say server1. You can do this by creating a new host group that contains all the Linux servers except server1, and assign the SSH service to this new host group. For example, you can create a host group called linux-servers-except-server1 using the following syntax:
define hostgroup{
hostgroup_name linux-servers-except-server1
alias Linux Servers Except Server1
members server2,server3,server4,... # list all the Linux servers except server1
}
Then, you can modify the SSH service definition to use this new host group instead of the original one:
define service{
use generic-service
hostgroup_name linux-servers-except-server1 # use the new host group
service_description SSH
check_command check_ssh
}
This way, Nagios will monitor the SSH service on all the Linux servers except server1. You can use this method to exclude any number of services from any number of hosts by creating appropriate host groups and assigning services to them.
Method 2: Using Service Dependencies
Another way to exclude specific services from Nagios monitoring is to use service dependencies. Service dependencies are logical relationships between services that indicate whether the status of one service affects the status of another. You can define service dependencies in the Nagios configuration files and use them to control how Nagios handles notifications and checks for dependent services. For example, suppose you have a service called PING that monitors the network connectivity of a host using ping command. You can define a service dependency that states that if the PING service is down, then Nagios should not check or notify any other services on that host. This way, you can avoid getting multiple alerts for services that depend on network connectivity. You can define such a service dependency using the following syntax:
define servicedependency{
dependent_host_name *
dependent_service_description *
host_name server1 # specify the host name
service_description PING # specify the master service
execution_failure_criteria n # do not check dependent services if PING is down
notification_failure_criteria n # do not notify dependent services if PING is down
}
This defines a service dependency that applies to all services on server1, except for the PING service itself. The * symbol means any value. The n symbol means none of the following states: o = OK, w = WARNING, u = UNKNOWN, c = CRITICAL. This means that if the PING service is in any state other than OK (i.e., down), then ec8f644aee