cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

2726
Views
0
Helpful
7
Replies
Highlighted
Beginner

script to query for uptime, ios/cat, version

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

7 REPLIES 7
Highlighted
Beginner

script to query for uptime, ios/cat, version

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

Highlighted
Beginner

Re: script to query for uptime, ios/cat, version

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

Highlighted
Advisor

script to query for uptime, ios/cat, version

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

Highlighted
Cisco Employee

Re: script to query for uptime, ios/cat, version

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

Highlighted
Beginner

script to query for uptime, ios/cat, version

i do not have snmpget

my switches are on mutiple subnets

how do I do this per switch?

Highlighted
Cisco Employee

script to query for uptime, ios/cat, version

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");
}

Highlighted

script to query for uptime, ios/cat, version

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

CreatePlease to create content
Content for Community-Ad