]> git.sesse.net Git - nms/blob - clients/portnames.pl
Add a tool for extracting port names.
[nms] / clients / portnames.pl
1 #! /usr/bin/perl
2
3 my ($host,$switchtype,$community) = @ARGV;
4
5 open SNMP, "snmpwalk -Os -c $community -v 2c $host ifDescr |"
6         or die "snmpwalk: $!";
7
8 print "begin;\n";
9 print "delete from portnames where switchtype='$switchtype';\n";
10
11 while (<SNMP>) {
12         chomp;
13         /^ifDescr\.(\d+) = STRING: (.*)$/ or next;
14
15         print "insert into portnames (switchtype,port,description) values ('$switchtype',$1,'$2');\n";
16 }
17
18 print "end;\n";