Simple reconfiguration of config a lot of work in Nagios?


#1

Hi, look at my nagios.cfg.
I had to work 20 minutes to add 1 freelancer in Nagios and for him to receive e-mail messages at steve@gmail.com.

Can anybody tell me if this was the fastest method? He looks at problems on server06.
I created a new service-group and contact-group for server06 and him and had to remove server06 from other groups.
See “#Toevoeging voor freelancer m.b.t. investigatie server06”.

I want to know if there’s a method that would’ve been faster. What do you guys need to do if you wish to add a contact for a specific server?

  1. Create new contact groups
  2. Create new server group
  3. Create new service group
  4. Remove server06 from server and service groups
  5. Create new services specifically for server06 connected with contactgroup/servicegroup

It shouldn’t be so much work if I only want this:

[quote]###############################################################################

LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE

Last Modified: 11-27-2006

NOTE: This config file is intended to servce as an extremely simple

example of how you can create your object configuration file(s).

###############################################################################

###############################################################################
###############################################################################

TIME PERIODS

###############################################################################
###############################################################################

This defines a timeperiod where all times are valid for checks,

notifications, etc. The classic “24x7” support nightmare. :slight_smile:

define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}

‘workhours’ timeperiod definition

define timeperiod{
timeperiod_name workhours
alias “Normal” Working Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}

‘nonworkhours’ timeperiod definition

define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}

‘none’ timeperiod definition

define timeperiod{
timeperiod_name none
alias No Time Is A Good Time
}

###############################################################################
###############################################################################

COMMANDS

###############################################################################
###############################################################################

NOTE: Sample command definitions can now be found in the sample commands.cfg

file

###############################################################################
###############################################################################

CONTACTS

###############################################################################
###############################################################################

In this simple config file, a single contact will receive all alerts.

This assumes that you have an account (or email alias) called

“nagios-admin” on the local host.

define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email ujjain@gmail.co.uk
}

define contact{
contact_name freelancer-coutts
alias Nagios Admin voor server06
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email steve@gmail.com
}

define contact{
contact_name mobiel_ujjain
alias ujjain
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
pager x
email ujjain.pager@randomdomain.co.uk
}

define contact{
contact_name mobiel_johndoe
alias johndoe
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
pager x
}

define contact{
contact_name mobiel_robot
alias Contactpersonen van R
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
pager x
}

define contact{
contact_name mobiel_marco
alias M
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,c,r
host_notification_options d,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
pager x

    }

###############################################################################
###############################################################################

CONTACT GROUPS

###############################################################################
###############################################################################

We only have one contact in this simple configuration file, so there is

no need to create more than one contact group.

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin, mobiel_ujjain, mobiel_johndoe
}

define contactgroup{
contactgroup_name admins_nosms
alias Nagios No SMS Administrators
members nagios-admin
}

define contactgroup{
contactgroup_name invest_06
alias Nagios Investigation for Server06
members nagios-admin,freelancer-coutts
}

define contactgroup{
contactgroup_name kort
alias Henk Administrators
members mobiel_robot
}

define contactgroup{
contactgroup_name marco
alias M Administrators
members mobiel_marco
}

###############################################################################
###############################################################################

HOSTS

###############################################################################
###############################################################################

Generic host definition template - This is NOT a real host, just a template!

define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

Linux host definition template - This is NOT a real host, just a template!

define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
max_check_attempts 5 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period 24x7 ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120m ; Resend notification every 2 hours
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

define host{
name kort-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period 24x7 ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120m ; Resend notification every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups kort ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLA$
}

define host{
name marco-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period 24x7 ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notification every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups marco ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLA$
}

Since this is a simple configuration file, we only monitor one host - the

local host (this machine).

define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name server01
alias server01.randomdomain.co.uk
parents switch01
address 192.168.1.10
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name server05
alias server05.randomdomain.co.uk
parents switch01
address 192.168.1.12
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name server06
alias server06.randomdomain.co.uk
parents switch01
address 192.168.1.14
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name dns1
alias dns1.randomdomain.co.uk
parents switch01

    address                 192.168.1.7
    }

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name dns2
alias dns2.randomdomain.co.uk
address 93.12.12.15
}

define host {
use marco-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name srv01
alias srv01.randomdomain.co.uk
parents switch01
address 192.168.1.20
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name srv05
alias srv05.randomdomain.co.uk
parents switch01
address 192.168.1.39
}

define host {
use kort-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name srv06
alias srv06.randomdomain.co.uk
parents switch01
address 192.168.1.38
}

define host {
use kort-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name srv09
alias srv09.randomdomain.co.uk
address 192.168.1.57
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name srv13
alias srv13.randomdomain.co.uk
parents switch01
address 192.168.1.65
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that aredefined
; in (or inherited by) the linux-server host template definition.
host_name switch01
alias switch01.randomdomain.co.uk
address 192.168.1.2
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that aredefined
; in (or inherited by) the linux-server host template definition.
host_name space
alias space
address 83.10.10.5
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name barracuda01
alias barracuda01.randomdomain.co.uk
parents switch01
address 192.168.1.5
}

