SOURCES: nagios-notify.sh (NEW) - initial
glen
glen at pld-linux.org
Thu Aug 3 14:32:04 CEST 2006
Author: glen Date: Thu Aug 3 12:32:04 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- initial
---- Files affected:
SOURCES:
nagios-notify.sh (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/nagios-notify.sh
diff -u /dev/null SOURCES/nagios-notify.sh:1.1
--- /dev/null Thu Aug 3 14:32:04 2006
+++ SOURCES/nagios-notify.sh Thu Aug 3 14:31:59 2006
@@ -0,0 +1,38 @@
+#!/bin/sh
+# $Id$
+#
+# Template based Nagios notify script.
+#
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+# Date: 2006-08-03
+# License: Same as Nagios (GPL v2)
+#
+. ./env1.txt
+
+templatedir='/etc/nagios/templates'
+
+# 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
+}
+
+# extract nagios version from status file
+export NAGIOS_VERSION=$(awk -F= '/version=/{print $2}' $NAGIOS_STATUSDATAFILE)
+
+tmpl="$1"
+tmpl="$templatedir/$1.tmpl"
+if [ ! -f "$tmpl" ]; then
+ echo >&2 "$0: template '$tmpl' can not be found!"
+ exit 1
+fi
+
+template_subst "$tmpl"
================================================================
More information about the pld-cvs-commit
mailing list