Example #1
0
function Walk($a, $pre = '-->') {
	if (!is_array($a)) {
		echo "$pre value=$a<br>";
		return;
	}

	reset($a);
	while (list($key, $value) = each($a)) {
		echo "$pre $key=$value<br>";

		if (is_array($value)) {
			Walk($value, $pre . '-->');
		}
	}// while loop
}
		echo "</table>\n";
		echo "$lstlbl $emplbl";
		echo "<div align=center>$query</dev>";
		include_once ("inc/footer.php");
		die;
	}
	foreach( Walk($ip,$rv,$rc,"1.3.6.1.2.1.17.1.4.1.2") as $ix => $val){
		$pidx[substr(strrchr($ix, "."), 1 )] = $val;
	}
	foreach( Walk($ip,$rv,$rc,"1.3.6.1.2.1.17.2.15.1.3") as $ix => $val){
		$pstate[substr(strrchr($ix, "."), 1 )] = $val;
	}
	foreach( Walk($ip,$rv,$rc,"1.3.6.1.2.1.17.2.15.1.5") as $ix => $val){
		$pcost[substr(strrchr($ix, "."), 1 )] = $val;
	}
	foreach( Walk($ip, $rv, $rc,"1.3.6.1.2.1.2.2.1.8") as $ix => $val){
		$ifost[substr(strrchr($ix, "."), 1 )] = $val;
	}
	asort($pidx);

	$row = 0;
	foreach($pidx as $po => $ix){
		if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";}
		$row++;
		$rpimg = "";
		if($ifost[$ix] == "1" or $ifost[$ix] == "up"){
			$ifstat = "good";
		}elseif($ifost[$ix] == "2" or $ifost[$ix] == "down"){
			if($ifa[$ix]){
				$ifstat = "warn";
			}else{
Example #3
0
function DevRoutes($ip, $rv, $rc, $vrfname)
{
    global $toumsg, $nonlbl;
    if (!empty($vrfname)) {
        $suffix = strlen($vrfname);
        $sufarr = str_split($vrfname);
        foreach ($sufarr as $char) {
            $suffix .= "." . ord($char);
        }
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.8.{$suffix}") as $ix => $val) {
            $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $nho = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
            $msk = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
            $route[$r]['nho'] = $nho;
            $route[$r]['msk'] = $msk;
            $route[$r]['ifx'] = $val;
        }
        if (!empty($ix)) {
            #metric
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.14.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['me1'] = $val;
                $route[$r]['vrfname'] = $vrfname;
            }
            #protocol
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.10.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['pro'] = $val;
            }
            #age
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.11.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['age'] = $val;
            }
            return $route;
        } else {
            echo "<h4>(VRFs: {$nonlbl})</h4>";
        }
    }
    #snmp_set_oid_numeric_print(1); Doesn't work eveerywhere, so I use the preg_replace hack below to avoid problems
    # now we should try to get ipCidrRouteIfIndex oid. Full table in 4 queries if exists.
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.5") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $msk = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
        $nho = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
        $route[$r]['nho'] = $nho;
        $route[$r]['msk'] = $msk;
        $route[$r]['ifx'] = $val;
    }
    if (!$ix) {
        # no ipCidrRouteIfIndex OID, lets try ipRouteIfIndex OID (old one, but very common). This one will complete in 6 SNMP queries.
        echo "<h4>(ipCidrRouteIfIndex: {$nonlbl})</h4>";
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.2") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['ifx'] = $val;
        }
        if (!$ix) {
            #no luck with generic OIDs, try even more exotic inetCidrRoute
            #walking for inetCidrRouteIfIndex
            #netmask in really CIDR now
            echo "<h4>(generic OIDs: {$nonlbl})</h4>";
            snmp_set_oid_numeric_print(TRUE);
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.7") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $mskcidr = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
                $nho = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
                $mskpfix = Masker($mskcidr);
                $route[$r]['nho'] = $nho;
                $route[$r]['msk'] = $mskpfix[1];
                $route[$r]['ifx'] = $val;
            }
            if (!$ix) {
                #no OIDs for route info, timeout or route do not exist.
                echo "</table><h4>{$toumsg}</h4>";
                if ($_SESSION['vol']) {
                    echo "<embed src=\"inc/enter2.mp3\" volume=\"{$_SESSION['vol']}\" hidden=\"true\">\n";
                }
                die;
            }
            #metric inetCidrRouteMetric1
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.12") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['me1'] = $val;
            }
            #protocol inetCidrRouteProto
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.9") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['pro'] = $val;
            }
            #age inetCidrRouteAge
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.10") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['age'] = $val;
            }
            snmp_set_oid_numeric_print(FALSE);
            return $route;
        }
        #metric ipRouteMetric1
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.3") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['me1'] = $val;
        }
        #nexthop ipRouteNextHop
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.7") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['nho'] = $val;
        }
        #proto ipRouteProto
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.9") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['pro'] = $val;
        }
        #age ipRouteAge
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.10") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['age'] = $val;
        }
        #netmask ipRouteMask
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.11") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['msk'] = $val;
        }
        return $route;
    }
    #metric ipCidrRouteMetric1
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.11") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['me1'] = $val;
    }
    #protocol ipCidrRouteProto
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.7") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['pro'] = $val;
    }
    #age ipCidrRouteAge
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.8") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['age'] = $val;
    }
    return $route;
}
Example #4
0
	}
