Yuvipanda has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/174780

Change subject: nagios_common: Split out notification_commands for 
shinken/icinga
......................................................................

nagios_common: Split out notification_commands for shinken/icinga

This reverts commit 69e893722c6b67ec53f44b47d8bd42ab47c9b1d4.

- They're different enough to cause problems, so separating them.
- Also use object inheritance for shinken contacts

Change-Id: I625e6c88b6c85205a3f5bdfa5bfcca6446920fcb
---
R modules/icinga/files/notification_commands.cfg
M modules/icinga/manifests/init.pp
D modules/nagios_common/manifests/notification_commands.pp
M modules/shinken/files/contacts.cfg
A modules/shinken/files/notification_commands.cfg
M modules/shinken/files/templates.cfg
M modules/shinken/manifests/server.pp
7 files changed, 48 insertions(+), 117 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/80/174780/1

diff --git a/modules/nagios_common/templates/notification_commands.cfg.erb 
b/modules/icinga/files/notification_commands.cfg
similarity index 76%
rename from modules/nagios_common/templates/notification_commands.cfg.erb
rename to modules/icinga/files/notification_commands.cfg
index ea2cf48..87872f9 100644
--- a/modules/nagios_common/templates/notification_commands.cfg.erb
+++ b/modules/icinga/files/notification_commands.cfg
@@ -16,7 +16,7 @@
 #                  used as a template for this definition (optional)
 # <objectname>   = object name of command definition, referenced by other
 #                  command definitions that use it as a template (optional)
-# <commandname>  = name of the command, as recognized/used by <%= @lover_name 
%>
+# <commandname>  = name of the command, as recognized/used by Icinga
 # <commandline>  = command line
 #
 
################################################################################
@@ -26,36 +26,36 @@
 # 'host-notify-by-email' command definition
 define command{
        command_name    host-notify-by-email
-       command_line    /usr/bin/printf "%b" "❤❤❤❤❤ <%= @lover_name %> 
❤❤❤❤❤\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: 
$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: 
$LONGDATETIME$\nLove, <%= @lover_name %>" | /usr/bin/mail -s "Host $HOSTSTATE$ 
alert for $HOSTNAME$!" $CONTACTEMAIL$
+       command_line    /usr/bin/printf "%b" "❤❤❤❤❤ Icinga 
❤❤❤❤❤\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: 
$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: 
$LONGDATETIME$\nLove, Icinga" | /usr/bin/mail -s "Host $HOSTSTATE$ alert for 
$HOSTNAME$!" $CONTACTEMAIL$
        }
 
 
 # 'host-notify-by-epager' command definition
 define command{
        command_name    host-notify-by-epager
-       command_line    /usr/bin/printf "%b" "Host '$HOSTALIAS$' is 
$HOSTSTATE$\nInfo: $HOSTOUTPUT$\nTime: $LONGDATETIME$ <3, <%= @lover_name %>" | 
/usr/bin/mail -s "$NOTIFICATIONTYPE$ alert - Host $HOSTNAME$ is $HOSTSTATE$" 
$CONTACTPAGER$
+       command_line    /usr/bin/printf "%b" "Host '$HOSTALIAS$' is 
$HOSTSTATE$\nInfo: $HOSTOUTPUT$\nTime: $LONGDATETIME$ <3, Icinga" | 
/usr/bin/mail -s "$NOTIFICATIONTYPE$ alert - Host $HOSTNAME$ is $HOSTSTATE$" 
$CONTACTPAGER$
        }
 
 # 'notify-by-email' command definition
 define command{
        command_name    notify-by-email
-       command_line    /usr/bin/printf "%b" "❤❤❤❤❤ <%= @lover_name %> 
❤❤❤❤❤\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: 
$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: 
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\nLove, <%= @lover_name 
%>" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ 
is $SERVICESTATE$ **" $CONTACTEMAIL$
+       command_line    /usr/bin/printf "%b" "❤❤❤❤❤ Icinga 
❤❤❤❤❤\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: 
$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: 
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\nLove, Icinga" | 
/usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is 
$SERVICESTATE$ **" $CONTACTEMAIL$
        }
 
 
 # 'notify-by-epager' command definition
 define command{
        command_name    notify-by-epager
-       command_line    /usr/bin/printf "%b" "Service: $SERVICEDESC$\nHost: 
$HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nInfo: 
$SERVICEOUTPUT$\nDate: $LONGDATETIME$ <3, <%= @lover_name %>" | /usr/bin/mail 
-s "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" 
$CONTACTPAGER$
+       command_line    /usr/bin/printf "%b" "Service: $SERVICEDESC$\nHost: 
$HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nInfo: 
$SERVICEOUTPUT$\nDate: $LONGDATETIME$ <3, Icinga" | /usr/bin/mail -s 
"$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$
        }
 
 define command{
        command_name    host-notify-by-sms-gateway
-       command_line    echo "Host $HOSTALIAS$ is $HOSTSTATE$\nInfo: 
$HOSTOUTPUT$\nTime: $LONGDATETIME$ <3, <%= @lover_name %>" | /usr/bin/mail -s 
"Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTADDRESS1$
+       command_line    echo "Host $HOSTALIAS$ is $HOSTSTATE$\nInfo: 
$HOSTOUTPUT$\nTime: $LONGDATETIME$ <3, Icinga" | /usr/bin/mail -s "Host 
$HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTADDRESS1$
        }
 define command{
        command_name    notify-by-sms-gateway
-       command_line    echo "$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$: 
$SERVICEOUTPUT$ $SERVICEACKAUTHOR$ $SERVICEACKCOMMENT$ at $LONGDATETIME$ <3, 
<%= @lover_name %>" | /usr/bin/mail -s "nagios" $CONTACTADDRESS1$
+       command_line    echo "$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$: 
$SERVICEOUTPUT$ $SERVICEACKAUTHOR$ $SERVICEACKCOMMENT$ at $LONGDATETIME$ <3, 
Icinga" | /usr/bin/mail -s "nagios" $CONTACTADDRESS1$
        }
 
 # global IRC output for operations
