Name | Modified | Size | Downloads / Week |
---|---|---|---|
README.txt | 2013-05-27 | 5.3 kB | |
snmp.txt | 2013-05-27 | 5.3 kB | |
Totals: 2 Items | 10.6 kB | 0 |
get the orignal version http://www.shrubbery.net/pipermail/rancid-discuss/2005-November/001276.html you need a tftpservice running make sure you update the rancid-fe file to fech the wrapper add a line for the wraaoper in the vendor table 'wrapper.snmp> 'wrapper.snmp', and for the if condition if ($vendortable{$vendor} eq "") { printf(STDERR "unknown router manufacturer for $router: $vendor\n"); exit(-1); } elsif($vendor =~ /^wrapper\.(.+)$/i) { exec('wrancid', '-s', $1, $router); } else { exec($vendortable{$vendor} . " $router"); } printf(STDERR "exec failed router manufacturer $vendor: $!\n"); exit(-1); file name :snmp =----------------------------------------------------config----------------------- #!/usr/bin/perl -w # # vpn3k - TFT and SNMP Backup script for Cisco DEVICES Only # # WARNING: This is only PROOF OF CONCEPT code and will screw up your data # and eat babies!!! # # # # Load any modules needed # This script is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ####################################################### # Modules ####################################################### # Load any modules needed #use strict; use Getopt::Std; use Net::SCP::Expect; use File::Temp; ####################################################### # Variables ####################################################### # Initialize variables used in this script #getopts('dflV'); #if ($opt_V) { # exit(0); #} #my $log = $opt_l; #my $debug = $opt_d; #my $file = $opt_f; #my $host = $ARGV[0]; my $clean_run = 0; my $found_end = 0; #my $timeo = 90; my %options = (); getopts('f:', \%options); my $file = $options{'f'}; my $host = $ARGV[0]; my $comm= 'xxxxxxxxxx'; my $tftp='xxxxxxxxxxxxx'; my $RANDOM = int(rand(1000)); my $ccstatus ='1'; my $fh; (my $tempfh, my $tempfile) = mkstemp( "/tftp/tmpXXXX" ); chmod(0777, $tempfile); my $path = substr($tempfile, -7); print "\n$host\n"; print "$file\n"; open ($fh, ">", $file) or die " cannot open output file\n"; ####################################################### #snmp defnitions:wq ####################################################### my $snmp_command2 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.2.$RANDOM i 1"; my $snmp_command3 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.3.$RANDOM i 4"; my $snmp_command4 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.4.$RANDOM i 1"; my $snmp_command5 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.5.$RANDOM a $tftp"; my $snmp_command6 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.6.$RANDOM s $path"; my $snmp_command141 = "snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.14.$RANDOM i 1"; my $snmp_command101 = "snmpget -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.10.$RANDOM i 1"; my $snmp_check = " snmpwalk -v2c -c$comm $host 1.3.6.1.2.1.47.1.1.1.1.11"; ###run snmp on the host my $snmp_var = `$snmp_check`; chomp($snmp_var); if ($snmp_var eq '') { print ($fh "SNMP IS NOT enabled "); } else { my $config = `$snmp_command2`;`$snmp_command3`;`$snmp_command4`;`$snmp_command5`;`$snmp_command6`;`$snmp_command141`; while ($ccstatus <= 4) { my $result = `snmpget -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.10.$RANDOM i 1`; chomp($result); if ( $result =~ "SNMPv2-SMI::enterprises.9.9.96.1.1.1.1.10.$RANDOM = INTEGER: 3" ) { $ccstatus =5; $clean_run = 1; $found_end = 1 } else { sleep 2; $ccstatus++; } } # tftp copy start time my $int1 = `snmpget -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.11.$RANDOM`; # tftp copy end time my $int2 = `snmpget -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.12.$RANDOM`; print "\n$int1\n$int2\n"; #clear the snmp set #my $result = `snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.14.$RANDOM i 6`; open($tempfh, "<", $tempfile)or die "copy seems to have failed\n"; print($fh "courtesy Naresh Paturi"); my $line; while ($line = <$tempfh>) { print ($fh $line); } my $result = `snmpset -v2c -c$comm $host 1.3.6.1.4.1.9.9.96.1.1.1.1.14.$RANDOM i 6`; } close($fh); close($tempfh);