summaryrefslogtreecommitdiff
path: root/cleopatre/application/spidnetsnmp/local/traptoemail
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/application/spidnetsnmp/local/traptoemail')
-rwxr-xr-xcleopatre/application/spidnetsnmp/local/traptoemail72
1 files changed, 0 insertions, 72 deletions
diff --git a/cleopatre/application/spidnetsnmp/local/traptoemail b/cleopatre/application/spidnetsnmp/local/traptoemail
deleted file mode 100755
index 7d198bef62..0000000000
--- a/cleopatre/application/spidnetsnmp/local/traptoemail
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/perl
-
-# This is a snmptrapd handler script to convert snmp traps into email
-# messages.
-
-# Usage:
-# Put a line like the following in your snmptrapd.conf file:
-# traphandle TRAPOID|default /usr/local/bin/traptoemail [-f FROM] [-s SMTPSERVER]b ADDRESSES
-# FROM defaults to "root"
-# SMTPSERVER defaults to "localhost"
-
-use Net::SMTP;
-use Getopt::Std;
-
-$opts{'s'} = "localhost";
-$opts{'f'} = 'root@' . `hostname`;
-chomp($opts{'f'});
-getopts("hs:f:", \%opts);
-
-if ($opts{'h'}) {
- print "
-traptoemail [-s smtpserver] [-f fromaddress] toaddress [...]
-
- traptoemail shouldn't be called interatively by a user. It is
- designed to be called as an snmptrapd extension via a \"traphandle\"
- directive in the snmptrapd.conf file. See the snmptrapd.conf file for
- details.
-
- Options:
- -s smtpserver Sets the smtpserver for where to send the mail through.
- -f fromaddress Sets the email address to be used on the From: line.
- toaddress Where you want the email sent to.
-
-";
- exit;
-}
-
-die "no recepients to send mail to" if ($#ARGV < 0);
-
-# process the trap:
-$hostname = <STDIN>;
-chomp($hostname);
-$ipaddress = <STDIN>;
-chomp($ipaddress);
-
-$maxlen = 0;
-while(<STDIN>) {
- ($oid, $value) = /([^\s]+)\s+(.*)/;
- push @oids, $oid;
- push @values, $value;
- $maxlen = (length($oid) > $maxlen) ? length($oid) : $maxlen;
-}
-$maxlen = 60 if ($maxlen > 60);
-$formatstr = "%" . $maxlen . "s %s\n";
-
-die "illegal trap" if ($#oids < 1);
-
-# send the message
-$message = Net::SMTP->new($opts{'s'}) || die "can't talk to server $opts{'s'}\n";
-$message->mail($opts{'f'});
-$message->to(@ARGV) || die "failed to send to the recepients ",join(",",@ARGV),": $!";
-$message->data();
-$message->datasend("To: " . join(", ",@ARGV) . "\n");
-$message->datasend("From: $opts{f}\n");
-$message->datasend("Subject: trap received from $hostname: $values[1]\n");
-$message->datasend("\n");
-$message->datasend("Host: $hostname ($ipaddress)\n");
-for($i = 0; $i <= $#oids; $i++) {
- $message->datasend(sprintf($formatstr, $oids[$i], $values[$i]));
-}
-$message->dataend();
-$message->quit;