diff --git a/modules/icinga/manifests/init.pp b/modules/icinga/manifests/init.pp
index 7beb4b8..1c323c4 100644
--- a/modules/icinga/manifests/init.pp
+++ b/modules/icinga/manifests/init.pp
@@ -83,10 +83,18 @@
         notify  => Service['icinga'],
     }
 
+    file { "/etc/icinga/notification_commands.cfg":
+        ensure  => present,
+        source  => 'puppet:///modules/icinga/notification_commands.cfg',
+        owner   => 'icinga',
+        group   => 'icinga',
+        require => Package['icinga'],
+        notify  => Service['icinga'],
+    }
+
     class { [
       'nagios_common::user_macros',
       'nagios_common::timeperiods',
-      'nagios_common::notification_commands',
     ] :
         require => Package['icinga'],
         notify  => Service['icinga'],
diff --git a/modules/nagios_common/manifests/notification_commands.pp 
b/modules/nagios_common/manifests/notification_commands.pp
deleted file mode 100644
index dbb32bb..0000000
--- a/modules/nagios_common/manifests/notification_commands.pp
+++ /dev/null
@@ -1,42 +0,0 @@
-# = Class: nagios_common::notificationcommands
-# Notification commands, to notify people by email/sms
-#
-# [*ensure*]
-#   present or absent, to make the definition
-#   present or absent. Defaults to present
-#
-# [*config_dir*]
-#   The base directory to put configuration directory in.
-#   Defaults to '/etc/icinga/'
-#
-# [*owner*]
-#   The user which should own the check config files.
-#   Defaults to 'icinga'
-#
-# [*group*]
-#   The group which should own the check config files.
-#   Defaults to 'icinga'
-#
-# [*lover_name*]
-#   Name of thing that gives the recipient love when notifying
-#   them via email of bad things that have happened
-#
-# [*irc_dir_path*]
-#   Directory containing files that are used by ircecho to
-#   echo notifications to IRC
-#
-class nagios_common::notification_commands(
-    $ensure = present,
-    $config_dir = '/etc/icinga',
-    $owner = 'icinga',
-    $group = 'icinga',
-    $lover_name = 'Icinga',
-    $irc_dir_path = '/var/log/icinga',
-) {
-    file { "$config_dir/notification_commands.cfg":
-        ensure  => $ensure,
-        content => template('nagios_common/notification_commands.cfg.erb'),
-        owner   => $owner,
-        group   => $group,
-    }
-}
diff --git a/modules/shinken/files/contacts.cfg 
b/modules/shinken/files/contacts.cfg
index f39b287..64ae65d 100644
--- a/modules/shinken/files/contacts.cfg
+++ b/modules/shinken/files/contacts.cfg
@@ -7,14 +7,7 @@
     contact_name                        guest
     alias                               Guest Account
     email                               guest@guest
-    host_notifications_enabled          0
-    service_notifications_enabled       0
-    host_notification_period            none
-    service_notification_period         none
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
     password                            guest
 }
 
