SVN: nagios-notify/trunk/nagios-notify

glen glen at pld-linux.org
Tue Jan 22 15:49:18 CET 2008


Author: glen
Date: Tue Jan 22 15:49:18 2008
New Revision: 9189

Modified:
   nagios-notify/trunk/nagios-notify
Log:
- parse $(base64:FILEPATH) macro from templates

Modified: nagios-notify/trunk/nagios-notify
==============================================================================
--- nagios-notify/trunk/nagios-notify	(original)
+++ nagios-notify/trunk/nagios-notify	Tue Jan 22 15:49:18 2008
@@ -10,6 +10,7 @@
 #
 
 templatedir='/etc/nagios/templates'
+export NAGIOS_DATADIR='/usr/share/nagios'
 prog="${0##*/}"
 
 # Substutute Nagios $VAR$-s (which are exported to environment by Nagios) from template.
@@ -25,7 +26,27 @@
 			}
 		}
 		exit;
-	}' | sed -f - $tmpl
+	}' | sed -f - $tmpl | perl -e '
+		use strict;
+		use MIME::Base64;
+
+		sub cat {
+			open(FH, shift) or die;
+			local $/ = undef;
+			local $_ = <FH>;
+			close FH;
+			return $_;
+		}
+
+		sub base64_subst {
+			encode_base64(cat(shift));
+		}
+
+		while (<>) {
+			s/\$\(base64:(\S+)\)/base64_subst($1)/eg;
+			print;
+		}
+	'
 }
 
 if [ -z "$NAGIOS_STATUSDATAFILE" ]; then


More information about the pld-cvs-commit mailing list