Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Cisco tftp upload via snmpset

Reply
Thread Tools

Cisco tftp upload via snmpset

 
 
Heinrich Piard
Guest
Posts: n/a
 
      07-23-2008
Hi all,

whoever is interested in it.

#!/usr/bin/ruby
#Version 0.1 Heinrich Piard - basic version of
snmpset-copy-running-config-to-tftp.rb

require 'yaml'
require 'snmp'
require 'socket'
#require 'daemons'
#require 'action_mailer'
require 'csv'
include Socket::Constants
#include Daemonize


# Cisco OIDs (variables)
#The ConfigCopyProtocol is set to TFTP
oid_setTFTP = "1.3.6.1.4.1.9.9.96.1.1.1.1.2.111 i 1"
#Set the SourceFileType to running-config
oid_setRUNNINGCONFIG = "1.3.6.1.4.1.9.9.96.1.1.1.1.3.111 i 4"
#Set the DestinationFileType to networkfile
oid_setDSTFILENETWORK = "1.3.6.1.4.1.9.9.96.1.1.1.1.4.111 i 1"
#Sets the ServerAddress to the IP address of the TFTP server
1.3.6.1.4.1.9.9.96.1.1.1.1.5.111 a <TFTP IP>
oid_setIPADDRTFTPSERVER = "1.3.6.1.4.1.9.9.96.1.1.1.1.5.111 a"
#Sets the CopyFilename to your desired file name
1.3.6.1.4.1.9.9.96.1.1.1.1.6.111 s <Filename>
oid_setDSTFILENAME = "1.3.6.1.4.1.9.9.96.1.1.1.1.6.111 s"
#Sets the CopyStatus to active which starts the copy process
1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 1
oid_setSTARTPROCESS = "1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 1"
#idcnetwatch1.bxc.is-teledata.com (TFTP server)
tftpserver = '172.29.0.254'
#hostlist including all switches
hostlist =
'/homes/network-monitoring/snmpset-copy-running-config-to-tftp.conf'
#snmp RO
rocommunity = 'public'
#snmp RW
rwcommunity = 'secret'



#start logic

#check if configfile is available
if ((File.exist?(hostlist)) && (File.readable?(hostlist)))
host = CSV.readlines(hostlist)
else
puts 'Cannot locate configuration file! Please check!'
exit
end

host.each do |ip|
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip} #{oid_setTFTP}")
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip}
#{oid_setRUNNINGCONFIG}" )
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip}
#{oid_setDSTFILENETWORK}" )
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip}
#{oid_setIPADDRTFTPSERVER} #{tftpserver}" )
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip}
#{oid_setDSTFILENAME} #{ip}" )
system('snmpset -v2c -c ' + "#{rwcommunity} #{ip}
#{oid_setSTARTPROCESS}" )
end
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
booting router from tftp: image is stored within a sub-dir in tftp root Sharad Cisco 0 02-13-2007 11:31 AM
Net:TFTPd questions - Want to upload configs via TFTP Chris G. Perl Misc 1 07-21-2006 08:18 PM
change password using snmpset mikerinos2000@hotmail.com Cisco 0 02-06-2004 07:06 AM
copy tftp to switch by useing snmpset strauch t Cisco 2 11-10-2003 07:20 AM
Setting arp address using snmpset. massimo Cisco 0 07-23-2003 02:52 PM



Advertisments