Paladox has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/361214 )
Change subject: Add mail-host and mail-service scripts
......................................................................
Add mail-host and mail-service scripts
Change-Id: Ie2ee659366a40766fa11a9579effdd8a7f753093
---
M manifests/init.pp
A templates/mail-host-notification.sh.erb
A templates/mail-service-notification.sh.erb
3 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
Paladox: Verified; Looks good to me, approved
diff --git a/manifests/init.pp b/manifests/init.pp
index a06f40a..7bb4d40 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -103,6 +103,24 @@
notify => Base::Service_unit['icinga2'],
}
+ file { '/etc/icinga2/scripts/mail-host-notification.sh':
+ ensure => present,
+ content => template('mail-host-notification.sh.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0755'
+ notify => Base::Service_unit['icinga2'],
+ }
+
+ file { '/etc/icinga2/scripts/mail-service-notification.sh':
+ ensure => present,
+ content => template('mail-service-notification.sh.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0755'
+ notify => Base::Service_unit['icinga2'],
+ }
+
# Setup all plugins!
class { '::icinga2::plugins':
require => Package['icinga2'],
diff --git a/templates/mail-host-notification.sh.erb
b/templates/mail-host-notification.sh.erb
new file mode 100644
index 0000000..3244cce
--- /dev/null
+++ b/templates/mail-host-notification.sh.erb
@@ -0,0 +1,22 @@
+#!/bin/sh
+template=`cat <<TEMPLATE
+***** Icinga *****
+
+Notification Type: $NOTIFICATIONTYPE
+
+Host: $HOSTALIAS
+Address: $HOSTADDRESS
+State: $HOSTSTATE
+
+Date/Time: $LONGDATETIME
+
+Additional Info: $HOSTOUTPUT
+
+Comment: [$NOTIFICATIONAUTHORNAME] $NOTIFICATIONCOMMENT
+TEMPLATE
+`
+
+# /usr/bin/printf "%b" "$template" | mail -s "$NOTIFICATIONTYPE -
$HOSTDISPLAYNAME is $HOSTSTATE" <email> # $USEREMAIL
+
+/bin/echo "$NOTIFICATIONTYPE - Host $HOSTALIAS is $HOSTSTATE: $HOSTOUTPUT
$HOSTACKAUTHOR $HOSTACKCOMMENT $NOTIFICATIONCOMMENT" >> /var/log/icinga2/irc.log
+
diff --git a/templates/mail-service-notification.sh.erb
b/templates/mail-service-notification.sh.erb
new file mode 100644
index 0000000..a337320
--- /dev/null
+++ b/templates/mail-service-notification.sh.erb
@@ -0,0 +1,22 @@
+#!/bin/sh
+template=`cat <<TEMPLATE
+***** Icinga *****
+
+Notification Type: $NOTIFICATIONTYPE
+
+Service: $SERVICEDESC
+Host: $HOSTALIAS
+Address: $HOSTADDRESS
+State: $SERVICESTATE
+
+Date/Time: $LONGDATETIME
+
+Additional Info: $SERVICEOUTPUT
+
+Comment: [$NOTIFICATIONAUTHORNAME] $NOTIFICATIONCOMMENT
+TEMPLATE
+`
+
+# /usr/bin/printf "%b" "$template" | mail -s "$NOTIFICATIONTYPE -
$HOSTDISPLAYNAME - $SERVICEDISPLAYNAME is $SERVICESTATE" $USEREMAIL
+
+/bin/echo "$NOTIFICATIONTYPE - $SERVICEDESC on $HOSTNAME is $SERVICESTATE:
$SERVICEOUTPUT $SERVICEACKAUTHOR $SERVICEACKCOMMENT" >> /var/log/icinga2/irc.log
--
To view, visit https://gerrit.wikimedia.org/r/361214
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2ee659366a40766fa11a9579effdd8a7f753093
Gerrit-PatchSet: 2
Gerrit-Project: labs/icinga2
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits