please help SNMP dynamic configuration using perl - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

please help SNMP dynamic configuration using perl

captincaptin Posts: 2Member
Hi there I new to perl and SNMP....I need to write a trap handler in Perl that handle traps in SNMP environment such as link up/down and also it must do some configuration as a respond/correct to what happen,in my case I look for linkdown status and it should turn the alternative port up,that's all
so fa r I got the:
1- snmptrapd.conf file

authCommunity log,execute,net public
ignoreauthfailure no
format1 %#02.2h:%#02.2j TRAP%w.%q (%W) from %A Event:%v

traphandle "{abc}" eq "IF-MIB::LinkUp" || "{def}" eq "IF-MIB::LinkDown" | perl.exe traph.pl

2-traph.pl file

my $TRAP_FILE = "traps.all.log";
print "Executing Trap Handler...";

my $host = ; # Read the Hostname - First line of input from STDIN
my $ip = ; # Read the IP - Second line of input

my $result = index($ip,"127.0.0.1");

if ($result==-1) {
while() {
push(@vars,$_);
}

open(TRAPFILE, ">> $TRAP_FILE");
print(TRAPFILE "New trap received: $OID

HOST: $host
IP: $ip
");
foreach(@vars) {
print(TRAPFILE "TRAP: $_
");
}
print(TRAPFILE "
----------
");
close(TRAPFILE);
}
print "finished.
";

but I don't know how to write the piece of script that will do the configuration changes from linkdown to linkup...

can somebody help please...
Sign In or Register to comment.