Service checks in hosts.cfg?
Hugo van der Kooij
hvdkooij at vanderkooij.org
Sat Feb 24 15:06:05 CET 2007
On Sat, 24 Feb 2007, chiel wrote:
> 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.
First off. Print the manual in full or whatever allows you to read it
cover to cover. But go over the full manual at least once from cover to
cover.
> 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 is rather completely wrong. I think you need to reverse your way of
thinking.
Think of hosts as machines. You can add a check on the machine but it is
just to see if the hardware is there. For this most people use the default
check but in some cases you need to deviate. That is where the checks on a
host end.
You care about service provided. You only check the host to make sure they
remain active because you need them to run the service. In this regard you
can think of CPU and memory usages as services on which other services
rely. (If your CPU is 0% idle your MySQL service is likely to be running
poorly.)
So you need to add a 100 hosts if you have a 100 machines. But read the
part on templates very very carefully as it will save a lot of time and
work.
Then you define service which may run on some hosts, mosts hosts or all
hosts.
So define a service named POSTFIX for example and use the check_smtp check
to test it.
If in doubt go over the manual a few times and study the mailinglist
archives.
For example my 4 backup DNS servers:
# 4 backup servers:
define hostgroup {
hostgroup_name mydyndns-org
alias mydyndns.org servers
members ns2.mydyndns.org
members ns3.mydyndns.org
members ns4.mydyndns.org
members ns5.mydyndns.org
}
# Template for these hosts
define host {
name mydyndns-template
register 0
check_command check-host-alive
max_check_attempts 3
active_checks_enabled 1
passive_checks_enabled 0
check_period 24x7
retain_status_information 1
retain_nonstatus_information 1
notification_interval 60
notification_period 24x7
notification_options d,u,r,f
notifications_enabled 1
}
# The 4 machines:
define host{
use mydyndns-template
host_name ns2.mydyndns.org
alias DNS server 2
address 204.13.249.82
parents transip-switch
hostgroups mydyndns-org
contact_groups mydyndns-org
}
define host{
use mydyndns-template
host_name ns3.mydyndns.org
alias DNS server 3
address 204.13.250.82
# address 63.209.15.211
parents transip-switch
hostgroups mydyndns-org
contact_groups mydyndns-org
}
define host{
use mydyndns-template
host_name ns4.mydyndns.org
alias DNS server 4
address 213.155.150.206
parents transip-switch
hostgroups mydyndns-org
contact_groups mydyndns-org
}
define host{
use mydyndns-template
host_name ns5.mydyndns.org
alias DNS server 5
address 63.208.196.93
parents transip-switch
hostgroups mydyndns-org
contact_groups mydyndns-org
}
# Now group the services on the 4 hosts:
define servicegroup {
servicegroup_name mydyndns-org
alias mydyndns.org servers
members ns2.mydyndns.org, *
members ns3.mydyndns.org, *
members ns4.mydyndns.org, *
members ns5.mydyndns.org, *
}
# Service template:
define service {
name mydyndns-template
register 0
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
active_checks_enabled 1
passive_checks_enabled 1
check_period 24x7
retain_status_information 1
retain_nonstatus_information 1
notification_interval 60
notification_period 24x7
notification_options w,u,c,r,f
notifications_enabled 1
}
# Add services to these hosts:
define service{
use mydyndns-template
host_name ns2.mydyndns.org,ns3.mydyndns.org,ns4.mydyndns.org,ns5.mydyndns.org
service_description DNS
check_command check_dig!1!5!www.vanderkooij.org
contact_groups mydyndns-org
}
define service{
use mydyndns-template
host_name ns2.mydyndns.org,ns3.mydyndns.org,ns4.mydyndns.org,ns5.mydyndns.org
service_description PING
check_command check_ping!300,20%!1000,60%
contact_groups mydyndns-org
}
......
Hugo.
--
hvdkooij at vanderkooij.org http://hvdkooij.xs4all.nl/
This message is using 100% recycled electrons.
-------------------------------------------------------------------------
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