function StatusMem($loc) { #TODO like cpu global $link, $tgtlbl, $limlbl, $frelbl, $memlbl, $modgroup, $self; $aquery = GenQuery('monitoring', 's', 'name,memcpu,memalert', 'memcpu desc', $_SESSION['lim'], array('memcpu/1024', 'memcpu', 'location'), array('COL <', '>', 'like'), array('memalert', 100, $loc), array('AND', 'AND'), 'LEFT JOIN devices USING (device)'); $ares = DbQuery($aquery, $link); $nar = DbNumRows($ares); $pquery = GenQuery('monitoring', 's', 'name,memcpu,memalert', 'memcpu desc', $_SESSION['lim'], array('memcpu', 'memcpu', 'memcpu', 'location'), array('COL <', '>', '<', 'like'), array('memalert', 0, 100, $loc), array('AND', 'AND', 'AND'), 'LEFT JOIN devices USING (device)'); $pres = DbQuery($pquery, $link); $npr = DbNumRows($pres); if ($nar or $npr) { ?> <p><table class="content"><tr class="<?php echo $modgroup[$self]; ?> 2"> <th colspan="2"><img src="img/16/trgt.png" title="Top <?php echo $_SESSION['lim']; ?> <?php echo $memlbl; ?> <?php echo $frelbl; ?> "><br><?php echo $tgtlbl; ?> </th> <th nowrap><img src="img/16/mem.png"><br><?php echo $frelbl; ?> </th> <?php $row = 0; while ($t = DbFetchRow($ares)) { if ($row % 2) { $bg = "txta"; $bi = "imga"; $off = "b8"; } else { $bg = "txtb"; $bi = "imgb"; $off = "c8"; } $row++; $lv = pow($ma[0] * 1024 / $t[1], 8); $hi = sprintf("%02x", ($lv > 55 ? 55 : $lv) + 200); $na = substr($t[0], 0, $_SESSION['lsiz']); $ud = urlencode($t[0]); if ($_SESSION['gsiz'] == 6) { echo "<tr bgcolor=\"#{$hi}{$hi}{$off}\"><th class=\"{$bi}\">{$row}</th><td>{$na}</td><th nowrap>" . DecFix($t[1]) . "B</th></tr>\n"; } else { echo "<tr bgcolor=\"#{$hi}{$hi}{$off}\"><th class=\"{$bi}\">{$row}</th><td><a href=Monitoring-Setup.php?in[]=name&op[]=%3D&st[]={$ud}>{$na}</a></td>\n"; echo "<th nowrap title=\"{$limlbl} " . DecFix($t[2] * 1024) . "B\">" . DecFix($t[1]) . "B</th></tr>\n"; } } while ($t = DbFetchRow($pres)) { if ($row % 2) { $bg = "txta"; $bi = "imga"; $off = "b8"; } else { $bg = "txtb"; $bi = "imgb"; $off = "c8"; } $row++; $lv = $t[1] - $m[1]; $hi = sprintf("%02x", ($lv > 55 ? 55 : $lv) + 200); $na = substr($t[0], 0, $_SESSION['lsiz']); $ud = urlencode($t[0]); if ($_SESSION['gsiz'] == 6) { echo "<tr bgcolor=\"#{$hi}{$hi}{$off}\"><th class=\"{$bi}\">{$row}</th><td>{$na}</td><th nowrap>{$t['1']}%</th></tr>\n"; } else { echo "<tr bgcolor=\"#{$hi}{$hi}{$off}\"><th class=\"{$bi}\">{$row}</th><td><a href=Monitoring-Setup.php?in[]=name&op[]=%3D&st[]={$ud}>{$na}</a></td>\n"; echo "<th nowrap title=\"{$limlbl} {$t['2']}%\">{$t['1']}%</th></tr>\n"; } } echo "</table>\n"; } else { $isiz = $_SESSION['gsiz'] == 2 ? "16" : "32"; ?> <p><img src="img/<?php echo $isiz; ?> /mem.png" title="<?php echo $memlbl; ?> <?php echo $frelbl; ?> " hspace="8"> <img src="img/<?php echo $isiz; ?> /bchk.png" title="OK"> <?php } DbFreeResult($ares); DbFreeResult($pres); }
$icm[$i[2]] = $i[20]; $isp[$i[2]] = $i[9]; } DbFreeResult($res); $r = DevRoutes($devip[$rtr], $devver[$rtr], $devcom[$rtr], $vrf); $row = 0; foreach (array_keys($r) as $rd) { if ($row % 2) { $bg = "txta"; $bi = "imga"; } else { $bg = "txtb"; $bi = "imgb"; } $row++; $spd = DecFix($isp[$r[$rd]['ifx']]); $rp = RteProtoNumToText($r[$rd]['pro']); $rpimg = RteProto($rp); $unh = rawurlencode($netif[$r[$rd]['nho']]); list($pfix, $msk, $bmsk) = Masker($r[$rd]['msk']); list($ifimg, $iftit) = Iftype($ity[$r[$rd]['ifx']]); list($ntimg, $ntit) = Nettype($rd); TblRow($bg); echo "<th class=\"{$bi}\" width=\"20\"><img src=\"img/{$ntimg}\" title={$ntit}></th>\n"; echo "<td><a href=\"Topology-Networks.php?in[]=ifip&op[]==&st[]={$rd}%2F{$pfix}&draw=png\">{$rd}/{$pfix}</a></td>\n"; echo "<td>" . $r[$rd]['nho'] . " <a href=?rtr={$unh}&vrf={$uvn}>" . $netif[$r[$rd]['nho']] . "</a></td><td><img src=\"img/{$ifimg}\" title={$iftit}> "; echo "<b>" . $ina[$r[$rd]['ifx']] . "</b> <i>" . $ial[$r[$rd]['ifx']] . "</i> " . $icm[$r[$rd]['ifx']] . "</td>\n"; echo "<td align=right>{$spd}</td><td align=center>" . $r[$rd]['me1'] . "</td>\n"; echo "<td><img src=\"img/16/{$rpimg}.png\"> {$rp}</td><td align=right>" . $r[$rd]['age'] . "</td>\n"; echo "</tr>\n"; }
elseif($pstate[$po] == 3 or $pstate[$po] == "listening"){$pst = "<img src=\"img/16/bup.png\" title=\"STP listening\">";} elseif($pstate[$po] == 4 or $pstate[$po] == "learning"){$pst = "<img src=\"img/16/brld.png\" title=\"STP learning\">";} elseif($pstate[$po] == 5 or $pstate[$po] == "forwarding"){$pst = "<img src=\"img/16/brgt.png\" title=\"STP forwarding\">";} else{$pst = "<img src=\"img/16/bcls.png\" title=\"broken\">";} $ui = urlencode($ifn[$ix]); list($ifimg,$iftit) = Iftype($ift[$ix]); TblRow($bg); echo "<th class=\"$ifstat\" width=\"20\"><img src=\"img/$ifimg\" title=\"$ix - $iftit\"></th>\n"; echo "<th class=\"$bi\" width=\"20\">$pst $sten $rpimg</th><td>\n"; if($ifstat == "good" and $guiauth != 'none' and !isset($_GET['print'])){ echo "<div style=\"font-weight: bold\" class=\"blu\" title=\"$rltlbl $trflbl\" onclick=\"window.open('inc/rt-popup.php?d=$debug&ip=$ip&v=$rv&c=$rc&i=$ix&t=$ud&in=$ui','$ip_$ix','scrollbars=0,menubar=0,resizable=1,width=600,height=400')\">$ifn[$ix]</div></td>\n"; }else{ echo "<b>$ifn[$ix]</b></td>\n"; } echo "<td align=\"right\">$pcost[$po]</td><td align=\"right\">".DecFix($ifs[$ix])."</td><td>$ifi[$ix]</td>\n"; if($shg){ echo "<td nowrap align=\"center\">\n"; IfGraphs($ud, $ui, $ifs[$i], ($_SESSION['gsiz'] == 4)?2:1 ); echo "</td>"; } echo "</tr>\n"; } ?> </table> <table class="content"> <tr class="<?= $modgroup[$self] ?>2"><td><?= $row ?> Interfaces</td></tr> </table> <?php }
function DrawLink($x1, $y1, $x2, $y2, $opt) { global $fmt, $lev, $lix, $liy, $lis, $lit, $lil, $lal, $ipi, $ifi, $ifa, $pos, $xm, $ym, $debug; global $dev, $maplinks, $mapitems, $errlbl, $trflbl, $rrdcmd, $rrdstep, $nedipath, $liy; $liy["{$x1},{$y1},{$y2}"] = $liy["{$x1},{$y1},{$y2}"] ? 0 : 9; # offset coherent if/ip info on start of links from a node where link end is same y $liy["{$x2},{$y2},{$y1}"] = $liy["{$x2},{$y2},{$y1}"] ? 0 : 9; # offset coherent if/ip info on end of links from a node where link end is same y if ($x1 == $x2) { # offset coherent, horizontal links... $lix[$x1] += 2; $x1 += $lix[$x1]; $x2 = $x1; } elseif ($y1 == $y2) { # offset coherent, verical links... $liy[$y1] += 2; $y1 += $liy[$y1]; $y2 = $y1; } $xlm = intval($x1 + $x2) / 2; # middle of link $ylm = intval($y1 + $y2) / 2; $dctr1 = sqrt(pow($x1 - $xm / 2, 2) + pow($y2 - $ym / 2, 2)); # Pythagoras tells distance to map center of either possible arc centerpoint $dctr2 = sqrt(pow($x2 - $xm / 2, 2) + pow($y1 - $ym / 2, 2)); if ($dctr1 < $dctr2) { $xctr = $x1; $yctr = $y2; $xedg = $xr2 = $x2; $xr1 = $xedg - intval(($xedg - $xctr) / 8); $yedg = $yr1 = $y1; $yr2 = $yedg - intval(($yedg - $yctr) / 8); } else { $xctr = $x2; $yctr = $y1; $xedg = $xr1 = $x1; $xr2 = $xedg - intval(($xedg - $xctr) / 8); $yedg = $yr2 = $y2; $yr1 = $yedg - intval(($yedg - $yctr) / 8); } #$maplinks .= "ImageString(\$image, 3, $xctr,$yctr,\"C\", \$blue);\n"; #$maplinks .= "ImageString(\$image, 3, $xedg,$yedg,\"E\", \$blue);\n"; $futl = round($opt['ftr'] * 800 / $opt['fbw'] / $rrdstep, 1); list($t, $cf) = LinkStyle($opt['fbw'], $futl); if (is_numeric($opt['rbw']) and $opt['rbw'] > 0) { $rutl = round($opt['rtr'] * 800 / $opt['rbw'] / $rrdstep, 1); list($tr, $cr) = LinkStyle($opt['rbw'], $rutl); } else { $rutl = round($opt['rtr'] * 800 / $opt['fbw'] / $rrdstep, 1); list($tr, $cr) = LinkStyle($opt['fbw'], $rutl); } #$maplinks .= "ImageString(\$image, 3, $x1,$y1,\"Start\", \$blue);\n"; $maplinks .= "\$stylarr = array(\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\n\t\t\t\t\t\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf}, \n\t\t\t\t\t\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf}, \n\t\t\t\t\t\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf},\${$cf}, \n\t\t\t\t\t\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\n\t\t\t\t\t\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\n\t\t\t\t\t\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\n\t\t\t\t\t\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr},\${$cr});\n"; $maplinks .= "imagesetstyle(\$image,\$stylarr);\n"; $lsty = 'IMG_COLOR_STYLED'; #$maplinks .= "\$bru = imagecreatefrompng('../img/netr.png');\n"; #$maplinks .= "imagesetbrush(\$image, \$bru);\n"; #$lsty = 'IMG_COLOR_BRUSHED'; if ($lis == "a1" or $x2 == $x1 and $y2 == $y1) { if ($x2 == $x1 and $y2 == $y1) { $y1 += 1; $w = 100; $h = 50; $s = 0; $e = 360; $xctr += 50; $xlm = $xctr + 50; $ylm = $y1; } else { $w = 2 * abs($x2 - $x1); $h = 2 * abs($y2 - $y1); $l = sqrt($w * $h) / 10; if ($xctr > $xedg) { # Left half if ($yctr > $yedg) { # Upper Quadrant $s = 180; $e = 270; $ylm -= $l; } else { $s = 90; $e = 180; $ylm += $l; } $xlm -= $l; } else { if ($yctr > $yedg) { $s = 270; $e = 0; $ylm -= $l; } else { $s = 0; $e = 90; $ylm += $l; } $xlm += $l; } } if ($fmt == "svg") { $maplinks .= "<path d=\"M {$x1} {$y1} A {$w} {$h} 0 0 1 {$x2} {$y2}\" stroke=\"{$cf}\" stroke-width=\"{$t}\" fill = \"none\"/>\n"; } else { $maplinks .= "imagesetthickness(\$image,{$t});\n"; $maplinks .= "imagearc(\$image, {$xctr}, {$yctr}, {$w}, {$h}, {$s}, {$e}, {$lsty});\n"; } } elseif ($lis == "a2" or $lis == "a3") { $xlm = $xedg; $ylm = $yedg; if ($fmt == "svg") { $maplinks .= "<line x1=\"{$x1}\" y1=\"{$y1}\" x2=\"{$xlm}\" y2=\"{$ylm}\" stroke=\"{$cf}\" stroke-width=\"{$t}\"/>\n"; $maplinks .= "<line x1=\"{$xlm}\" y1=\"{$ylm}\" x2=\"{$x2}\" y2=\"{$y2}\" stroke=\"{$cf}\" stroke-width=\"{$t}\"/>\n"; } elseif ($lis == "a3") { $maplinks .= "imagesetthickness(\$image,{$t});\n"; $maplinks .= "imageline(\$image,{$x1},{$y1},{$xr1},{$yr1},{$lsty});\n"; $maplinks .= "imageline(\$image,{$xr2},{$yr2},{$x2},{$y2},{$lsty});\n"; $maplinks .= "imageline(\$image,{$xr1},{$yr1},{$xr2},{$yr2},{$lsty});\n"; } else { $maplinks .= "imagesetthickness(\$image,{$t});\n"; $maplinks .= "imageline(\$image,{$x1},{$y1},{$xlm},{$ylm},{$lsty});\n"; $maplinks .= "imageline(\$image,{$xlm},{$ylm},{$x2},{$y2},{$lsty});\n"; } } elseif ($lis == "a4") { $xlm = $xedg - intval(($xedg - $xctr) / 5); $ylm = $yedg - intval(($yedg - $yctr) / 5); if ($fmt == "svg") { $maplinks .= "<line x1=\"{$x1}\" y1=\"{$y1}\" x2=\"{$xlm}\" y2=\"{$ylm}\" stroke=\"{$cf}\" stroke-width=\"{$t}\"/>\n"; $maplinks .= "<line x1=\"{$xlm}\" y1=\"{$ylm}\" x2=\"{$x2}\" y2=\"{$y2}\" stroke=\"{$cf}\" stroke-width=\"{$t}\"/>\n"; } else { $maplinks .= "imagesetthickness(\$image,{$t});\n"; $maplinks .= "imageline(\$image,{$x1},{$y1},{$xlm},{$ylm},{$lsty});\n"; $maplinks .= "imageline(\$image,{$xlm},{$ylm},{$x2},{$y2},{$lsty});\n"; } } else { if ($fmt == "svg") { $maplinks .= "<line x1=\"{$x1}\" y1=\"{$y1}\" x2=\"{$x2}\" y2=\"{$y2}\" stroke=\"{$cf}\" stroke-width=\"{$t}\"/>\n"; } else { $maplinks .= "imagesetthickness(\$image,{$t});\n"; $maplinks .= "imageline(\$image,{$x1},{$y1},{$x2},{$y2},{$lsty});\n"; } } $xlm = $xlm + $lil / 10 * intval($xm / ($xlm - $xm / 2.1)); # move info on a ray from the center $ylm = $ylm + $lil / 10 * intval($ym / ($ylm - $ym / 2.1)); # .1 to avoid div 0 if (is_array($opt['fif'])) { $yof = 2 + $liy["{$x1},{$y1},{$y2}"]; foreach ($opt['fif'] as $fi) { $f = explode(';;', $fi); $ifal = ($ifa and $dev[$f[0]]['ifal'][$f[1]]) ? " " . $dev[$f[0]]['ifal'][$f[1]] : ""; if (preg_match('/^[febd]/', $lit) and $rrdcmd) { $rrd = "{$nedipath}/rrd/" . rawurlencode($f[0]) . "/" . rawurlencode($f[1]) . ".rrd"; if (file_exists($rrd)) { $rrdif["{$f['0']}-{$f['1']}"] = $rrd; } elseif ($debug) { echo "<div class=\"textpad alrm\">FRRD:{$rrd} not found!</div>\n"; } } if ($lev > 3) { $ifl = ($ifi and $f[1] != '-') ? $f[1] : ''; } else { $ifl = $ifi ? "{$f['0']} {$f['1']}" : ""; } $ipl = $ipi ? $dev[$f[0]]['ifip'][$f[1]] : ""; $alpha = atan2($ylm - $y1, $xlm - $x1); $mapitems .= DrawLabel($x1 + cos($alpha) * $lal, $y1 + sin($alpha) * $lal + $yof, Safelabel("{$ifl}{$ipl}{$ifal}"), 1, "gray"); $yof += 9; } } if (is_array($opt['rif'])) { $yof = 2 + $liy["{$x2},{$y2},{$y1}"]; foreach ($opt['rif'] as $ri) { $r = explode(';;', $ri); $ifal = ($ifa and $dev[$r[0]]['ifal'][$r[1]]) ? " " . $dev[$r[0]]['ifal'][$r[1]] : ""; if ($lev > 3) { $ifl = ($ifi and $r[1] != '-') ? $r[1] : ''; } else { $ifl = $ifi ? "{$r['0']} {$r['1']}" : ""; } $ipl = $ipi ? $dev[$r[0]]['ifip'][$r[1]] : ""; $alpha = atan2($ylm - $y2, $xlm - $x2); $mapitems .= DrawLabel($x2 + cos($alpha) * $lal, $y2 + sin($alpha) * $lal + $yof, Safelabel("{$ifl}{$ipl}{$ifal}"), 1, "gray"); $yof += 9; } } if ($lit == 'w') { $mapitems .= DrawLabel($xlm, $ylm - 8, DecFix($opt['fbw']) . "/" . DecFix($opt['rbw']), 1, "green"); } elseif ($lit == 't') { foreach ($opt['fty'] as $t => $c) { $ftyp .= $c > 1 ? "{$c}x {$t} " : "{$t} "; } foreach ($opt['rty'] as $t => $c) { $rtyp .= $c > 1 ? "{$c}x {$t} " : "{$t} "; } $mapitems .= DrawLabel($xlm, $ylm - 8, $ftyp, 1, "blue"); $mapitems .= DrawLabel($xlm, $ylm - 16, $rtyp, 1, "blue"); } elseif ($lit == 'l' and $pos != "d") { $mapitems .= DrawLabel($xlm, $ylm - 8, "{$futl}%/{$rutl}%", 3, "black"); } elseif (is_array($rrdif)) { if (preg_match('/^f/', $lit)) { $opts = GraphOpts(substr($lit, 1), 0, 0, $trflbl, $opt['fbw']); list($draw, $tit) = GraphTraffic($rrdif, 'trf'); $mapitems .= DrawLabel($xlm, $ylm - 25, DecFix($opt['fbw']) . "/" . DecFix($opt['rbw']), 1, "green"); } elseif (preg_match('/^e/', $lit)) { $opts = GraphOpts(substr($lit, 1), 0, 0, $errlbl, 1); list($draw, $tit) = GraphTraffic($rrdif, 'err'); } elseif (preg_match('/^d/', $lit)) { $opts = GraphOpts(substr($lit, 1), 0, 0, "Discards", 0); list($draw, $tit) = GraphTraffic($rrdif, 'dsc'); } else { $opts = GraphOpts(substr($lit, 1), 0, 0, "Broadcasts", 0); list($draw, $tit) = GraphTraffic($rrdif, 'brc'); } exec("{$rrdcmd} graph map/{$xlm}{$ylm}.png -a PNG {$opts} {$draw}"); if ($fmt == "json") { } elseif ($fmt == "svg") { $mapitems .= "\t<text x=\"{$xlm}\" y=\"{$ylm}\" fill=\"gray\">no RRDs in SVG!</text>\n"; } else { $mapitems .= "\$icon = Imagecreatefrompng(\"{$xlm}{$ylm}.png\");\n"; $mapitems .= "\$w = Imagesx(\$icon);\n"; $mapitems .= "\$h = Imagesy(\$icon);\n"; $mapitems .= "Imagecopy(\$image, \$icon,{$xlm}-\$w/2,{$ylm}-\$h/2,0,0,\$w,\$h);\n"; $mapitems .= "Imagedestroy(\$icon);\n"; $mapitems .= "unlink(\"{$xlm}{$ylm}.png\");\n"; } } }
$ud = rawurlencode($l[1]); $un = rawurlencode($l[3]); if ($row % 2) { $bg = "txta"; $bi = "imga"; } else { $bg = "txtb"; $bi = "imgb"; } $row++; TblRow($bg); list($tc, $tc) = Agecol($l[10], $l[10], $row % 2); TblCell($l[1], "?dv={$ud}", "nowrap", "<a href=\"Devices-Status.php?dev={$ud}\"><img src=\"img/16/sys.png\"></a>"); echo "<td>{$l['2']}</td>\n"; echo "<th>{$l['6']}</th>\n"; echo "<td align=right>" . DecFix($l[5]) . "</td>\n"; TblCell($l[3], "?dv={$un}", "nowrap", "<a href=\"Devices-Status.php?dev={$un}\"><img src=\"img/16/sys.png\"></a>"); echo "<td>{$l['4']} (Vl{$l['9']} {$l['8']})</td><td>{$l['7']}</td><td bgcolor=\"{$tc}\" width=\"100\" nowrap>" . date($datfmt, $l[10]) . "</td>\n"; echo "<th><a href=\"?del={$l['0']}&dv={$ud}\"><img src=\"img/16/bcnl.png\" onclick=\"return confirm('Link {$l['0']} {$dellbl}?');\" title=\"{$l['0']} {$dellbl}\"></a></th></tr>\n"; $nli++; } DbFreeResult($res); } else { print DbError($link); } ?> </table> <table class="content" > <tr class="<?php echo $modgroup[$self]; ?>
</head> <body> <?php $link = DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('nodes', 's', 'nodes.*,location,speed,duplex,pvid,dinoct,doutoct,dinerr,douterr,dindis,doutdis,dinbrc', 'lastseen', '1', array('nodip'), array('='), array(ip2long($_SERVER[REMOTE_ADDR])), array(), 'LEFT JOIN devices USING (device) LEFT JOIN interfaces USING (device,ifname)'); $res = DbQuery($query, $link); if ($res) { $n = DbFetchRow($res); if ($n[2]) { $img = Nimg($n[3]); $l = explode($locsep, $n[23]); echo "<table class=\"mon2\">"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/oui/{$img}.png\" title=\"{$n['3']}\"></th><td><b>{$n['0']}</b></td><td class=\"mrn code\">{$n['2']}</td></tr>\n"; echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/net.png\" title=\"Network\"></th><td class=\"blu code\">" . long2ip($n[1]) . "</td><td class=\"prp code\">" . ($n[16] ? inet_ntop($n[16]) : '') . "</td></tr>\n"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/dev.png\" title=\"Device\"></th><td>{$n['6']}</td><td>{$l['2']} {$l['3']}</td></tr>\n"; echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/port.png\" title=\"Interface\"></th><td>{$n['7']}</td><td>" . DecFix($n[24]) . "-{$n['25']} vl{$n['8']}</td></tr>\n"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/grph.png\" title=\"In/Out\"></th><td colspan=\"2\">Traffic: <b class=\"blu code\">" . DecFix($n[27]) . "/" . DecFix($n[28]) . "</b> Errors:<b class=\"drd code\"> " . DecFix($n[29]) . "/" . DecFix($n[30]) . "</b> Discards:<b class=\"prp code\">" . DecFix($n[31]) . "/" . DecFix($n[32]) . " </b> Bcast:<b class=\"dgy code\"> " . DecFix($n[33]) . "</b></td></tr>\n"; echo "</table>"; } else { echo "<h4>{$_SERVER['REMOTE_ADDR']} was not found</h4>"; } DbFreeResult($res); } else { print DbError($link); } ?> </body>
if ($oto[$i] > 70){ # ...cauz some devs don't default to 0! $roo[$i] = ($ifs[$i])?round($doo[$i] / $ifs[$i] / $rrdstep * 800,1):0; $boo = "title=\"$roo[$i]%\" bgcolor=\"#".(($roo[$i] > $trfa)?sprintf("%02x","40" + $off):$bg3)."$bg3".sprintf("%02x","40" + $off)."\""; if ($doe[$i]){ $oer = $doe[$i] * $doe[$i] * 8/(($doo[$i])?$doo[$i]:1); # Relative err^2 with fix for / by 0 if ($oer > 55){$oer = 55;} $boe = "bgcolor=#".sprintf("%02x", $oer+ $off)."$bg3$bg3"; } } echo "<td $bio align=\"right\">".DecFix($dio[$i])."B</td>\n"; echo "<td $boo align=\"right\">".DecFix($doo[$i])."B</td>\n"; echo "<td $bie align=\"right\">".DecFix($die[$i])."</td>\n"; echo "<td $boe align=\"right\">".DecFix($doe[$i])."</td>\n"; echo "<td align=\"right\">".DecFix($did[$i])."</td>\n"; echo "<td align=\"right\">".DecFix($dod[$i])."</td>\n"; echo "<td align=\"right\">".DecFix($dib[$i])."</td>\n"; } if($ifp[$i]){ $tpow += $ifp[$i]/1000; $bp1 = sprintf("%02x",$ifp[$i]/280 + $off); echo "<td nowrap align=\"right\" bgcolor=\"#$bp1$bp1$bg3\">$ifp[$i]"; }else{ echo "<td nowrap align=\"right\" >"; } if( preg_match('/^..[P]/',$dev[27]) and $ifpst[$i] ){ if($isadmin and $wver){ echo (($ifpst[$i] == 1)?"<a href=\"?dev=$ud&pif=0$ifpsx[$i].$i\"><img src=\"img/16/bchk.png\" title=\"PoE $stco[100]\"></a>":"<a href=\"?dev=$ud&pif=1$ifpsx[$i].$i\"><img src=\"img/16/bdis.png\" title=\"PoE $dsalbl\"></a>"); }else{ echo (($ifpst[$i] == 1)?"<img src=\"img/16/bchk.png\" title=\"PoE $stco[100]\">":"<img src=\"img/16/bdis.png\" title=\"PoE $dsalbl\">"); }
function IntChart($mode, $dir, $ina, $opa, $sta, $lim, $ord, $opt) { global $link, $modgroup, $self, $rrdstep; global $laslbl, $totlbl, $loclbl, $locsep, $conlbl, $srtlbl, $trflbl, $errlbl, $inblbl, $oublbl, $idxlbl, $spdlbl, $acslbl, $nonlbl; $unt = ""; $grf = intval($_SESSION['gsiz'] / 2); $dti = $dir == "in" ? $inblbl : $oublbl; if ($opt) { $pes = 0; $d = ""; $bam = "si"; $abs = $totlbl; } else { $pes = 1; $d = "d"; $bam = "mi"; $abs = $laslbl; } if ($ord) { $ocol = "aval desc"; $sopt = ""; } else { $ocol = "rval desc"; $sopt = $mode == "trf" ? "/ {$spdlbl}" : "/ {$trflbl}"; } if ($mode == "trf") { $pes = 0; $col = "oct"; $tit = $trflbl; $ico = $dir == "in" ? "bbup" : "bbdn"; if ($opt) { $rel = "{$d}{$dir}oct/speed"; } else { $rel = "{$d}{$dir}oct/{$rrdstep}*8000/speed"; } $qry = GenQuery('interfaces', 's', "device,contact,location,icon,ifname,speed,iftype,ifidx,comment,alias,{$d}{$dir}oct as aval,{$rel} as rval", $ocol, $lim, array('speed', $ina), array('>', $opa), array('0', $sta), array('AND'), 'LEFT JOIN devices USING (device)'); } elseif ($mode == "err") { $col = "err"; $tit = $errlbl; $ico = $dir == "in" ? "brup" : "brdn"; $qry = GenQuery('interfaces', 's', "device,contact,location,icon,ifname,speed,iftype,ifidx,comment,alias,{$d}{$dir}{$col} as aval,{$d}{$dir}{$col}/{$d}{$dir}oct as rval", $ocol, $lim, array('iftype', "{$d}{$dir}{$col}", $ina), array('!=', '>', $opa), array('71', 0, $sta), array('AND', 'AND'), 'LEFT JOIN devices USING (device)'); } elseif ($mode == "dsc") { $col = "dis"; $tit = "Discards"; $ico = $dir == "in" ? "bbu2" : "bbd2"; $qry = GenQuery('interfaces', 's', "device,contact,location,icon,ifname,speed,iftype,ifidx,comment,alias,{$d}{$dir}{$col} as aval,{$d}{$dir}{$col}/{$d}{$dir}oct as rval", $ocol, $lim, array('iftype', "{$d}{$dir}{$col}", $ina), array('!=', '>', $opa), array('71', 0, $sta), array('AND', 'AND'), 'LEFT JOIN devices USING (device)'); } elseif ($mode == "brc") { $tit = "{$acslbl} Broadcasts"; $ico = "wlan"; $qry = GenQuery('interfaces', 's', "device,contact,location,icon,ifname,speed,iftype,ifidx,comment,alias,{$d}inbrc as aval,{$d}inbrc/{$d}inoct as rval", $ocol, $lim, array('comment', "{$d}inoct", $ina), array('!~', '>', $opa), array('DP:|MAC:', 0, $sta), array('AND', 'AND'), 'LEFT JOIN devices USING (device)'); } echo "<h2>{$abs} {$tit} {$dti}</h2>\n"; $res = DbQuery($qry, $link); if (DbNumRows($res)) { ?> <table class="content"> <tr class="<?php echo $modgroup[$self]; ?> 2"> <th colspan="2" width="30%"><img src="img/16/dev.png"><br>Device</th> <th><img src="img/16/port.png"><br>IF</th> <th colspan="2"><img src="img/16/<?php echo $ico; ?> .png"><br><?php echo $tit; ?> </th> </tr> <?php $row = 0; while ($r = DbFetchRow($res)) { if ($row % 2) { $bg = "txta"; $bi = "imga"; } else { $bg = "txtb"; $bi = "imgb"; } $row++; $ud = urlencode($r[0]); $ui = urlencode($r[4]); $l = explode($locsep, $r[2]); list($ifimg, $iftyp) = Iftype($r[6]); if ($grf) { if ($mode == "trf") { $gop = $r[5]; } elseif ($mode == "err") { $gop = 1; } else { $gop = 0; } $gr = "<img src=\"inc/drawrrd.php?dv={$ud}&if%5B%5D={$ui}&s={$grf}&t={$mode}&o={$gop}\" title=\"" . ($pes ? round($r[10] / $rrdstep, 1) . '/s' : DecFix($r[10])) . "\">"; } else { $gr = DecFix($r[10]); } TblRow($bg); echo "<th class=\"{$bi}\"><a href=\"Devices-Status.php?dev={$ud}\"><img src=\"img/dev/{$r['3']}.png\" title=\"{$conlbl}: {$r['1']}, {$loclbl}: {$l['0']} {$l['1']} {$l['2']}\"></a></th>\n"; echo "<td><b>" . substr($r[0], 0, $_SESSION['lsiz']) . "</b></td>\n"; echo "<td><img src=\"img/{$ifimg}\" title=\"{$iftyp} {$idxlbl} {$r['7']}\"><a href=\"Nodes-List.php?in[]=device&op[]==&st[]={$ud}&co[]=AND&in[]=ifname&op[]==&st[]={$ui}\">{$r['4']}</a> " . DecFix($r[5]) . " {$r['8']} {$r['9']}</td>\n"; echo "<th><a href=\"Devices-Graph.php?dv={$ud}&if%5B%5D={$ui}&it%5B%5D=" . substr($mode, 0, 1) . "\">{$gr}</a></th>\n"; echo "<td nowrap>"; if ($mode == "trf" and !$opt) { echo Bar($r[11] / 10, 45) . ' ' . round($r[11] / 10, 1) . '%'; } elseif ($mode == "brc") { echo Bar($r[10], "lvl100", $bam) . " " . DecFix($r[10]); } else { echo Bar($r[10], 10, $bam) . " " . DecFix($r[10]); } echo "</td></tr>\n"; } ?> </table> <table class="content" > <tr class="<?php echo $modgroup[$self]; ?> 2"><td><?php echo $row; ?> IF, <?php echo $srtlbl; ?> : <?php echo $tit; ?> <?php echo $sopt; ?> </td></tr> </table> <p> <?php } else { echo "<h5>{$nonlbl}</h5>"; } }
TblCell(DecFix($if[18]) . "B", "", "align=\"right\""); } if (in_array("dinerr", $col)) { TblCell(DecFix($if[17]), "", "align=\"right\""); } if (in_array("douterr", $col)) { TblCell(DecFix($if[19]), "", "align=\"right\""); } if (in_array("dindis", $col)) { TblCell(DecFix($if[22]), "", "align=\"right\""); } if (in_array("doutdis", $col)) { TblCell(DecFix($if[23]), "", "align=\"right\""); } if (in_array("dinbrc", $col)) { TblCell(DecFix($if[25]), "", "align=\"right\""); } if (in_array("poe", $col)) { TblCell($if[27] . "mW", "?in[]=poe&op[]==&st[]={$if['27']}", "align=\"right\""); } if (in_array("comment", $col)) { TblCell($if[28]); } if (in_array("trafalert", $col)) { TblCell($if[29] . '%'); } if (in_array("bcastalert", $col)) { TblCell($if[30] . '/s'); } if (in_array("macflood", $col)) { TblCell($if[31]);
} } if( in_array("gfNS",$col) and !isset($_GET['xls']) ){ echo "<td>"; $gsiz = ($_SESSION['gsiz'] == 4)?2:1; if( substr($dev[27],1,1) == "C" ) echo "<a href=\"Devices-Graph.php?dv=$ud&if[]=cpu\"><img src=\"inc/drawrrd.php?dv=$ud&t=cpu&s=$gsiz\" title=\"$dev[20]% CPU $lodlbl\">\n"; if($dev[21]) echo "<a href=\"Devices-Graph.php?dv=$ud&if[]=mem\"><img src=\"inc/drawrrd.php?dv=$ud&t=mem&s=$gsiz\" title=\"".(($dev[21] > 100)?DecFix($dev[21]).'B':$dev[21].'%')." $memlbl $frelbl\">\n"; if($dev[22]) echo "<a href=\"Devices-Graph.php?dv=$ud&if[]=tmp\"><img src=\"inc/drawrrd.php?dv=$ud&t=tmp&s=$gsiz\" title=\"$tmplbl ".(($_SESSION['far'])?($dev[22]*1.8+32)."F":"$dev[22]C")."\">\n"; if($dev[23]){ if($dev[24] and $dev[24] != 'MemIO'){ list($ct,$cy,$cu) = explode(";", $dev[24]); }else{ $ct = "$memlbl IO"; $cu = "Bytes $frelbl"; } echo "<a href=\"Devices-Graph.php?dv=$ud&if[]=cuv\"><img src=\"inc/drawrrd.php?dv=$ud&if[]=".urlencode($ct)."&if[]=".urlencode($cu)."&s=$gsiz&t=cuv\" title=\"$ct ".DecFix($dev[23])." $cu\">"; } echo "</td>"; } } echo "</tr>\n"; } DbFreeResult($res); }else{ print DbError($link); } ?> </table> <table class="content"> <tr class="<?= $modgroup[$self] ?>2"><td><?= $row ?> Devices<?= ($ord)?", $srtlbl: $ord":"" ?><?= ($lim)?", $limlbl: $lim":"" ?></td></tr>
function IfGraphs($ud, $ui, $opt, $sz) { global $trflbl, $errlbl, $stalbl, $inblbl, $maxlbl; if ($sz) { $sz -= 1; ?> <a href="Devices-Graph.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &it%5B%5D=t"> <img src="inc/drawrrd.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &s=<?php echo $sz; ?> &t=trf&o=<?php echo $opt; ?> " title="<?php echo $trflbl; ?> <?php echo $sz == 1 ? " {$maxlbl} " . DecFix($opt) : ""; ?> "> </a> <a href="Devices-Graph.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &it%5B%5D=e"> <img src="inc/drawrrd.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &s=<?php echo $sz; ?> &t=err&o=1" title="<?php echo $errlbl; ?> "> </a> <a href="Devices-Graph.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &it%5B%5D=d"> <img src="inc/drawrrd.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &s=<?php echo $sz; ?> &t=dsc" title="Discards"> </a> <a href="Devices-Graph.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &it%5B%5D=b"> <img src="inc/drawrrd.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &s=<?php echo $sz; ?> &t=brc&o=100" title="Broadcast <?php echo $inblbl; ?> <?php echo $sz == 1 ? " {$maxlbl} 100" : ""; ?> "> </a> <a href="Devices-Graph.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &it%5B%5D=s"> <img src="inc/drawrrd.php?dv=<?php echo $ud; ?> &if%5B%5D=<?php echo $ui; ?> &s=<?php echo $sz; ?> &t=sta" title="<?php echo $stalbl; ?> "> </a> <?php } else { echo "---"; } }
TblCell($l[16], "?in[]=contact&op[]==&st[]=" . urlencode($l[16])); } if (in_array("firstdis", $col)) { TblCell(date($datfmt, $l[12]), "?in[]=firstdis&op[]==&st[]={$l['12']}", "bgcolor=\"#{$fc}\""); } if (in_array("lastdis", $col)) { TblCell(date($datfmt, $l[13]), "?in[]=lastdis&op[]==&st[]={$l['13']}", "bgcolor=\"#{$lc}\""); } if (in_array("neighbor", $col)) { TblCell($l[3], "?in[]=device&op[]==&st[]={$un}&ord=ifname", "nowrap", "<a href=\"Devices-Status.php?dev={$un}\"><img src=\"img/16/sys.png\"></a><a href=\"Topology-Linked.php?dv={$un}\"><img src=\"img/16/ncfg.png\"></a>"); } if (in_array("nbrifname", $col)) { TblCell($l[4]); } if (in_array("bandwidth", $col)) { TblCell(DecFix($l[5])); } if (in_array("linktype", $col)) { TblCell($l[6], "?in[]=linktype&op[]==&st[]={$l['6']}"); } if (in_array("linkdesc", $col)) { TblCell($l[7]); } if (in_array("nbrduplex", $col)) { TblCell($l[8]); } if (in_array("nbrvlanid", $col)) { TblCell($l[9]); } if (in_array("time", $col)) { TblCell(date($datfmt, $l[10]), "?in[]=time&op[]==&st[]={$l['10']}", "bgcolor=\"#{$tc}\"");
} if( in_array("device",$col) ){ TblCell($n[6],"?in[]=device&op[]==&st[]=$ud&ord=ifname","nowrap","<a href=\"Devices-Status.php?dev=$ud&pop=on\"><img src=\"img/16/sys.png\"></a>"); } if(in_array("type",$col)){ TblCell( $n[23],"?in[]=type&op[]==&st[]=".urlencode($n[23]) );} if(in_array("location",$col)){ TblCell( $n[24],"?in[]=location&op[]==&st[]=".urlencode($n[24]) );} if(in_array("contact",$col)){ TblCell( $n[25],"?in[]=contact&op[]==&st[]=".urlencode($n[25]) );} if( in_array("ifname",$col) ){ list($ifimg,$iftit) = Iftype($n[26]); list($ifbg,$ifst) = Ifdbstat($n[29]); TblCell($n[7],"?in[]=device&op[]==&in[]=ifname&op[]==&st[]=$ud&co[]=AND&st[]=$ui","class=\"$ifbg\"","<img src=\"img/$ifimg\" title=\"$iftit, $ifst\">",'td-img'); } if(in_array("ifdesc",$col)){ TblCell($n[27]);} if(in_array("alias",$col)){ TblCell($n[28]);} if(in_array("speed",$col)){ TblCell( DecFix($n[30]),"","align=\"right\"" );} if(in_array("duplex",$col)) {TblCell($n[31]);} if(in_array("vlanid",$col)) {TblCell( ($n[9] < 255)?"SSID:$n[8]":$n[8],"?in[]=vlanid&op[]==&st[]=$n[8]","align=\"right\"");} if(in_array("pvid",$col)) {TblCell( ($n[9] < 255)?"CH:$n[32]":$n[32],"?in[]=vlanid&op[]==&st[]=$n[8]","align=\"right\"");} if(in_array("ifmetric",$col)){ TblCell( (($n[9] < 255)?Bar($n[9],-30,'mi')." $n[9]db":"$n[9]"),"?in[]=ifmetric&op[]==&st[]=$n[9]","nowrap" );} if(in_array("ifupdate",$col)){ list($i1c,$i2c) = Agecol($n[10],$n[10],$row % 2); TblCell( date($datfmt,$n[10]),"","nowrap bgcolor=\"#$i1c\""); } if(in_array("ifchanges",$col)){ TblCell($n[11],"?in[]=ifchanges&op[]==&st[]=$n[11]");} if(in_array("lastchg",$col)){ list($i1l,$i2l) = Agecol($n[33],$n[33],$row % 2); TblCell(date($datfmt,$n[33]),"?in[]=lastchg&op[]==&st[]=$n[33]","nowrap bgcolor=\"#$i1l\""); } if(in_array("dinerr",$col)) {TblCell($n[34]);} if(in_array("douterr",$col)) {TblCell($n[35]);}
function DirList($dir,$opt,$lvl){ global $row,$sub,$upllbl,$levlbl,$dellbl,$edilbl,$cfmmsg,$isadmin; $tsiz = 0; $ed = ''; foreach (glob("$dir/*") as $f){ if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";} $row++; $plen = strlen($dir); $t = substr($f,$plen+1); TblRow($bg); echo "<td class=\"$bi\" width=\"20\" nowrap>"; $i=0; while ($i < $lvl) { echo "<img src=\"img/sub.png\">"; $i++; } $i=0; if(is_dir($f)){ if($lvl and $opt == "web"){ echo "<a href=\"?sub=$f&mde=o\"><img src=\"img/16/".(($f == $sub)?'foye':'fogy').".png\" title=\"$upllbl $levlbl $lvl\"></a></td>"; }else{ echo "<img src=\"img/16/fogy.png\" title=\"Folder $levlbl $lvl\">"; } echo "</td><td colspan=\"4\">$t"; if($isadmin){ echo "<span style=\"float:right\"><a href=\"?del=".urlencode($f)."\"> <img src=\"img/16/bcnl.png\" onclick=\"return confirm('$dellbl, $cfmmsg')\" title=\"$dellbl!\"></a></span>"; } echo "</td></tr>\n"; $tsiz += DirList("$dir/$t",$opt,$lvl+1); }else{ list($ico,$ed) = FileImg($f); echo "$ico</td><td>"; if($opt == "web"){ echo "<a href=\"$f\" target=\"window\">$t</a></td>"; }else{ echo "$t</td>"; } $siz = filesize($f); $tsiz += $siz; echo "<td align=\"right\">".DecFix($siz)."</td><td align=\"right\">".date ($_SESSION['date'],filemtime($f))."<td align=\"right\">"; if($isadmin){ if($opt == "tftp" and $ed){ echo "<a href=\"?tft=".urlencode($t)."\"><img src=\"img/16/note.png\" title=\"$edilbl\"></a>"; } echo "<a href=\"?del=".urlencode($f)."\"><img src=\"img/16/bcnl.png\" onclick=\"return confirm('$dellbl, $cfmmsg')\" title=\"$dellbl!\"></a>"; } echo "</td></tr>\n"; } } return $tsiz; }