@@ -22,82 +15,40 @@
     contact_name                        yuvipanda
     alias                               Yuvi Panda
     email                               yuvipa...@wikimedia.org
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
 
 define contact {
     contact_name                        legoktm
     alias                               Lego KTM
     email                               lego...@wikimedia.org
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
 
 define contact {
     contact_name                        milimetric
     alias                               Dan Andreescu
     email                               dandree...@wikimedia.org
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
 
 define contact {
     contact_name                        greg_g
     alias                               Greg G
     email                               g...@wikimedia.org
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
 
 define contact {
     contact_name                        cmcmahon
     alias                               Chris McMahon
     email                               cmcma...@wikimedia.org
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
 
 define contact {
     contact_name                        amusso
     alias                               Antoine Musso
     email                               has...@free.fr
-    host_notifications_enabled          1
-    service_notifications_enabled       1
-    host_notification_period            24x7
-    service_notification_period         24x7
-    service_notification_commands       notify-by-email
-    host_notification_commands          notify-by-email
-    host_notification_options           d,u,r
-    service_notification_options        w,u,r,c
+    use                                 generic-contact
 }
diff --git a/modules/shinken/files/notification_commands.cfg 
b/modules/shinken/files/notification_commands.cfg
new file mode 100644
index 0000000..57b8599
--- /dev/null
+++ b/modules/shinken/files/notification_commands.cfg
@@ -0,0 +1,14 @@
+# Notification commands, copied and adapted from shinken's
+# default commands.cfg file
+
+## Notify Host by Email
+define command {
+    command_name    notify-host-by-email
+    command_line    /usr/bin/printf "%b" "Shinken 
Notification\n\nType:$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: 
$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $DATE$ 
$TIME$\n" | /usr/bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$" 
$CONTACTEMAIL$
+}
+
+## Notify Service by Email
+define command {
+    command_name    notify-service-by-email
+    command_line    /usr/bin/printf "%b" "Shinken Notification\n\nNotification 
Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: 
$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATE$ $TIME$\nAdditional 
Info : $SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - 
$HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
+}
diff --git a/modules/shinken/files/templates.cfg 
b/modules/shinken/files/templates.cfg
index 422e94e..7b7b08c 100644
--- a/modules/shinken/files/templates.cfg
+++ b/modules/shinken/files/templates.cfg
@@ -119,6 +119,6 @@
        host_notification_period        24x7
        service_notification_options    c,w,r
        host_notification_options       d,u,r,f,s
-       service_notification_commands   notify-by-email ; send service 
notifications via email
-       host_notification_commands      notify-by-email    ; send host 
notifications via email
+       service_notification_commands   notify-host-by-email ; send service 
notifications via email
+       host_notification_commands      notify-service-by-email    ; send host 
notifications via email
 }
diff --git a/modules/shinken/manifests/server.pp 
b/modules/shinken/manifests/server.pp
index b01b0c3..923816f 100644
--- a/modules/shinken/manifests/server.pp
+++ b/modules/shinken/manifests/server.pp
@@ -71,6 +71,15 @@
         notify  => Service['shinken'],
     }
 
+    file { "/etc/shinken/notification_commands.cfg":
+        ensure  => present,
+        source  => 'puppet:///modules/shinken/notification_commands.cfg',
+        owner   => 'shinken',
+        group   => 'shinken',
+        require => Package['shinken'],
+        notify  => Service['shinken'],
+    }
+
     class { 'nagios_common::contacts':
         source     => 'puppet:///modules/shinken/contacts.cfg',
         owner      => 'shinken',
@@ -89,15 +98,6 @@
         group      => 'shinken',
         notify     => Service['shinken'],
         require    => Package['shinken'],
-    }
-
-    class { 'nagios_common::notification_commands':
-        config_dir => '/etc/shinken',
-        owner      => 'shinken',
-        group      => 'shinken',
-        notify     => Service['shinken'],
-        require    => Package['shinken'],
-        lover_name => 'Shinken',
     }
 
     # Default localhost config, we do not need this

-- 
To view, visit https://gerrit.wikimedia.org/r/174780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I625e6c88b6c85205a3f5bdfa5bfcca6446920fcb
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to