mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixed some cosmetic issues with cisco graphs. Added cisco-specific OID for getting better ifType.
git-svn-id: http://www.observium.org/svn/observer/trunk@60 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -18,7 +18,10 @@
|
||||
$device = getifhost($_GET['if']);
|
||||
$ifIndex = getifindexbyid($_GET['if']);
|
||||
}
|
||||
$hostname = gethostbyid($device);
|
||||
if($device) {
|
||||
$hostname = gethostbyid($device);
|
||||
}
|
||||
|
||||
$from = $_GET['from'];
|
||||
$to = $_GET['to'];
|
||||
$width = $_GET['width'];
|
||||
@@ -34,6 +37,9 @@
|
||||
|
||||
switch ($type) {
|
||||
|
||||
case 'global_bits':
|
||||
$graph = graph_global_bits ("global_bits.png", $from, $to, $width, $height);
|
||||
break;
|
||||
case 'device_bits':
|
||||
$graph = graph_device_bits ($device, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
|
||||
$graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits";
|
||||
echo("<tr style=\"background-color: $bg; padding: 5px;\" valign=top>
|
||||
<td valign=top width=275>
|
||||
<td valign=top width=300>
|
||||
<span class=list-large><a onmouseover=\"return overlib('<img src=\'$graph_url\'>');\" onmouseout=\"return nd();\"
|
||||
class='$ifclass' href='?page=interface&id=$interface[id]'>
|
||||
$i. $inf
|
||||
@@ -27,9 +27,9 @@
|
||||
$break = " ";
|
||||
}
|
||||
echo("</span>");
|
||||
echo("</td><td width=80>");
|
||||
echo("</td><td width=70>");
|
||||
if($speed && $speed != "") { echo("<span class=box-desc>$speed</span>"); }
|
||||
echo("</td><td width=80>");
|
||||
echo("</td><td width=110>");
|
||||
if($iftype && $iftype != "") { echo("<span class=box-desc>$iftype</span>"); } else { echo("-"); }
|
||||
echo("</td><td width=80>");
|
||||
if($mac && $mac != "") { echo("<span class=box-desc>$mac</span>"); } else { echo("-"); }
|
||||
|
@@ -10,14 +10,16 @@
|
||||
|
||||
while($data = mysql_fetch_array($query)) {
|
||||
unset($class);
|
||||
$iid = $data[iid];
|
||||
$ifIndex = $data[ifIndex];
|
||||
$did = $data[did];
|
||||
$hostname = $data[hostname];
|
||||
$up = $data[up];
|
||||
$up_admin = $data[up_admin];
|
||||
$ifname = fixifname($data[ifname]);
|
||||
$ifalias = $data[ifalias];
|
||||
$iid = $data['iid'];
|
||||
$ifIndex = $data['ifIndex'];
|
||||
$did = $data['did'];
|
||||
$device[id] = $did;
|
||||
$device['hostname'] = $data['hostname'];
|
||||
$hostname = $data['hostname'];
|
||||
$up = $data['up'];
|
||||
$up_admin = $data['up_admin'];
|
||||
$ifname = fixifname($data['ifname']);
|
||||
$ifalias = $data['ifalias'];
|
||||
$ifalias = str_replace("Cust: ", "", $ifalias);
|
||||
$ifalias = str_replace("[PNI]", "Private", $ifalias);
|
||||
$ifclass = ifclass($up, $up_admin);
|
||||
@@ -47,9 +49,9 @@
|
||||
echo("
|
||||
<tr bgcolor='$bg'>
|
||||
<td width='7'></td>
|
||||
<td width='250'><span class=interface>$useifalias</span></td>
|
||||
<td width='200'><a href='?page=device&id=$did' $mouseoverhost>$hostname</a></td>
|
||||
<td width='100'><a href='?page=interface&id=$iid' class=$ifclass $mouseoverint><span class=interface-desc>$ifname</span></td>
|
||||
<td width='250'><span style='font-weight: bold;' class=interface>$useifalias</span></td>
|
||||
<td width='200'>" . generatedevicelink($device) . "</td>
|
||||
<td width='100'>" . generateiflink($data, makeshortif($data['if'])) . "</td>
|
||||
<td>$notes</td>
|
||||
</tr>
|
||||
");
|
||||
|
@@ -338,6 +338,7 @@ function fixifName ($inf) {
|
||||
$inf = str_replace("-802.1q Vlan subif", "", $inf);
|
||||
$inf = str_replace("serial", "Serial", $inf);
|
||||
$inf = str_replace("-aal5 layer", " aal5", $inf);
|
||||
$inf = str_replace("null", "Null", $inf);
|
||||
$inf = str_replace("atm", "ATM", $inf);
|
||||
$inf = str_replace("port-channel", "Port-Channel", $inf);
|
||||
$inf = str_replace("dial", "Dial", $inf);
|
||||
@@ -535,17 +536,19 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height)
|
||||
"--title", $title,
|
||||
"DEF:5s=$database:LOAD5S:AVERAGE",
|
||||
"DEF:5m=$database:LOAD5M:AVERAGE",
|
||||
"AREA:5s#FAFDCE:5sec",
|
||||
"LINE1.25:5s#dd8800:",
|
||||
"GPRINT:5s:LAST:Cur\:%6.2lf",
|
||||
"GPRINT:5s:AVERAGE:Avg\: %6.2lf",
|
||||
"GPRINT:5s:MIN:Min\:%6.2lf",
|
||||
"GPRINT:5s:MAX:Max\:%6.2lf\\n",
|
||||
"COMMENT: Days Current Minimum Maximum Average\\n",
|
||||
"AREA:5m#c5aa00:",
|
||||
"AREA:5s#ffeeaa:5 sec",
|
||||
"LINE1:5s#ea8f00:",
|
||||
"GPRINT:5s:LAST:%6.2lf ",
|
||||
"GPRINT:5s:AVERAGE:%6.2lf ",
|
||||
"GPRINT:5s:MAX:%6.2lf ",
|
||||
"GPRINT:5s:AVERAGE:%6.2lf\\n",
|
||||
"LINE1.25:5m#aa2200:5min",
|
||||
"GPRINT:5m:LAST:Cur\:%6.2lf",
|
||||
"GPRINT:5m:AVERAGE:Avg\: %6.2lf",
|
||||
"GPRINT:5m:MIN:Min\:%6.2lf",
|
||||
"GPRINT:5m:MAX:Max\:%6.2lf\\n");
|
||||
"GPRINT:5m:LAST:%6.2lf ",
|
||||
"GPRINT:5m:AVERAGE:%6.2lf ",
|
||||
"GPRINT:5m:MAX:%6.2lf ",
|
||||
"GPRINT:5m:AVERAGE:%6.2lf\\n");
|
||||
|
||||
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
|
||||
"--font", "AXIS:6:$mono_font",
|
||||
@@ -556,45 +559,7 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height)
|
||||
|
||||
if( !is_array($ret) ) {
|
||||
$err = rrd_error();
|
||||
#echo "rrd_graph() ERROR: $err\n";
|
||||
return FALSE;
|
||||
} else {
|
||||
return $imgfile;
|
||||
}
|
||||
}
|
||||
|
||||
function tempgraph ($rrd, $graph, $from, $to, $width, $height, $title, $vertical)
|
||||
{
|
||||
global $rrdtool, $installdir, $mono_font;
|
||||
$database = "rrd/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
|
||||
$optsa = array( "--start", $from, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
|
||||
"-E", "-l 0", "--title", $title,
|
||||
"DEF:in=$database:TEMPIN1:AVERAGE",
|
||||
"DEF:out=$database:TEMPOUT1:AVERAGE",
|
||||
"LINE1.5:in#cc0000:Inlet ",
|
||||
"GPRINT:in:LAST: Cur\:%6.2lf",
|
||||
"GPRINT:in:AVERAGE:Avg\: %6.2lf",
|
||||
"GPRINT:in:MIN:Min\:%6.2lf",
|
||||
"GPRINT:in:MAX:Max\:%6.2lf\\n",
|
||||
"LINE1.25:out#009900:Outlet ",
|
||||
"GPRINT:out:LAST:Cur\:%6.2lf",
|
||||
"GPRINT:out:AVERAGE:Avg\: %6.2lf",
|
||||
"GPRINT:out:MIN:Min\:%6.2lf",
|
||||
"GPRINT:out:MAX:Max\:%6.2lf\\n");
|
||||
|
||||
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
|
||||
"--font", "AXIS:6:$mono_font",
|
||||
"--font-render-mode", "normal");}
|
||||
$opts = array_merge($optsa, $optsb);
|
||||
|
||||
|
||||
$ret = rrd_graph("$imgfile", $opts, count($opts));
|
||||
|
||||
if( !is_array($ret) ) {
|
||||
$err = rrd_error();
|
||||
# echo "rrd_graph() ERROR: $err\n";
|
||||
echo "rrd_graph() ERROR: $err\n";
|
||||
return FALSE;
|
||||
} else {
|
||||
return $imgfile;
|
||||
@@ -610,11 +575,13 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti
|
||||
"-E", "-l 0",
|
||||
"DEF:uptime=$rrd:uptime:AVERAGE",
|
||||
"CDEF:cuptime=uptime,86400,/",
|
||||
"COMMENT: Days Current Minimum Maximum Average\\n",
|
||||
"AREA:cuptime#EEEEEE:Uptime",
|
||||
"LINE1.25:cuptime#36393D:",
|
||||
"GPRINT:cuptime:LAST:Cur\:%6.2lf",
|
||||
"GPRINT:cuptime:AVERAGE:Avg\: %6.2lf",
|
||||
"GPRINT:cuptime:MAX:Max\:%6.2lf\\n");
|
||||
"GPRINT:cuptime:LAST:%6.2lf ",
|
||||
"GPRINT:cuptime:AVERAGE:%6.2lf ",
|
||||
"GPRINT:cuptime:MAX:%6.2lf ",
|
||||
"GPRINT:cuptime:AVERAGE:%6.2lf\\n");
|
||||
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
|
||||
"--font", "AXIS:6:$mono_font",
|
||||
"--font-render-mode", "normal");}
|
||||
@@ -625,7 +592,7 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti
|
||||
|
||||
if( !is_array($ret) ) {
|
||||
$err = rrd_error();
|
||||
# echo "rrd_graph() ERROR: $err\n";
|
||||
# echo "rrd_graph() ERROR: $err\n";
|
||||
return FALSE;
|
||||
} else {
|
||||
return $imgfile;
|
||||
@@ -651,9 +618,19 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical
|
||||
DEF:PROCUSED=$memrrd:PROCUSED:AVERAGE \
|
||||
CDEF:FREE=IOFREE,PROCFREE,+ \
|
||||
CDEF:USED=IOUSED,PROCUSED,+ \
|
||||
AREA:USED#ee9900:Used \
|
||||
AREA:FREE#FAFDCE:Free:STACK \
|
||||
LINE1.5:MEMTOTAL#cc0000:";
|
||||
COMMENT:'Bytes Current Minimum Maximum Average\\n' \
|
||||
AREA:USED#f0e0a0:Used\
|
||||
GPRINT:USED:LAST:\%6.2lf%s\
|
||||
GPRINT:USED:MIN:%6.2lf%s\
|
||||
GPRINT:USED:MAX:%6.2lf%s\
|
||||
GPRINT:USED:AVERAGE:'%6.2lf%s \\n'\
|
||||
AREA:FREE#cccccc:Free:STACK\
|
||||
GPRINT:FREE:LAST:\%6.2lf%s\
|
||||
GPRINT:FREE:MIN:%6.2lf%s\
|
||||
GPRINT:FREE:MAX:%6.2lf%s\
|
||||
GPRINT:FREE:AVERAGE:%6.2lf%s\
|
||||
LINE1:USED#d0b080:\
|
||||
LINE1:MEMTOTAL#000000:";
|
||||
|
||||
if($width <= "300") {$opts .= "\
|
||||
--font LEGEND:7:$mono_font \
|
||||
|
@@ -40,6 +40,91 @@ function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vert
|
||||
}
|
||||
}
|
||||
|
||||
function graph_global_bits ($graph, $from, $to, $width, $height) {
|
||||
|
||||
global $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
$imgfile = "graphs/" . $graph;
|
||||
$opts = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
|
||||
|
||||
$query = mysql_query("SELECT `ifIndex`, I.id as id, D.hostname FROM `interfaces` AS I, `devices` AS D WHERE I.host = D.id AND I.iftype LIKE '%ethernet%'");
|
||||
|
||||
while($int = mysql_fetch_row($query)) {
|
||||
$hostname = $int[2];
|
||||
$id = $int[1];
|
||||
if(is_file($rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd")) {
|
||||
$opts .= "DEF:inoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:INOCTETS:AVERAGE \
|
||||
DEF:outoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:OUTOCTETS:AVERAGE \
|
||||
";
|
||||
$in_thing .= $seperator . "inoctets" . $int[1] . ",UN,0," . "inoctets" . $int[1] . ",IF";
|
||||
$out_thing .= $seperator . "outoctets" . $int[1] . ",UN,0," . "outoctets" . $int[1] . ",IF";
|
||||
$pluses .= $plus;
|
||||
$seperator = ",";
|
||||
$plus = ",+";
|
||||
}
|
||||
}
|
||||
|
||||
$opts .= " CDEF:inoctets=" . $in_thing . $pluses . " \
|
||||
CDEF:outoctets=" . $out_thing . $pluses . " \
|
||||
CDEF:doutoctets=outoctets,-1,* \
|
||||
CDEF:inbits=inoctets,8,* \
|
||||
CDEF:outbits=outoctets,8,* \
|
||||
CDEF:doutbits=doutoctets,8,* \
|
||||
AREA:inbits#CDEB8B: \
|
||||
COMMENT:BPS Current Average Max 95th %\\n \
|
||||
LINE1.25:inbits#006600:In \
|
||||
GPRINT:inbits:LAST:%6.2lf%s \
|
||||
GPRINT:inbits:AVERAGE:%6.2lf%s \
|
||||
GPRINT:inbits:MAX:%6.2lf%s\l \
|
||||
AREA:doutbits#C3D9FF: \
|
||||
LINE1.25:doutbits#000099:Out \
|
||||
GPRINT:outbits:LAST:%6.2lf%s \
|
||||
GPRINT:outbits:AVERAGE:%6.2lf%s \
|
||||
GPRINT:outbits:MAX:%6.2lf%s ";
|
||||
|
||||
|
||||
if($width <= '300') {
|
||||
$opts .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal ";
|
||||
}
|
||||
|
||||
echo("<pre>");
|
||||
echo($imgfile . "\n" . $opts);
|
||||
|
||||
|
||||
$cmd = "/usr/bin/rrdtool";
|
||||
|
||||
`rm /tmp/poo`;
|
||||
$handle = fopen("/tmp/poo", "w");
|
||||
fwrite($handle, " graph test.png " . $opts);
|
||||
|
||||
if (( $fh = popen($cmd, 'r')) === false)
|
||||
die("Open failed : ${php_errormsg}\n");
|
||||
|
||||
fwrite($fh, " graph $imgfile " . $opts);
|
||||
|
||||
|
||||
pclose($fh);
|
||||
|
||||
|
||||
|
||||
echo`$rrdtool graph $imgfile $opts`;
|
||||
|
||||
|
||||
# $ret = rrd_graph("$imgfile", $opts, count($opts));
|
||||
|
||||
# if( !is_array($ret) )
|
||||
# {
|
||||
# $err = rrd_error();
|
||||
# echo "rrd_graph() ERROR: $err\n";
|
||||
# if ( !is_file($installdir . $imgfile) ) {
|
||||
# return FALSE;
|
||||
# } else {
|
||||
return $imgfile;
|
||||
# }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function graph_device_bits ($device, $graph, $from, $to, $width, $height)
|
||||
{
|
||||
global $rrdtool, $installdir, $mono_font, $rrd_dir;
|
||||
@@ -76,7 +161,7 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height)
|
||||
"CDEF:outbits=outoctets,8,*",
|
||||
"CDEF:doutbits=doutoctets,8,*",
|
||||
"AREA:inbits#CDEB8B:",
|
||||
"COMMENT:BPS Current Average Max 95th %\\n",
|
||||
"COMMENT:BPS Current Average Max\\n",
|
||||
"LINE1.25:inbits#006600:In ",
|
||||
"GPRINT:inbits:LAST:%6.2lf%s",
|
||||
"GPRINT:inbits:AVERAGE:%6.2lf%s",
|
||||
|
@@ -28,7 +28,6 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
$snmp_output = trim($snmp_output);
|
||||
$snmp_output = str_replace("No Such Object available on this agent at this OID", "", $snmp_output);
|
||||
$snmp_output = str_replace("No Such Instance currently exists at this OID", "", $snmp_output);
|
||||
|
||||
$ifPhysAddress = strtolower(str_replace("\"", "", $ifPhysAddress));
|
||||
$ifPhysAddress = str_replace(" ", ":", $ifPhysAddress);
|
||||
echo("Looking at $old_if on $hostname \n");
|
||||
@@ -39,6 +38,8 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
if ($ifAlias == " ") { $ifAlias = str_replace(" ", "", $ifAlias); }
|
||||
$ifAlias = trim(str_replace("\"", "", $ifAlias));
|
||||
$ifAlias = trim($ifAlias);
|
||||
if($interface['os'] == "IOS") { $ifType = trim(str_replace("\"", "", `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.9.2.2.1.1.1.$ifIndex`)); }
|
||||
|
||||
|
||||
$rrdfile = "rrd/" . $hostname . ".". $ifIndex . ".rrd";
|
||||
if(!is_file($rrdfile)) {
|
||||
|
Reference in New Issue
Block a user