Old Stuf‎ > ‎Linux‎ > ‎nagios‎ > ‎

Nagios Introduction

Mat nagios is het mogelijk om om servers en services te controleren.
 
De sofware kun je hier downloaden
 
Hier onder wat handige weetjes

Introduction

This documentation attempts to explain how you can exploit the (somewhat) hidden features of template-based object definitions to save your sanity. How so, you ask? Several types of objects allow you to specify multiple host names and/or hostgroup names in definitions, allowing you to "copy" the object defintion to multiple hosts or services. I'll cover each type of object that supports these features seperately. For starters, the object types which support this time-saving feature are as follows:

Object types that are not listed above (i.e. timeperiods, commands, etc.) do not support the features I'm about to describe.

Regular Expression Matching

The examples I give below use "standard" matching of object names. If you wish, you can enable regular expression matching for object names by using the use_regexp_matching config option. By default, regular expression matching will only be used in object names that contain the * and ? wildcard characters. If you want regular expression matching to be used on all object names (regardless of whether or not they contain the * and ? wildcard characters), enable the use_true_regexp_matching config option.

Regular expressions can be used in any of the fields used in the examples below (host names, hostgroup names, service names, and servicegroup names).

NOTE: Be careful when enabling regular expression matching - you may have to change your config file, since some directives that you might not want to be interpreted as a regular expression just might be! Any problems should become evident once you verify your configuration.

Service Definitions

Multiple Hosts: If you want to create identical services that are assigned to multiple hosts, you can specify multiple hosts in the host_name directive as follows:

	define service{
		host_name		HOST1,HOST2,HOST3,...,HOSTN
		service_description	SOMESERVICE
		other service directives ...
		}

The definition above would create a service called SOMESERVICE on hosts HOST1 through HOSTN. All the instances of the SOMESERVICE service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).

All Hosts In Multiple Hostgroups: If you want to create identical services that are assigned to all hosts in one or more hostgroups, you can do so by creating a single service definition. How? The hostgroup_name directive allows you to specify the name of one or more hostgroups that the service should be created for:

	define service{
		hostgroup_name		HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN
		service_description	SOMESERVICE
		other service directives ...
		}

The definition above would create a service called SOMESERVICE on all hosts that are members of hostgroups HOSTGROUP1 through HOSTGROUPN. All the instances of the SOMESERVICE service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).

All Hosts: If you want to create identical services that are assigned to all hosts that are defined in your configuration files, you can use a wildcard in the host_name directive as follows:

	define service{
		host_name		*
		service_description	SOMESERVICE
		other service directives ...
		}

The definition above would create a service called SOMESERVICE on all hosts that are defined in your configuration files. All the instances of the SOMESERVICE service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).

Service Escalation Definitions

Multiple Hosts: If you want to create service escalations for services of the same name/description that are assigned to multiple hosts, you can specify multiple hosts in the host_name directive as follows:

	define serviceescalation{
		host_name		HOST1,HOST2,HOST3,...,HOSTN
		service_description	SOMESERVICE
		other escalation directives ...
		}

The definition above would create a service escalation for services called SOMESERVICE on hosts HOST1 through HOSTN. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Hosts In Multiple Hostgroups: If you want to create service escalations for services of the same name/description that are assigned to all hosts in in one or more hostgroups, you can do use the hostgroup_name directive as follows:

	define serviceescalation{
		hostgroup_name		HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN
		service_description	SOMESERVICE
		other escalation directives ...
		}

The definition above would create a service escalation for services called SOMESERVICE on all hosts that are members of hostgroups HOSTGROUP1 through HOSTGROUPN. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Hosts: If you want to create identical service escalations for services of the same name/description that are assigned to all hosts that are defined in your configuration files, you can use a wildcard in the host_name directive as follows:

	define serviceescalation{
		host_name		*
		service_description	SOMESERVICE
		other escalation directives ...
		}

