change how we draw error graphs (do it in rrd so they fit!). improvements to new devices/ports

git-svn-id: http://www.observium.org/svn/observer/trunk@2457 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-14 14:28:42 +00:00
parent a7b7dc8f4d
commit 9e680b33a6
4 changed files with 57 additions and 73 deletions

View File

@@ -84,17 +84,36 @@ else
function graph_error($string) function graph_error($string)
{ {
global $width, $height, $debug; global $config, $width, $height, $debug, $graphfile, $rrd_options, $rrd_switches;
#$rrd_options .= " HRULE:0#cc0000";
#$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
$rrd_cmd = $config['rrdtool'] . " graph $graphfile --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width 315 --height 110 -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000" . $rrd_switches;
$woo = shell_exec($rrd_cmd);
if ($debug) { echo("<pre>".$rrd_cmd."</pre>"); }
if (is_file($graphfile) && !$debug)
{
header('Content-type: image/png');
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
unlink($graphfile);
}
# if (!$debug) { header('Content-type: image/png'); }
# if ($height > "99") { $width +=75; }
# $im = imagecreate($width, $height);
# $orange = imagecolorallocate($im, 255, 225, 225);
# $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
# imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
# imagepng($im);
# imagedestroy($im);
# exit();
if (!$debug) { header('Content-type: image/png'); }
if ($height > "99") { $width +=75; }
$im = imagecreate($width, $height);
$orange = imagecolorallocate($im, 255, 225, 225);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
imagepng($im);
imagedestroy($im);
exit();
} }
if ($error_msg) { if ($error_msg) {

View File

@@ -178,8 +178,10 @@ foreach ($menu_options as $option => $text)
$menu_options = array('bits' => 'Bits', $menu_options = array('bits' => 'Bits',
'processor' => 'CPU', 'processor' => 'CPU',
'mempool' => 'Memory', 'mempool' => 'Memory',
'uptime' => 'Uptime'); 'uptime' => 'Uptime',
'storage' => 'Storage',
'diskio' => 'Disk I/O'
);
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {

View File

@@ -44,6 +44,7 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos
<option value='loopback' <?php if ($vars['state'] == "loopback") { echo("selected"); } ?>>Loopback</option> <option value='loopback' <?php if ($vars['state'] == "loopback") { echo("selected"); } ?>>Loopback</option>
</select> </select>
</td> </td>
<td width=110> <td width=110>
<select name='ifSpeed' id='ifSpeed'> <select name='ifSpeed' id='ifSpeed'>
<option value=''>All Speeds</option> <option value=''>All Speeds</option>
@@ -75,6 +76,23 @@ foreach (dbFetchRows("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `i
} }
?> ?>
</select> </select>
<br />
<select name='port_descr_type' id='port_descr_type'>
<option value=''>All Port Types</option>
<?php
foreach (dbFetchRows("SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr_type` ORDER BY `port_descr_type`") as $data)
{
if ($data['port_descr_type'])
{
echo("<option value='".$data['port_descr_type']."'");
if ($data['port_descr_type'] == $vars['port_descr_type']) { echo("selected"); }
echo(">".ucfirst($data['port_descr_type'])."</option>");
}
}
?>
</select>
</td> </td>
<td> <td>
<input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($vars['ifAlias']); ?>" /> <input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($vars['ifAlias']); ?>" />
@@ -202,6 +220,7 @@ if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $vars['state'] == "dow
$where .= " AND I.ifType = 'ppp'"; $where .= " AND I.ifType = 'ppp'";
} }
if (is_numeric($vars['device_id'])) if (is_numeric($vars['device_id']))
{ {
$where .= " AND I.device_id = ?"; $where .= " AND I.device_id = ?";
@@ -212,7 +231,11 @@ if ($vars['ifType'])
$where .= " AND I.ifType = ?"; $where .= " AND I.ifType = ?";
$param[] = $vars['ifType']; $param[] = $vars['ifType'];
} }
if ($vars['port_descr_type'])
{
$where .= " AND I.port_descr_type = ?";
$param[] = $vars['port_descr_type'];
}
if (is_numeric($vars['ifSpeed'])) if (is_numeric($vars['ifSpeed']))
{ {
$where .= " AND I.ifSpeed = ?"; $where .= " AND I.ifSpeed = ?";

View File

@@ -3,66 +3,6 @@
<?php <?php
#if ($_SESSION['userlevel'] >= '5') {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
#} else {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#}
$param = array();
# FIXME block below is not totally used, at least the iftype stuff is bogus?
if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "down")
{
$where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down' AND I.ignore = '0'";
} elseif ($_GET['opta'] == "admindown" || $_GET['type'] == "admindown" || $_POST['state'] == "admindown") {
$where .= "AND I.ifAdminStatus = 'down'";
} elseif ($_GET['opta'] == "errors" || $_GET['type'] == "errors" || $_POST['state'] == "errors") {
$where .= "AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')";
} elseif ($_GET['type'] == "up" || $_POST['state'] == "up") {
$where .= "AND I.ifOperStatus = 'up'";
} elseif ($_GET['opta'] == "ignored" || $_GET['type'] == "ignored" || $_POST['state'] == "ignored") {
$where .= "AND I.ignore = '1'";
} elseif ($_GET['type'] == "l2vlan" || $_POST['state'] == "l2vlan") {
$where .= " AND I.ifType = 'l2vlan'";
} elseif ($_GET['type'] == "ethernet" || $_POST['state'] == "ethernet") {
$where .= " AND I.ifType = 'ethernetCsmacd'";
} elseif ($_GET['type'] == "loopback" || $_POST['state'] == "loopback") {
$where .= " AND I.ifType = 'softwareLoopback'";
} elseif ($_GET['typee'] == "sonet" || $_POST['state'] == "sonet") {
$where .= " AND I.ifType = 'sonet'";
} elseif ($_POST['state'] == "propvirtual") {
$where .= " AND I.ifType = 'propVirtual'";
} elseif ($_POST['state'] == "ppp") {
$where .= " AND I.ifType = 'ppp'";
}
if (is_numeric($_POST['device_id']))
{
$where .= " AND I.device_id = ?";
$param[] = $_POST['device_id'];
}
if ($_POST['ifType'])
{
$where .= " AND I.ifType = ?";
$param[] = $_POST['ifType'];
}
if (is_numeric($_POST['ifSpeed']))
{
$where .= " AND I.ifSpeed = ?";
$param[] = $_POST['ifSpeed'];
}
if ($_POST['ifAlias']) {
$where .= " AND I.ifAlias LIKE ?";
$param[] = "%".$_POST['ifAlias']."%";
}
if ($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; }
$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ORDER BY D.hostname, I.ifIndex";
echo("<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Down</th><th>Up</th><th>Media</th><th>Description</th></tr>"); echo("<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Down</th><th>Up</th><th>Media</th><th>Description</th></tr>");
$row = 1; $row = 1;