Difference between revisions of "Nagios"

Jump to navigation Jump to search
3,807 bytes added ,  08:31, 30 August 2012
Added "Check Tuning" and Meta
m (→‎Introduction: Reworded)
(Added "Check Tuning" and Meta)
Line 16: Line 16:
! Path  !! Description
! Path  !! Description
|-
|-
| <code> /etc/nagios3/conf.d </code>  || Config files
| <code> /etc/nagios3/conf.d </code>  || Config files - anything in here is parsed as config, filenames are for your convenience and are irrelevant to Nagios
|-
|-
| <code> /etc/nagios-plugins/config </code>  || Plugin commands
| <code> /etc/nagios-plugins/config </code>  || Plugin commands
Line 26: Line 26:
| <code> service nagios3 restart </code>  || Restart service (reloads config - will fail if config is invalid!)
| <code> service nagios3 restart </code>  || Restart service (reloads config - will fail if config is invalid!)
|}
|}


== Create SNMP Checks ==
== Create SNMP Checks ==
Line 171: Line 170:
         alias                  NAS
         alias                  NAS
         address                192.168.1.200
         address                192.168.1.200
        }
== Check Tuning ==
It's unlikely that you really want everything checked every 5 mins, 24 hours a day.  Some services might get a bit flaky in the middle of the night when there's maintenance tasks running, or don't warrant being checked so frequently.
In general its better to make such changes to generic templates, that can then be applied to one or more service checks.  You can then edit changes centrally, rather than going round and updating services.  Templates can be daisy chained so that subsequent templates override or add to config (see http://nagios.sourceforge.net/docs/3_0/objectinheritance.html for further info).
=== Check Frequency ===
For services that don't need to be checked as often as every 5 mins, create a new ''service template'' for the check internal, and apply to the appropriate ''services''.
Create a new service template for the check interval in <code>/etc/nagios3/conf.d/generic-service_nagios2.cfg</code>, See example below, which changes the check interval to every 30 mins.  Note that the template uses the normal <code>generic-service</code>, and then overrides the <code>normal_check_interval</code>.
# Service template for low frequency checks
define service {
        name                            low-freq-svc-template
        use                            generic-service
        normal_check_interval          30
        }
Update the service config for any services that you want to have the new check interval.  Change the <code>use</code> config line to use the new template name, for example...
define service{
        use                    low-freq-svc-template
        host_name              wib1.domain.com
        service_description    Wibble Sys
        check_command          check_wib_svc
        }
=== Maintenance Windows / Hours of Service ===
For services that don't need to be checked 24x7, create a new ''time period'', and a new ''service template'' for that time period, and apply to the appropriate ''services''.
Define a new time period in <code>/etc/nagios3/conf.d/timeperiods_nagios2.cfg</code>, example excludes 02:00 - 03:00 hrs Sunday, and 02:30 - 03:00 hrs all other days (to not check/notify on a particular day, simply leave that day out of the config)...
define timeperiod{
        timeperiod_name wibblehours
        alias          Wibble Hours
        sunday          00:00-02:00,03:00-24:00
        monday          00:00-02:30,03:00-24:00
        tuesday        00:00-02:30,03:00-24:00
        wednesday      00:00-02:30,03:00-24:00
        thursday        00:00-02:30,03:00-24:00
        friday          00:00-02:30,03:00-24:00
        saturday        00:00-02:30,03:00-24:00
        }
Then create a new service template for the time-period in <code>/etc/nagios3/conf.d/generic-service_nagios2.cfg</code>, See example below.  Note that the template uses the normal <code>generic-service</code>, and then overrides the <code>check_period</code> and <code>notification_period</code> settings.
# Service template for Wibble system services
define service {
        name                            wibble-svc-template
        use                            generic-service
        check_period                    wibblehours
        notification_period            wibblehours
        }
Finally, update the service config for any services that you want to have the new time period.  Change the <code>use</code> config line to use the new template name, for example...
define service{
        use                    wibble-svc-template
        host_name              wib1.domain.com
        service_description    Wibble Sys
        check_command          check_wib_svc
         }
         }


Navigation menu