Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.