#!/usr/bin/perl # Author: Albert S. Causing # License: BSD License use Net::Ping; $walk = "snmpwalk -v2c -c public "; $corinex = "enterprises.6798"; $devMac = ".1.3.6.1.2.1.2.2.1.6.1"; $nodeType = "$corinex.3.1.1.1.2"; $nodeMode = "$corinex.3.1.1.1.3"; $basicMode = "$corinex.3.2.1.1.2"; $subMode = "$corinex.3.2.1.1.20"; $numConn = "$corinex.3.4.1.1.3"; $conNMac = "$corinex.3.4.2.1.3"; $conPhyTX = "$corinex.3.3.1.1.11"; $conPhyRX = "$corinex.3.3.1.1.12"; $ipadd = $ARGV[0]; $n = 0; $p = Net::Ping->new(); for ($z=0;$z<5;$z++) { if ($p->ping($ipadd)) { $z = 5; } } if ($z == 6) { $mac = `$walk $ipadd $devMac`; $mac =~/= (.*)$/; $mac = $1; $ntype = `$walk $ipadd $nodeType`; $ntype =~/= (.*)$/; $ntype = $1; $nmode = `$walk $ipadd $nodeMode`; $nmode =~/= (.*)$/; $nmode = $1; $bmode = `$walk $ipadd $basicMode`; $bmode =~/= (.*)$/; $bmode = $1; $smode = `$walk $ipadd $subMode`; $smode =~/= (.*)$/; $smode = $1; $cnmac = `$walk $ipadd $numConn`; $cnmac=~/= (.*)$/; $cnmac =$1; $cmac =`$walk $ipadd $conNMac`; @acmac = $cmac =~ /: (.{17})/sg; $cpTX =`$walk $ipadd $conPhyTX`; @acpTX = $cpTX =~ /: (\d+)/sg; $cpRX =`$walk $ipadd $conPhyRX`; @acpRX = $cpRX =~ /: (\d+)/sg; for($i=0; $i<$cnmac;$i++) { $r[$i] = [$acmac[$i],$acpTX[$i],$acpRX[$i]]; } $n++; my $ntop =""; $a[$n] = [$ipadd,[$mac,$ntype,$nmode,$bmode,$smode, $cnmac,\@r]]; if ($a[$n][1][1] == "0") { $notp = "Master"; } elsif ($a[$n][1][1] == "1") { $notp = "Slave"; } elsif ($a[$n][1][1] == "2") { $notp = "TDRepeater"; } else { $notp = "Undefined"; } if ($a[$n][1][2] == "0") { $nomo = "LV Access"; } elsif ($a[$n][1][2] == "1") { $nomo = "MV Access"; } else { $nomo = "Undefined"; } print "IP:$a[$n][0]"." \tMAC: $a[$n][1][0] \tMODE: $a[$n][1][3]\n"; print "ACCESS: $notp \tWORKINGMODE: $nomo\n\n"; print "--------------------------------------------------------\n"; print " # \tMAC ADDRESS\t\tTX PHY\t\tRXPHY\n"; for($x=0;$x<$cnmac;$x++) { print " $x.\t$r[$x][0]\t$r[$x][1]\t\t$r[$x][2]\n"; } print "\n\n"; } else { print "[-] $ipadd is down...\n"; }