Perl

Moderators: Jonathan
Number of threads: 1259
Number of posts: 3644

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
please help SNMP dynamic configuration using perl Posted by captin on 26 Dec 2012 at 7:10 AM
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\n
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 = <STDIN>; # Read the Hostname - First line of input from STDIN
my $ip = <STDIN>; # Read the IP - Second line of input

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

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

open(TRAPFILE, ">> $TRAP_FILE");
print(TRAPFILE "New trap received: $OID\n\nHOST: $host\nIP: $ip\n");
foreach(@vars) {
print(TRAPFILE "TRAP: $_\n");
}
print(TRAPFILE "\n----------\n");
close(TRAPFILE);
}
print "finished.\n";

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...



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.