Service checks in hosts.cfg?
Thomas Guyot-Sionnest
dermoth at aei.ca
Sat Feb 24 15:33:45 CET 2007
On 24/02/07 08:21 AM, chiel wrote:
> Hello,
>
> I have been working with Nagios for a couple of days now and I'm just
> beginning to understand the principle of the config (.cfg) files.
> I understand that you create a service (let say Ping) and put all your
> hosts (or hostgroups) in there that you want to check with ping.
>
> But is it also possible to define these checks in the hosts.cfg file??
> So I would become something like this:
>
> define host{
> host_name server1
> alias Linux server 1
> address 10.0.0.1
> contact_groups network_team
> checks check_ping, check_load, check_snmp <--- This line
> }
>
>
> This would make more sense to me, because if you got over a 100 hosts to
> check, and you don't want to do it with a hostgroup, then all these host
> most be in the services.cfg on one line (do I got this right?).
Well, first keep in mind that any object configuration file is only a
configuration file. The name is irrelevant. If you're building a huge
host you should use cfg_dir so that you can config files simple by
dropinf one in cfg_dir on one of its subdirectory.
The best way to achieve your result is using templates. So let's say you
have, among hostgroups, web1 web2 and web3 that all needs HTTP checks.
You can create a template (I'm not looking at the doc so syntax may be
wrong...):
define service{
name web_service
hostgroup_name web1 web2 web3
[optionally other options]
use generic_service
# ^^^ Only if you have a generic_service template with default options.
register 0
}
Then to define the HTTP check all you have to do is:
define service {
service_description HTTP Check
host_name <Any additional host that you want to check>
check_command check_http!args
use web_service
}
If you build everything over whell-organized templates your config will
be much smaller. Here's the comparisos of number of lines between
objects config lines and the fully parsed objects cache on one of my hosts:
# find /path/to/nagios/cfg -name \*.cfg|xargs cat|egrep -v '^.*?#' \
|egrep -v '^[[:space:]]*$'|wc -l
1755
# cat /path/to/var/objects.cache|egrep -v '^.*?#' \
|egrep -v '^[[:space:]]*$'|wc -l
29970
Thomas
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list