Lots of pretty things!

git-svn-id: http://www.observium.org/svn/observer/trunk@99 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-06-06 09:23:41 +00:00
parent ad4160c2ea
commit b8e3ba656a
14 changed files with 154 additions and 48 deletions

View File

@@ -5,7 +5,7 @@ include("includes/functions.php");
$device_query = mysql_query("SELECT * FROM `devices` WHERE `os` = 'IOS' AND `status` = '1'");
while ($device = mysql_fetch_array($device_query)) {
$id = $device['id'];
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
echo("Detecting IOS temperature sensors for $hostname\n");

View File

@@ -69,14 +69,13 @@ while ($sensor = mysql_fetch_array($query)) {
$i = 0;
while ($i < count($temp_exists) && !$exists) {
$thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid'];
if ($temp_exists[$i] == $thistemp) { $exists = 1; echo("Match!"); }
if ($temp_exists[$i] == $thistemp) { $exists = 1; }
$i++;
echo("$temp_exists[$i] == $thistemp \n");
}
if(!$exists) {
echo("Deleting...\n");
# mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'");
mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'");
}

View File

@@ -58,8 +58,11 @@
case 'uptime':
$graph = uptimegraph ($hostname . "-uptime.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'unixfs_dev':
$graph = unixfsgraph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'unixfs':
$graph = unixfsgraph ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
$graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'calls':
$graph = callsgraphSNOM ($hostname . "-data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
@@ -90,7 +93,10 @@
}
break;
case 'temp':
$graph = temp_graph ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
$graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'dev_temp':
$graph = temp_graph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'mem':
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {

View File

@@ -1,15 +1,15 @@
<?php
$daily_traffic = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=333&height=100";
$daily_traffic = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=217&height=100";
$daily_url = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=550&height=175";
$weekly_traffic = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=333&height=100";
$weekly_traffic = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=217&height=100";
$weekly_url = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=550&height=175";
$monthly_traffic = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=333&height=100";
$monthly_traffic = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=217&height=100";
$monthly_url = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=550&height=175";
$yearly_traffic = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=333&height=100";
$yearly_traffic = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=217&height=100";
$yearly_url = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=550&height=175";
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">

View File

@@ -76,14 +76,14 @@ echo(" <li><hr width=140 /></li>
</li>
<li><a class="menu2four" href="?page=locations"><img src='/images/16/building.png' border=0 align=absmiddle> Locations</a></li>
<li><a><img src='/images/16/connect.png' border=0 align=absmiddle> Interfaces
<li><a><img src='/images/16/connect.png' border=0 align=absmiddle> Ports
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href='?page=interfaces'><img src='/images/16/connect.png' border=0 align=absmiddle> All Interfaces</a></li>
<li><a href='?page=interfaces'><img src='/images/16/connect.png' border=0 align=absmiddle> All Ports</a></li>
<li><hr width=140 /></li>
<?php
@@ -98,17 +98,14 @@ if($interface_alerts) {
echo("<li><a href='?page=interfaces&status=0'><img src='/images/16/link_error.png' border=0 align=absmiddle> Alerts ($interface_alerts)</a></li>");
}
?>
</ul></td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li><a class="menu2four" href="?page=temperatures"><img src='/images/16/weather_sun.png' border=0 align=absmiddle> Temperatures</a></li>
<li style='float: right;'><a href='?page=configuration'><img src='/images/16/wrench.png' border=0 align=absmiddle> Configuration</a></li>
</ul>

View File

@@ -23,7 +23,7 @@ if(!$samehost) {
echo("
<tr style=\"background-color: $bg; padding: 5px;\"><td valign=top>" . $service['service_id'] . ".</td>");
<tr style=\"background-color: $bg; padding: 5px;\">");
if($device_id) {
if(!$samehost) {

View File

@@ -5,7 +5,6 @@ while($device = mysql_fetch_array($device_query)) {
$hostname = $device[hostname];
$bg="#ffffff";
echo("<div style='clear: both;'>");
switch ($device['os']) {
@@ -62,13 +61,13 @@ while($device = mysql_fetch_array($device_query)) {
if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Storage</div>");
$graph_type = "unixfs"; include ("includes/print-device-graph.php");
$graph_type = "unixfs_dev"; include ("includes/print-device-graph.php");
echo("<br />");
}
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "temp"; include ("includes/print-device-graph.php");
$graph_type = "dev_temp"; include ("includes/print-device-graph.php");
echo("<br />");
}
echo("<div class=graphhead>IP Statistics</div>");
@@ -124,9 +123,9 @@ while($device = mysql_fetch_array($device_query)) {
echo("<br />");
$graph_type = "mem"; include ("includes/print-device-graph.php");
echo("<br />");
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '$device[id]'"),0)) {
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "temp"; include ("includes/print-device-graph.php");
$graph_type = "dev_temp"; include ("includes/print-device-graph.php");
echo("<br />");
}
echo("<div class=graphhead>IP Statistics</div>");

View File

@@ -37,6 +37,7 @@ if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id
echo("<p class=sectionhead>Storage</p>");
echo("<table width=100%>");
$i = '1';
echo("<tr class=tablehead><td>Mountpoint</td><td width=203>Usage</td><td width=40>%</td><td width=75>Total</td>
<td width=75>Used</td></tr>");
$drives = mysql_query("SELECT * FROM `storage` WHERE host_id = '" . $device['device_id'] . "'");
@@ -46,8 +47,12 @@ if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id
$perc = $drive['storage_perc'];
$total = formatStorage($total);
$used = formatStorage($used);
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
if($perc > '80') { $drv_class='red'; } else { $drvclass=''; }
echo("<tr><td class=tablehead>" . $drive['hrStorageDescr'] . "</td><td><img src='percentage.php?per=" . $perc . "'>
echo("<tr><td class=tablehead>" . $drive['hrStorageDescr'] . "</td><td><a href='#' $store_popup><img src='percentage.php?per=" . $perc . "'></a>
</td><td>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td></tr>");
$i++;
}

View File

@@ -2,33 +2,25 @@
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
if($_GET['id']) {
$type = $_GET['id'];
$sql = "select *, I.id as iid, I.ifIndex as ifIndex, D.id as did, D.hostname as hostname, I.if as ifname, I.name as ifalias ";
$sql .= "from interfaces as I, devices as D WHERE `name` like '$type: %' AND I.host = D.id ORDER BY I.name";
if($_GET['type']) {
$type = $_GET['type'];
$sql = "select * from interfaces as I, devices as D WHERE `ifAlias` like '$type: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
while($data = mysql_fetch_array($query)) {
$done = "yes";
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];
$ifalias = str_replace($type . ": ", "", $ifalias);
$ifalias = str_replace("[PNI]", "Private", $ifalias);
$ifclass = ifclass($up, $up_admin);
$data['ifAlias'] = str_replace($type . ": ", "", $data['ifAlias']);
$data['ifAlias'] = str_replace("[PNI]", "Private", $data['ifAlias']);
$ifclass = ifclass($data['ifOperStatus'], $data['ifAdminStatus']);
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
echo("<tr bgcolor='$bg'>
<td><span class=interface><a href='?page=interface&id=$iid'>$ifalias</a></span><br />
<span class=interface-desc><a href='?page=device&id=$did'>$hostname</a> <a href='?page=interface&id=$iid'>$ifname</a></span></td></tr><tr bgcolor='$bg'><td>");
<td><span class=interface><a href='?page=interface&id=" . $data['interface_id'] . "'>" . $data['ifAlias'] . "</a></span><br />
<span class=interface-desc><a href='?page=device&id=" . $data['device_id'] . "'>" . $data['hostname'] . "</a> <a href='?page=interface&id=" . $data['interface_id'] . "'>" . $data['ifDescr'] . "</a></span></td></tr><tr bgcolor='$bg'><td>");
if(file_exists("rrd/" . $hostname . ".". $ifIndex . ".rrd")) {
if(file_exists("rrd/" . $data['hostname'] . "." . $data['ifIndex'] . ".rrd")) {
$graph_type = "bits";
$iid = $data['interface_id'];
include("includes/print-interface-graphs.php");
}

View File

@@ -7,6 +7,8 @@ include("windows.php");
include("procurve.php");
include("snom.php");
include("graphing.php");
include("print-functions.php");
function formatStorage($size) {
$sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');

View File

@@ -1,6 +1,54 @@
<?php
function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",
"-E",
"-b 1024",
"--title", $title);
$hostname = gethostbyid($device);
$imgfile = "graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM temperature where temp_id = '$temp'");
$optsa[] = "COMMENT: Cur Max";
while($temperature = mysql_fetch_array($sql)) {
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $temperature['temp_host'] . "'"),0);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
$temprrd = addslashes("rrd/$hostname-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE";
$optsa[] = "LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr_fixed];
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf<EFBFBD>C";
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf<EFBFBD>C\l";
$iter++;
}
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";
return FALSE;
} else {
return $imgfile;
}
}
function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",
@@ -20,7 +68,13 @@ function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vert
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=rrd/" . $hostname . "-temp-" . str_replace(" ", "_", $temperature['temp_descr']) . ".rrd:temp:AVERAGE";
$temprrd = addslashes("rrd/$hostname-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE";
$optsa[] = "LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr_fixed];
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf<EFBFBD>C";
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf<EFBFBD>C\l";

View File

@@ -8,10 +8,11 @@ while($temperature = mysql_fetch_array($temp_data)) {
echo($temp_cmd);
$temp = `$temp_cmd`;
$temprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$temprrd = "rrd/" . $device[hostname] . "-temp-" . str_replace(" ", "_",$temperature['temp_descr']) . ".rrd";
if (!is_file($temprrd)) {
`rrdtool create $temprrd \
--step 300 \
@@ -24,9 +25,13 @@ while($temperature = mysql_fetch_array($temp_data)) {
$temp = str_replace("\"", "", $temp);
if($temperature['temp_tenths']) { $temp = $temp / 10; }
echo("$temprrd, N:$temp");
echo("$temprrd N:$temp");
`rrdtool update $temprrd N:$temp`;
$updatecmd = "rrdtool update $temprrd N:$temp";
echo($updatecmd . "\n");
`$updatecmd`;
mysql_query("UPDATE temperature SET temp_current = '$temp' WHERE temp_id = '$temperature[temp_id]'");

View File

@@ -508,7 +508,53 @@ function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
}
}
function unixfsgraph ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",
"-E",
"-b 1024",
"--title", $title);
$imgfile = "graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM storage where storage_id = '$id'");
$optsa[] = "COMMENT: Size Used %age\l";
while($fs = mysql_fetch_array($sql)) {
$hostname = gethostbyid($fs['host_id']);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; $iter = "0"; }
$descr = str_pad($fs[hrStorageDescr], 16);
$descr = substr($descr,0,16);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$optsa[] = "DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$optsa[] = "LINE1.25:$fs[storage_id]p#" . $colour . ":$descr";
$optsa[] = "GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]p:LAST:%3.0lf%%\l";
$iter++;
}
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";
return FALSE;
} else {
return $imgfile;
}
}
function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",

View File

@@ -9,6 +9,7 @@ while ($device = mysql_fetch_array($device_query)) {
unset($update); unset($update_query); unset($seperator); unset($version); unset($uptime); unset($features);
unset($location); unset($hardware);
unset($sysDescr);
$pingable = isPingable($device['hostname']);
$snmpable = FALSE;