UCD DiskIO MIB support. Still needs graphs tidied up and web display made a bit more useful

git-svn-id: http://www.observium.org/svn/observer/trunk@1214 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-06-19 16:06:57 +00:00
parent d4c07f7c7a
commit a726255dd7
11 changed files with 196 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ include("includes/functions.php");
include("includes/discovery/functions.inc.php");
$start = utime();
$runtime_stats = array();
### Observer Device Discovery
@@ -122,6 +123,7 @@ while ($device = mysql_fetch_array($device_query))
include("includes/discovery/cisco-vrf.inc.php");
include("includes/discovery/toner.inc.php");
include("includes/discovery/ups.inc.php");
include("includes/discovery/ucd-diskio.inc.php");
if ($device['type'] == "unknown")
{

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 881 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

After

Width:  |  Height:  |  Size: 957 B

View File

@@ -5,7 +5,6 @@
include("common.inc.php");
$unit_text = str_pad(truncate($unit_text,10),10);
$rrd_options .= " DEF:".$out."=".$rrd_filename.":".$rra_out.":AVERAGE";

View File

@@ -2,6 +2,7 @@
$temperatures = mysql_result(mysql_query("select count(*) from temperature WHERE device_id = '" . $device['device_id'] . "'"), 0);
$storage = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0);
$diskio = mysql_result(mysql_query("select count(*) from ucd_diskio WHERE device_id = '" . $device['device_id'] . "'"), 0);
$memory = mysql_result(mysql_query("select count(*) from mempools WHERE device_id = '" . $device['device_id'] . "'"), 0);
$processor = mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0);
$fans = mysql_result(mysql_query("select count(*) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
@@ -13,6 +14,7 @@ $datas[] = 'overview';
if ($processor) { $datas[] = 'processors'; }
if ($memory) { $datas[] = 'memory'; }
if ($storage) { $datas[] = 'storage'; }
if ($diskio) { $datas[] = 'diskio'; }
if ($temperatures) { $datas[] = 'temperatures'; }
if ($fans) { $datas[] = 'fanspeeds'; }
if ($volts) { $datas[] = 'voltages'; }
@@ -24,6 +26,7 @@ $type_text['overview'] = "Overview";
$type_text['temperatures'] = "Temperatures";
$type_text['memory'] = "Memory Pools";
$type_text['storage'] = "Disk Usage";
$type_text['diskio'] = "Disk IO";
$type_text['processors'] = "Processor Usage";
$type_text['voltages'] = "Voltages";
$type_text['fanspeeds'] = "Fan Speeds";

View File

@@ -0,0 +1,73 @@
<?php
$sql = "SELECT * FROM `ucd_diskio` WHERE device_id = '" . $_GET[id] . "' ORDER BY diskio_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
#echo("<tr class=tablehead>
# <th width=250>Drive</th>
# <th width=420>Usage</th>
# <th width=50>Free</th>
# <th></th>
# </tr>");
$row = 1;
while($drive = mysql_fetch_array($query)) {
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
# $total = $drive['storage_size'];
# $used = $drive['storage_used'];
# $free = $drive['storage_free'];
# $perc = round($drive['storage_perc'], 0);
# $used = formatStorage($used);
# $total = formatStorage($total);
# $free = formatStorage($free);
$fs_url = "/device/".$device['device_id']."/health/diskio/";
$fs_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['diskio_descr'];
$fs_popup .= "</div><img src=\'graph.php?id=" . $drive['diskio_id'] . "&type=ucd_diskio&from=$month&to=$now&width=400&height=125\'>";
$fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
if($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
echo("<tr bgcolor='$row_colour'><th><a href='$fs_url' $fs_popup>" . $drive['diskio_descr'] . "</a></td></tr>");
$types = array("diskio_bits", "diskio_ops");
foreach($types as $graph_type) {
echo('<tr bgcolor="'.$row_colour.'"><td colspan=5>');
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $now;
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
$periods = array('day', 'week', 'month', 'year');
foreach($periods as $period) {
$graph_array['from'] = $$period;
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
echo(overlib_link($_SERVER['REQUEST_URI'], generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
}
echo('</tr></td>');
}
$row++;
}
echo("</table>");
?>

View File

@@ -0,0 +1,52 @@
<?php
echo("UCD Disk IO : ");
$diskio_array = snmpwalk_cache_oid("diskIOEntry", $device, array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/");
$valid_diskio = array();
# if($debug) { print_r($diskio_array); }
if(is_array($diskio_array[$device['device_id']])) {
foreach($diskio_array[$device['device_id']] as $index => $entry) {
if($entry['diskIONRead'] > "0" || $entry['diskIONWritten'] > "0") {
echo("$index ".$entry['diskIODevice']."\n");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = '".$device['device_id']."' AND `diskio_index` = '".$index."'"),0) == "0")
{
$sql = "INSERT INTO `ucd_diskio` (`device_id`,`diskio_index`,`diskio_descr`) VALUES ('".$device['device_id']."','".$index."','".$entry['diskIODevice']."')";
mysql_query($sql); echo("+");
if($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); }
}
else
{
echo(".");
## Need update code here!
}
$valid_diskio[$index] = 1;
} ## end validity check
} ## end array foreach
} ## End array if
### Remove diskio entries which weren't redetected here
$sql = "SELECT * FROM `ucd_diskio` where `device_id` = '".$device['device_id']."'";
$query = mysql_query($sql);
if($debug) { print_r ($valid_vp); }
while ($test = mysql_fetch_array($query)) {
if($debug) { echo($test['diskio_index'] . " -> " . $test['diskio_descr'] . "\n"); }
if(!$valid_diskio[$test['diskio_index']]) {
echo("-");
mysql_query("DELETE FROM `ucd_diskio` WHERE `diskio_id` = '" . $test['diskio_id'] . "'");
}
}
unset($valid_diskio);
echo("\n");
?>

View File

@@ -0,0 +1,65 @@
<?php
$sql = "SELECT * FROM `ucd_diskio` WHERE `device_id` = '".$device['device_id']."'";
if($debug) { echo("$sql"); }
$diskio_data = mysql_query($sql);
if(mysql_affected_rows()) {
$diskio_cache = array();
$diskio_cache = snmpwalk_cache_oid("diskIOEntry", $device, $diskio_cache);
$diskio_cache = $diskio_cache[$device['device_id']];
echo("Checking UCD DiskIO MIB: ");
while($diskio = mysql_fetch_array($diskio_data)) {
$index = $diskio['diskio_index'];
$entry = $diskio_cache[$index];
echo($diskio['diskio_descr'] . " ");
if($debug) { print_r($entry); }
$rrd_update = $entry['diskIONReadX'].":".$entry['diskIONWrittenX'];
$rrd_update .= ":".$entry['diskIOReads'].":".$entry['diskIOWrites'];
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ucd_diskio-" . $diskio['diskio_descr'] .".rrd");
if($debug) { echo("$rrd "); }
if (!is_file($rrd)) {
rrdtool_create ($rrd, "--step 300 \
DS:read:DERIVE:600:0:125000000000 \
DS:written:DERIVE:600:0:125000000000 \
DS:reads:DERIVE:600:0:125000000000 \
DS:writes:DERIVE:600:0:125000000000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797");
}
rrdtool_update($rrd,"N:$rrd_update");
unset($rrd_update);
}
}
unset($diskio_data);
unset($diskio_cache);
?>

View File

@@ -179,6 +179,7 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/polling/cisco-mac-accounting.inc.php");
include("includes/polling/bgpPeer.inc.php");
include("includes/polling/toner.inc.php");
include("includes/polling/ucd-diskio.inc.php");
unset( $update ) ;
unset( $seperator) ;