Hi,
I am new to nagios. I just want to check whether the url is up and running like google.com.
Could not understand the relation between define_host { } and define_service {} and in which .cfg we need to put those entries.
Can some one give me a sample code ?
Monitor the URL like google.com
Re: Monitor the URL like google.com
The difference between a host and a service can be a bit tricky, but basically a host is just an IP address or FQDN, whereas a service is what you want to check on that host. So you might have a single google.com host, and then a few services like ping, URL check, DNS lookup, etc. attached to that host. The host itself needs to have a check defined, so in this sense a host acts like both a host and a single service - usually this check will be a ping, so there is no need to create a second ping service if this is the case.
The config files you put these in does not matter, but I usually try to keep them grouped together. I will have one hosts.cfg and then for each host I will have a .cfg file for its services named after the host. So it would look like:
in your example. The config files can be named whatever you want, as long as your nagios.cfg knows where to find them.
The config files you put these in does not matter, but I usually try to keep them grouped together. I will have one hosts.cfg and then for each host I will have a .cfg file for its services named after the host. So it would look like:
Code: Select all
hosts.cfg
google.com.cfg
Former Nagios employee
Re: Monitor the URL like google.com
To add to what @tmcdonald mentioned, see here for examples on how you can configure a host / service -
Host - https://assets.nagios.com/downloads/nag ... .html#host
Service - https://assets.nagios.com/downloads/nag ... ml#service
The important part about your nagios.cfg is how you include the configuration files as @tmcdonald mentioned is right here -
Host - https://assets.nagios.com/downloads/nag ... .html#host
Service - https://assets.nagios.com/downloads/nag ... ml#service
The important part about your nagios.cfg is how you include the configuration files as @tmcdonald mentioned is right here -
File Inclusions, Cascading Configs, and the 'include_file' Directive
An object definition file can include other object definition files with the use of the include_file=<file_name> and include_dir=<directory_name> directives. The former includes the single file specified, the latter will process all files ending in the .cfg extension in the directory specified. These directives may be repeated to include multiple files/directories. The directives are not allowed within the actual definition of an object, and should appear before, after, or in between any object definitions.
They are closely related to the cfg_file= and cfg_dir= directives in the main configuration file. These directives may be chained; e.g. an object definition file included from the main configuration file with a cfg_file= or cfg_dir= directive can use include_file= or include_dir= to include another object definition file, which in turn can also use include_file= or include_dir= to include yet another object definition file, and so on.
This can be useful when certain objects are dynamic but need to pull in a number of configs or when certain configs files grow to an unmanageable size.
Former Nagios Employee