nagios-notify/trunk: . nagios-notify
glen
cvs at pld-linux.org
Fri Aug 4 01:32:05 CEST 2006
Author: glen
Date: Fri Aug 4 01:32:04 2006
New Revision: 7574
Added:
nagios-notify/trunk/
nagios-notify/trunk/nagios-notify (contents, props changed)
Log:
- imported into SVN
Added: nagios-notify/trunk/nagios-notify
==============================================================================
--- (empty file)
+++ nagios-notify/trunk/nagios-notify Fri Aug 4 01:32:04 2006
@@ -0,0 +1,42 @@
+#!/bin/sh
+# $Id: nagios-notify.sh,v 1.3 2006/08/03 12:39:22 glen Exp $
+#
+# Template based Nagios notify script.
+#
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+# Date: 2006-08-03
+# License: Same as Nagios (GPL v2)
+#
+
+templatedir='/etc/nagios/templates'
+prog="${0##*/}"
+
+# Substutute Nagios $VAR$-s (which are exported to environment by Nagios) from template.
+template_subst() {
+ awk 'BEGIN {
+ for (var in ENVIRON) {
+ if (substr(var, 1, length("NAGIOS_")) == "NAGIOS_") {
+ val = ENVIRON[var];
+ var = substr(var, 1 + length("NAGIOS_"));
+ gsub(/#/,"\\#",val);
+ printf("s#\$%s\$#%s#g\n", var, val);
+ }
+ }
+ }' | sed -f - $tmpl
+}
+
+if [ -z "$NAGIOS_STATUSDATAFILE" ]; then
+ echo >&2 "$prog: This program must be ran from Nagios."
+ exit 1
+fi
+
+# extract nagios version from status file
+export NAGIOS_VERSION=$(awk -F= '/version=/{print $2}' $NAGIOS_STATUSDATAFILE)
+
+tmpl="$templatedir/$1.tmpl"
+if [ ! -f "$tmpl" ]; then
+ echo >&2 "$prog: template '$tmpl' can not be found!"
+ exit 1
+fi
+
+template_subst "$tmpl"
More information about the pld-cvs-commit
mailing list