?>
<th><img src="img/16/batt.png" title="PoE [mW]"><br>PoE</th>
<th valign="bottom" width="10%"><img src="img/netg.png" title="MAC IP VRF"><br><?= $adrlbl ?></th>
</tr>

<?php
	if($uptime){
		foreach( Walk($ip, $rver, $dev[15],"1.3.6.1.2.1.2.2.1.8") as $ix => $val){
			$ifost[substr(strrchr($ix, "."), 1 )] = $val;
		}
		foreach( Walk($ip, $rver, $dev[15],"1.3.6.1.2.1.2.2.1.9") as $ix => $val){
			$iflac[substr(strrchr($ix, "."), 1 )] = $val;
		}
		if( preg_match('/^..[P]/',$dev[27]) ){ 
			foreach( Walk($ip, $rver, $dev[15],"1.3.6.1.2.1.105.1.1.1.3") as $ix => $val){
				$x = explode('.', $ix);
				$ifpst[$x[13]] = $val;
				$ifpsx[$x[13]] = $x[12];
			}
		}
	}
	$tpow= 0;											# China in your hand ;-)
	$row = 0;
	foreach ( $ifn as $i => $in){
		if( !$pvi or $pvi == $ifv[$i] ){
			if ($row % 2){$bg = "txta"; $bi = "imga";$off=200;}else{$bg = "txtb"; $bi = "imgb";$off=185;}
			$row++;
			$blc = $bio = $bie = $boo = $boe = "";
			$bg3 = sprintf("%02x",$off);
			$ui  = urlencode($in);
<th><img src="img/16/clock.png"><br><?php 
            echo $laslbl;
            ?>
</th>
<?php 
            error_reporting(1);
            snmp_set_quick_print(1);
            snmp_set_oid_numeric_print(1);
            foreach (Walk($ip, $dev[14] & 3, $dev[15], '1.3.6.1.4.1.9.10.2.1.1.2.1.12') as $ix => $val) {
                $prun[substr(strstr($ix, '9.10.2.1.1.2.1.'), 18)] = $val;
                // cut string at beginning with strstr first, because it depends on snmpwalk & Co being installed!
            }
            foreach (Walk($ip, $dev[14] & 3, $dev[15], '1.3.6.1.4.1.9.10.2.1.1.2.1.19') as $ix => $val) {
                $bps[substr(strstr($ix, '9.10.2.1.1.2.1.'), 18)] = $val;
            }
            foreach (Walk($ip, $dev[14] & 3, $dev[15], '1.3.6.1.4.1.9.10.2.1.1.2.1.23') as $ix => $val) {
                $last[substr(strstr($ix, '9.10.2.1.1.2.1.'), 18)] = $val;
            }
            ksort($prun);
            $row = 0;
            foreach ($prun as $mr => $pr) {
                if ($row % 2) {
                    $bg = "txta";
                    $bi = "imga";
                } else {
                    $bg = "txtb";
                    $bi = "imgb";
                }
                $row++;
                $i = explode(".", $mr);
                $ip = "{$i['4']}.{$i['5']}.{$i['6']}.{$i['7']}";
Example #6
0
 <?php 
echo $_GET['c'];
?>
 v<?php 
echo $ver;
?>
</h1>
<div class="net1">
<h2><img src="../img/32/bdwn.png" hspace="10"> <?php 
echo $_GET['oid'];
?>
</h2>
</div>
<div class="net2 code">
<?
if($_GET['ip'] and $ver and $_GET['c'] and $_GET['oid']){
	$cutoid = strlen($_GET['oid'])+2;
	snmp_set_oid_numeric_print(1);
	snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
	foreach( Walk($_GET['ip'], $ver, $_GET['c'], $_GET['oid'], $timeout*300000) as $ix => $val){
			echo substr($ix, $cutoid ).": <b>$val</b>\n";
	}
}else{
	echo "<h4>$nonlbl IP, version, community, OID?</h4>";
}

?>
</div>
</body>
</html>