From 9835da0bf6b10f3cf6d374623ce5b0ac3b32dce3 Mon Sep 17 00:00:00 2001 From: andre Date: Thu, 6 Feb 2025 12:50:12 +0100 Subject: [PATCH] =?UTF-8?q?BMU=20SMS/send=5Fsms.pl=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMU SMS/send_sms.pl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 BMU SMS/send_sms.pl diff --git a/BMU SMS/send_sms.pl b/BMU SMS/send_sms.pl new file mode 100644 index 0000000..cc9f49a --- /dev/null +++ b/BMU SMS/send_sms.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +my $path="/usr/lib64/nagios/plugins"; +my $log="/var/log/send_sms"; +my $smspath="/var/spool/sms/outgoing"; + +my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); +my $smsfile="$smspath/out_" . sprintf("%4d-%02d-%02d_%02d-%02d-%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec); + +if (system("$path/feiertage.sh") != 0) { + open LF, ">>$log" || die "Kann Logfile nicht schreiben!"; + printf LF "### %4d-%02d-%02d %02d-%02d-%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec; + printf LF "Keine Alarmierung ($path/feiertage.sh)!\n"; + close LF; + exit 0; +} + +my $host=$ARGV[0]; +my $msg=$ARGV[1]; +my $lvl=$ARGV[2]; + +open SMS, "<$path/sms_receiver" || die "Kann SMS Receiver Datei nicht schreiben!"; +my $nr=; +close SMS; + +open FH, ">$smsfile" || die "Kann SMS Datei nicht schreiben!"; +open LF, ">>$log" || die "Kann Logfile nicht schreiben!"; + +printf FH "To: %s\n\nHost/Service:\n%s\n\nStatus: %s\n\nNachricht:\n%s\n", $nr, $host, $lvl, $msg; +printf LF "### %4d-%02d-%02d %02d-%02d-%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec; +printf LF "To: %s\n\nHost/Service:\n%s\n\nStatus: %s\n\nNachricht:\n%s\n", $nr, $host, $lvl, $msg; + +close FH; +close LF;