LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-18-2012, 07:14 AM   #1
dudastt
LQ Newbie
 
Registered: Feb 2012
Posts: 13

Rep: Reputation: Disabled
modify router configuration using snmp in linux


i'm planning to automate the distribution of a set of configuration commands to a large number of routers

i found some script and how to in "cisco ios cook book 2nd edition",this website has published the script
Code:
http://www.cathayschool.com/Using-SNMP-to-Perform-Mass-Configuration-Changes-a559.html
i've tried them but i kept getting error message

so is there anyone who has tried this script?is there anything else that i should do at first so that the script works?
 
Old 07-18-2012, 07:47 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if you're getting an error message, then tell us what it is. We aren't psychic.
 
Old 07-18-2012, 08:06 AM   #3
dudastt
LQ Newbie
 
Registered: Feb 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
sorry about that chris..

actually,in the book ,it says that when the script works it will give output like this

toronto - Update Successful

and when it doesn't,this message will appear

toronto - Update Failed

and this is all the message that i get
i think i will put the script here just to be clear
Quote:
#!/usr/bin/perl -w
#
# snmpcfg.pl -- a script to perform mass configuration changes to
# a list of routers using SNMP.
#
#
# Set behavior
$workingdir="/home/nms";
$snmprw="ORARW";
$tftpsrv="172.25.1.1";
#
#
$rtrlist="$workingdir/RTR_LIST";
open (RTR, "$rtrlist") || die "Can't open $rtrlist file";
open (LOG, ">$workingdir/RESULT") || die "Can't open $workingdir/RESULT file";
#
while (<RTR>) {
chomp($rtr="$_");
print LOG "=================================== \n";
print "=================================== \n";
$snmpset="/usr/local/bin/snmpset -t 20 -r 2 v1 c $snmprw $rtr ";
chomp($result=\Q$snmpset .1.3.6.1.4.1.9.2.1.50.$tftpsrv s SNMPCFG\Q);
if ($result=~/.+ = "(.+)"$/ ) {
if( $1 eq SNMPCFG ) {
print LOG "$rtr - Update Successful\n";
print "$rtr - Update Successful\n";
chomp($result=\Q$snmpset .1.3.6.1.4.1.9.2.1.54.0 i 1\Q);
if ($result=~/.+ = (.+)$/ ) {
if( $1 == 1 ) {
print LOG "$rtr - Wr Mem Successful\n";
print "$rtr - Wr Mem Successful\n";
}
else {
print LOG "$rtr - Wr Mem Failed\n";
print "$rtr - Wr Mem Failed\n";
}
}
else {
print LOG "$rtr - Wr Mem Failed\n";
print "$rtr - Wr Mem Failed\n";
}
}
else {
print LOG "$rtr - Update Failed\n";
print "$rtr - Update Failed\n";
}
}
else {
print LOG "$rtr - Update Failed\n";
print "$rtr - Update Failed\n";
}
}
i guess i did something wrong in stating $snmprw and $rtrlist variable
thanks for your reply,i'm pretty newb about snmp and perl scripting..

--fathul--
 
Old 07-18-2012, 08:24 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well does snmpset work in itself? try putting in a "print $result;" below the "chomp" line too
 
Old 07-20-2012, 11:16 AM   #5
dudastt
LQ Newbie
 
Registered: Feb 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
chris..
i've given up working my problem by using snmp
but i found an easier way for me to do it using expect,telnet and tftp
but i still got a little problem over it,so i'm going to ask in programming subforum

I think you can close/delete this thread
thanks for your reply and help

_______
fathul
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Net-snmp Mib configuration in Linux prashanthi74 Linux - Newbie 1 04-11-2012 08:00 AM
pc modify to switch with router function? hocheetiong Linux - Networking 1 12-23-2007 03:51 AM
Snmp configuration in suse linux 10.1 shan_nathan Linux - Networking 0 07-26-2007 06:46 AM
/etc/resolv.conf configuration when behind a router(not a linux router) rmanocha Linux - Networking 2 04-28-2004 01:52 AM
how to know my linux's SNMP managable router's DNS name or IP? zhgalaxy Linux - Newbie 1 03-19-2004 09:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration