nagios: Added support for SMS contacts.

This commit is contained in:
Timo Mkinen 2013-05-29 09:36:03 +03:00
parent fa1867ad40
commit ed60033f31
2 changed files with 54 additions and 0 deletions

View file

@ -287,6 +287,18 @@ define command{
}
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /bin/echo "Nagios: $HOSTNAME$ is $HOSTSTATE$ '$HOSTOUTPUT$'" > "/var/spool/smsd/OUT$CONTACTPAGER$.txt"
}
# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /bin/echo "Nagios: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ '$SERVICEOUTPUT$'" > "/var/spool/smsd/OUT$CONTACTPAGER$.txt"
}
# 'check_esxi_hardware' command definition
define command{
command_name check_esxi_hardware

View file

@ -411,6 +411,48 @@ define nagios::contact::pushover($token, $group=["all"],
}
# Define nagios sms contact.
#
# This requires gammu::smsd running on same host.
#
# === Parameters
#
# $name:
# Descriptive name for contact.
# $number:
# Phone number where to send messages.
# $group:
# List of contact groups. Defaults to "all".
#
define nagios::contact::sms($number, $group=["all"],
$confdir=$nagios::common::confdir) {
$contactgroups = inline_template('<%= @group.join(",") -%>')
file { "${confdir}/contact_sms_${name}.cfg":
ensure => present,
mode => "0640",
owner => "root",
group => "nagios",
before => Nagios_Contact["sms-${name}"],
require => File["/etc/nagios/conf.d"],
}
nagios_contact { "sms-${name}":
target => "${confdir}/contact_sms_${name}.cfg",
contactgroups => $contactgroups,
host_notification_commands => "notify-host-by-sms",
host_notification_options => "d,u",
host_notification_period => "24x7",
service_notification_commands => "notify-service-by-sms",
service_notification_options => "c",
service_notification_period => "24x7",
pager => $number,
notify => Service["nagios"],
}
}
# Define nagios target host.
#
# === Parameters