cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3872
Views
0
Helpful
8
Replies

script to query for uptime, ios/cat, version

Dragomir
Level 1
Level 1

is it possible to get the uptime, ios or catos version and version number of all my cisco switches from a script?

8 Replies 8

fabios
Level 1
Level 1

Yes.

You can easily do with expect which can login on each router/switch, issue the required commands and store the output in the required format in a file.

You can look it up on google and this is the main puprose for which expect was written.

Hope this helps

Fabio

this is what i have

#!/usr/bin/expect -f

set timeout 20

set IPaddress x.x.x.x

set Password "xxxxx"

spawn telnet $IPaddress

expect "Password: "

send "$Password\r"

exp_send "sh version\r"

expect "R1#"

exp_send "exit\r"

how do I find what i need and then save to a file for 100s switches

I need

version, uptime, image name, serial

sh ver | i System Bootstrap Version

Collin Clark
VIP Alumni
VIP Alumni

If you use SecureCRT you can use VBScript. I could send you an example if you're interested.

I use SecureCRT. Can you share your scrpt?

Thank you,

Dan Frey
Cisco Employee
Cisco Employee

Another option is perl.   I use this script to get this info in one of the lab subnets via snmp.   net-snmp needs to be installed on your system if you want to use it as is.   May need to add another OID for uptime information.

#!/usr/bin/perl

system(clear);
open(STDERR , ">> /dev/null");
open(STDOUT , "> info_devices");
for ($int = 1; $int <= 124; $int = $int + 1) {
push(@IP , "192.168.23.$int ")
}

foreach $IP (@IP) {
print "\ninfo for $IP\n";
system("snmpget -v 2c -c public $IP SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysObjectID.0 SNMPv2-MIB::sysDescr.0");
}

- Dan

i do not have snmpget

my switches are on mutiple subnets

how do I do this per switch?

snmpget is part of the net-snmp package, it can be downloaded here: http://www.net-snmp.org/

Populate the individual switch IP addresses directly into the @IP array. Separate each IP with a space in the array.

#!/usr/bin/perl

system(clear);
open(STDERR , ">> /dev/null");
open(STDOUT , "> info_devices");

@IP = qw(10.34.1.3 192.168.3.2 10.55.94.1);

foreach $IP (@IP) {
print "\ninfo for $IP\n";
system("snmpget -v 2c -c public $IP SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysObjectID.0 SNMPv2-MIB::sysDescr.0");
}

catalystexpress
Level 1
Level 1

Hi,

You can try Macro using teraterm, which is quite simple.... let me know if you have done with this if not will help you out...cheers...

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card