The definition above would create a service escalation for all services called SOMESERVICE on all hosts that are defined in your configuration files. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Services On Same Host: If you want to create service escalations for all services assigned to a particular host, you can use a wildcard in the service_description directive as follows:

	define serviceescalation{
		host_name		HOST1
		service_description	*
		other escalation directives ...
		}

The definition above would create a service escalation for all services on host HOST1. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

If you feel like being particularly adventurous, you can specify a wildcard in both the host_name and service_description directives. Doing so would create a service escalation for all services that you've defined in your configuration files.

Multiple Services On Same Host: If you want to create service escalations for all multiple services assigned to a particular host, you can use a specify more than one service description in the service_description directive as follows:

	define serviceescalation{
		host_name		HOST1
		service_description	SERVICE1,SERVICE2,...,SERVICEN
		other escalation directives ...
		}

The definition above would create a service escalation for services SERVICE1 through SERVICEN on host HOST1. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Services In Multiple Servicegroups: If you want to create service escalations for all services that belong in one or more servicegroups, you can do use the servicegroup_name directive as follows:

	define serviceescalation{
		servicegroup_name		SERVICEGROUP1,SERVICEGROUP2,...,SERVICEGROUPN
		other escalation directives ...
		}

The definition above would create service escalations for all services that are members of servicegroups SERVICEGROUP1 through SERVICEGROUPN. All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

Service Dependency Definitions

Multiple Hosts: If you want to create service dependencies for services of the same name/description that are assigned to multiple hosts, you can specify multiple hosts in the host_name and or dependent_host_name directives as follows:

	define servicedependency{
		host_name			HOST1,HOST2
		service_description		SERVICE1
		dependent_host_name		HOST3,HOST4
		dependent_service_description	SERVICE2
		other dependency directives ...
		}

In the example above, service SERVICE2 on hosts HOST3 and HOST4 would be dependent on service SERVICE1 on hosts HOST1 and HOST2. All the instances of the service dependencies would be identical except for the host names (i.e. have the same notification failure criteria, etc.).

All Hosts In Multiple Hostgroups: If you want to create service dependencies for services of the same name/description that are assigned to all hosts in in one or more hostgroups, you can do use the hostgroup_name and/or dependent_hostgroup_name directives as follows:

	define servicedependency{
		hostgroup_name			HOSTGROUP1,HOSTGROUP2
		service_description		SERVICE1
		dependent_hostgroup_name	HOSTGROUP3,HOSTGROUP4
		dependent_service_description	SERVICE2
		other dependency directives ...
		}

In the example above, service SERVICE2 on all hosts in hostgroups HOSTGROUP3 and HOSTGROUP4 would be dependent on service SERVICE1 on all hosts in hostgroups HOSTGROUP1 and HOSTGROUP2. Assuming there were five hosts in each of the hostgroups, this definition would be equivalent to creating 100 single service dependency definitions! All the instances of the service dependency would be identical except for the host names (i.e. have the same notification failure criteria, etc.).

All Services On Same Host: If you want to create service dependencies for all services assigned to a particular host, you can use a wildcard in the service_description and/or dependent_service_description directives as follows:

	define servicedependency{
		host_name			HOST1
		service_description		*
		dependent_host_name		HOST2
		dependent_service_description	*
		other dependency directives ...
		}

In the example above, all services on host HOST2 would be dependent on all services on host HOST1. All the instances of the service dependencies would be identical (i.e. have the same notification failure criteria, etc.).

Multiple Services On Same Host: If you want to create service dependencies for multiple services assigned to a particular host, you can specify more than one service description in the service_description and/or dependent_service_description directives as follows:

	define servicedependency{
		host_name			HOST1
		service_description		SERVICE1,SERVICE2,...,SERVICEN
		dependent_host_name		HOST2
		dependent_service_description	SERVICE1,SERVICE2,...,SERVICEN
		other dependency directives ...
		}

