Difference between revisions of "Nagios"

Jump to navigation Jump to search
1,807 bytes removed ,  09:01, 24 October 2011
m
m (Another draft)
Line 30: Line 30:




define service{
== Create SNMP Checks ==
use generic-service ; Inherit default values from a template
hostgroup_name zimbra-servers
service_description IMAP
check_command check_imap
}
 
define service{
use generic-service ; Inherit default values from a template
hostgroup_name zimbra-servers
service_description SMTP
check_command check_smtp
}
 
# check that MySQL services are up
define service {
        hostgroup_name                  mysql-servers
        service_description            MySQL
        check_command                  check_mysql
        use                            generic-service
        notification_interval          0 ; set > 0 if you want to be renotified
}
 
 
define command{
        command_name    check_http_auth
        command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -I '$HOSTADDRESS$' -a '$ARG1$'q
        }
 
 
define service{
        use                            generic-service        ; Name of service template to use
        host_name                      localhost
        service_description            HTTP
        check_command                  check_http_auth!user:pass  ; Enter actual user/pass
        }
 
 
define hostextinfo{
        hostgroup_name  debian-servers
        notes            Debian GNU/Linux servers
#      notes_url        http://webserver.localhost.localdomain/hostinfo.pl?host=netware1
        icon_image      base/debian.png
        icon_image_alt  Debian GNU/Linux
        vrml_image      debian.png
        statusmap_image  base/debian.gd2
        }
 
define hostextinfo{
        hostgroup_name  ubuntu-servers
        notes            Ubuntu servers
        icon_image      base/ubuntu.png
        icon_image_alt  Ubuntu
        vrml_image      ubuntu.png
        statusmap_image  base/ubuntu.gd2
        }
 
 
=== Create SNMP Checks ===
Everything here creates various checks for my '''QNAP NAS''', which I've used as an example.
Everything here creates various checks for my '''QNAP NAS''', which I've used as an example.


==== Define OID's to Poll ====
=== Define OID's to Poll ===
Before you start you need to know what SNMP OID's you want to poll, and what they're values should be.  For common devices and metrics you can often get by with a Google search or two, but it doesn't take much for you to need to get a bit more involved.
Before you start you need to know what SNMP OID's you want to poll, and what they're values should be.  For common devices and metrics you can often get by with a Google search or two, but it doesn't take much for you to need to get a bit more involved.


Line 114: Line 56:




==== Create Commands ====
=== Create Commands ===
Each type of check needs a command defined for it, which where the SNMP OID that will be checked is defined.  Commands are are not specific to a particular host, so could be run against any system for which the check would be valid.  There is some flexibility in that if you've certain checks that will be similar (eg checks for status of disk 1, disk 2 etc) then you can add arguments to the checks that can be defined later on.
Each type of check needs a command defined for it, which where the SNMP OID that will be checked is defined.  Commands are are not specific to a particular host, so could be run against any system for which the check would be valid.  There is some flexibility in that if you've certain checks that will be similar (eg checks for status of disk 1, disk 2 etc) then you can add arguments to the checks that can be defined later on.


Line 164: Line 106:




==== Create Services ====
== Create Services ==
Services are used to define a generic check command within the bounds of a specific service.  So for example, you could define two separate disk space checks, using the same command definition, but with different alerting thresholds depending on your requirements.
Services are used to define a generic check command within the bounds of a specific service.  So for example, you could define two separate disk space checks, using the same command definition, but with different alerting thresholds depending on your requirements.


Services need to be defined with...
Services need to be defined with...
* <code> hostgroup_name </code> - The hostgroup defines which servers will have the service checks applied to it.  For a host to be checked for the service it needs to be a member of the hostgroup, see [[#Create Hostgroup]] for further info.
* <code> hostgroup_name </code> - The hostgroup defines which servers will have the service checks applied to it.  For a host to be checked for the service it needs to be a member of the hostgroup, see [[#Create Hostgroup|Create Hostgroup]] for further info.
* <code> service_description </code> - A name for the service check, this is what is displayed in the Service field on the Nagios display
* <code> service_description </code> - A name for the service check, this is what is displayed in the Service field on the Nagios display
* <code> check_command </code> - The command (and its parameters, if any) to perform the check.
* <code> check_command </code> - The command (and its parameters, if any) to perform the check.
Line 212: Line 154:




==== Create Hostgroup ====
== Create Hostgroup ==
The hostgroup definition allows you to group one or more hosts together, in order to have service checks run against them.  So in the above I created services that would apply to hosts in the <code>qnap-nas</code> hostgroup. I can then add my NAS server to this hostgroup in order for it to be monitored (hostgroup definitions are normally found in <code>/etc/nagios3/conf.d/hostgroups_nagios2.cfg</code>
The hostgroup definition allows you to group one or more hosts together, in order to have service checks run against them.  So in the above I created services that would apply to hosts in the <code>qnap-nas</code> hostgroup. I can then add my NAS server to this hostgroup in order for it to be monitored (hostgroup definitions are normally found in <code>/etc/nagios3/conf.d/hostgroups_nagios2.cfg</code>


Navigation menu