#!/usr/bin/perl # use warnings; use strict; my $workingdir = "/home/timmytimay/inventory_scripts"; my @snmpro=qw/snmpString1 snmpString2 snmpString3 snmpString4 snmpString5/; my $snmp_cmd = "/usr/sfw/bin/snmpget -v2c -c"; my $rtrlist = "$workingdir/RTR_LIST.TXT"; my $snmpget="/usr/sfw/bin/snmpget -v2c -c"; # # Open the device list open( RTR, "$rtrlist" ) || die "Can't open $rtrlist file"; # Open the log file and print the tiles open( LOG, ">$workingdir/RESULT.TXT" )|| die "Can't open $workingdir/RESULT.TXT file"; printf " Router\t\t Location\t\t\tContact\t\t Serial\n"; printf LOG " Router\t\t; Location\t\t\t;Contact\t\t ;Serial\n"; # Loop through the devices and... foreach () { chomp( $rtr = "$_" ); $rtr = `$snmpget .1.3.6.1.4.1.9.2.1.3.0 $snmpro[0] $rtr` or print "hostname failed: $!\n"; if ($rtr =~ m/Timeout:/){ $rtr = `$snmpget .1.3.6.1.4.1.9.2.1.3.0 $snmpro[1] $rtr` or print "Host not responding to $snmpro[1]\n"; }