All Services In Multiple Servicegroups: If you want to create service dependencies for all services that belong in one or more servicegroups, you can do use the servicegroup_name and/or dependent_servicegroup_name directive as follows:

	define servicedependency{
		servicegroup_name		SERVICEGROUP1,SERVICEGROUP2,...,SERVICEGROUPN
		dependent_servicegroup_name	SERVICEGROUP3,SERVICEGROUP4,...SERVICEGROUPN
		other escalation directives ...
		}

Host Escalation Definitions

Multiple Hosts: If you want to create host escalations for multiple hosts, you can specify multiple hosts in the host_name directive as follows:

	define hostescalation{
		host_name		HOST1,HOST2,HOST3,...,HOSTN
		other escalation directives ...
		}

The definition above would create a host escalation for hosts HOST1 through HOSTN. All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Hosts In Multiple Hostgroups: If you want to create host escalations for all hosts in in one or more hostgroups, you can do use the hostgroup_name directive as follows:

	define hostescalation{
		hostgroup_name		HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN
		other escalation directives ...
		}

The definition above would create a host escalation on all hosts that are members of hostgroups HOSTGROUP1 through HOSTGROUPN. All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

All Hosts: If you want to create identical host escalations for all hosts that are defined in your configuration files, you can use a wildcard in the host_name directive as follows:

	define hostescalation{
		host_name		*
		other escalation directives ...
		}

The definition above would create a hosts escalation for all hosts that are defined in your configuration files. All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).

Host Dependency Definitions

Multiple Hosts: If you want to create host dependencies for multiple hosts, you can specify multiple hosts in the host_name and/or dependent_host_name directives as follows:

	define hostdependency{
		host_name		HOST1,HOST2
		dependent_host_name	HOST3,HOST4,HOST5
		other dependency directives ...
		}

The definition above would be equivalent to creating six seperate host dependencies. In the example above, hosts HOST3, HOST4 and HOST5 would be dependent upon both HOST1 and HOST2. All the instances of the host dependencies would be identical except for the host names (i.e. have the same notification failure criteria, etc.).

All Hosts In Multiple Hostgroups: If you want to create host escalations for all hosts in in one or more hostgroups, you can do use the hostgroup_name and /or dependent_hostgroup_name directives as follows:

	define hostdependency{
		hostgroup_name			HOSTGROUP1,HOSTGROUP2
		dependent_hostgroup_name	HOSTGROUP3,HOSTGROUP4
		other dependency directives ...
		}

In the example above, all hosts in hostgroups HOSTGROUP3 and HOSTGROUP4 would be dependent on all hosts in hostgroups HOSTGROUP1 and HOSTGROUP2. All the instances of the host dependencies would be identical except for host names (i.e. have the same notification failure criteria, etc.).

Hostgroups

All Hosts: If you want to create a hostgroup that has all hosts that are defined in your configuration files as members, you can use a wildcard in the members directive as follows:

	define hostgroup{
		hostgroup_name		HOSTGROUP1
		members			*
		other hostgroup directives ...
		}

The definition above would create a hostgroup called HOSTGROUP1 that has all all hosts that are defined in your configuration files as members

bron: http://nagios.sourceforge.net/docs/2_0/templatetricks.html

Verifying Your Configuration

Every time you modify your configuration files, you should run a sanity check on them. It is important to do this before you (re)start Nagios, as Nagios will shut down if your configuration contains errors.

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. This is done so that one error does not cascade into multiple errors as the remainder of the configuration data is verified. If you get any error messages you'll need to go and edit your configuration files to remedy the problem. Warning messages can generally be safely ignored, since they are only recommendations and not requirements.

Once you've verified your configuration files and fixed any errors you can go ahead and (re)start Nagios.

bron: nagios helpfile

website controle

If you want it to connect and look for a specific piece of text then I use something like:-

check_command                   check_website!www.domain.com!Word_to_look_for

check commands.cfg includes:-
define command{
        command_name    check_website
        command_line    $USER1$/check_http -H $ARG1$ -I $HOSTADDRESS$ -s $ARG2$
        }

bron: http://www.experts-exchange.com/OS/Linux/Q_22547632.html

 
Comments