define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name backup01
alias backup01.randomdomain.co.uk
parents switch01
address 192.168.1.6
}

###############################################################################
###############################################################################

HOST GROUPS

###############################################################################
###############################################################################

We only have one host in our simple config file, so there is no need to

create more than one hostgroup.

define hostgroup{
hostgroup_name localhost
alias Test Servers
members localhost,rackspace
}

define hostgroup{
hostgroup_name appliances
alias Emperor Appliances
members switch01,dns1,dns2,barracuda01,backup01
}

define hostgroup{
hostgroup_name Emperor
alias Emperor Shared Servers
members server01,server05,server06
}

define hostgroup{
hostgroup_name clients
alias Clients Managed Servers
members srv01,srv05
}

define hostgroup{
hostgroup_name unm_clients
alias Clients Unmanaged Servers
members srv06,srv13
}

define hostgroup{
hostgroup_name sms
alias SMS Notified Servers
members srv09
}

###############################################################################
###############################################################################

SERVICES

###############################################################################
###############################################################################

Generic service definition template - This is NOT a real service, just a template!

define service{
name generic-service ; The ‘name’ of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness’
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

Local service definition template - This is NOT a real service, just a template!

define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 2 ; Check the service every 5 minutes under normal conditions
retry_check_interval 3 ; Re-check the service every minute until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

define service{
name nosms-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 2 ; Check the service every 5 minutes under normal conditions
retry_check_interval 3 ; Re-check the service every minute until a hard state can be determined
contact_groups admins_nosms ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

define service{
name invest06-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 2 ; Check the service every 5 minutes under normal conditions
retry_check_interval 3 ; Re-check the service every minute until a hard state can be determined
contact_groups invest_06 ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

define service{
name sms-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 2 ; Check the service every 5 minutes under normal conditions
retry_check_interval 3 ; Re-check the service every minute until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

define service{
name kort-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 5 ; Re-check the service every minute until a hard state can be determined
contact_groups kort ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

Define a service to “ping” the local machine

define service{
use local-service ; Name of service template to use
host_name localhost,server01,server05,srv01,srv05,srv06,srv13,srv09,switch01,dns1,dns2,barracuda01,backup01
service_description PING
check_command check_ping!1000.0,20%!1500.0,60%
}

Define a service to check the disk space of the root partition

on the local machine. Warning if < 20% free, critical if

< 10% free space on partition.

define service{
use local-service ; Name of service template to use
host_name localhost
service_description Root Partition
check_command check_local_disk!20%!10%!/
}

Define a service to check the number of currently logged in

users on the local machine. Warning if > 20 users, critical

if > 50 users.

define service{
use local-service ; Name of service template to use
host_name localhost
service_description Current Users
check_command check_local_users!20!50
}

Define a service to check the number of currently running procs

on the local machine. Warning if > 250 processes, critical if

> 400 users.

define service{
use local-service ; Name of service template to use
host_name localhost
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}

Define a service to check the load on the local machine.

define service{
use nosms-service ; Name of service template to use
host_name localhost
service_description Current Load
check_command check_local_load!15.0,14.0,13.0!30.0,26.0,24.0
}

define service{
use nosms-service ; Name of service template to use
host_name localhost
service_description Current SWAP
check_command check_swap!50%!25%
}

define service{
use nosms-service ; Name of service template to use
host_name server01,server05
service_description SWAP usage
check_command check_nrpe!check_swap!50%!25%
}

define service{
use local-service ; Name of service template to use
host_name localhost,rackspace,server01,server05,srv01,srv05,srv06
service_description HTTP
check_command check_http
}

define service{
use local-service ; Name of service template to use
host_name server01,server05,srv01,srv05,srv06
service_description FTP
check_command check_ftp
}

define service{
use kort-service ; Name of service template to use
host_name srv09
service_description KHTTP
check_command check_http
}

define service{
use local-service ; Name of service template to use
host_name server05
service_description MySQL
check_command check_mysql!check_mysql!nagios1
}

define service{
use sms-service ; Name of service template to use
host_name server01,server05
service_description Server Load
check_command check_nrpe!check_load!15.0,14.0,13.0!20.0,12.0,8.0
}

#Toevoeging voor freelancer m.b.t. investigatie server06

define service{
use invest06-service ; Name of service template to use
host_name server06
service_description PING
check_command check_ping!1000.0,20%!1500.0,60%
}

define service{
use local-service ; Name of service template to use
host_name server06
service_description MySQL
check_command check_mysql!check_mysql!nagios1
}

define service{
use invest06-service ; Name of service template to use
host_name server06
service_description SWAP usage
check_command check_nrpe!check_swap!50%!25%
}

define service{
use invest06-service ; Name of service template to use
host_name server06
service_description HTTP
check_command check_http
}

define service{
use invest06-service ; Name of service template to use
host_name server06
service_description FTP
check_command check_ftp
}

define service{
use invest06-service ; Name of service template to use
host_name server06
service_description Server Load
check_command check_nrpe!check_load!15.0,14.0,13.0!20.0,12.0,8.0[/quote]


#2

first thing i’d remove public email and IP addresses from the configs you publish on the internet :slight_smile: