add applications polling infrastructure (OH YEAH!)

git-svn-id: http://www.observium.org/svn/observer/trunk@1217 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-06-20 14:48:29 +00:00
parent 8e7ebaf639
commit 88460b4a30
5 changed files with 158 additions and 0 deletions

BIN
html/images/icons/apps.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

View File

@@ -65,6 +65,15 @@ if($health) {
</li>');
}
if(@mysql_result(mysql_query("select count(app_id) from applications WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0')
{
echo('<li class="' . $select['apps'] . '">
<a href="' . $config['base_url'] . '/device/' . $device['device_id'] . '/apps/">
<img src="images/icons/apps.png" align="absmiddle" border="0" /> Apps
</a>
</li>');
}
### This needs to die, rolled into generic sensors! (still need to implement booleans, tx/rx powers and currents)
#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0);

View File

@@ -0,0 +1,73 @@
<?php
$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);
$volts = mysql_result(mysql_query("select count(*) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0);
$freqs = mysql_result(mysql_query("select count(*) from frequency WHERE device_id = '" . $device['device_id'] . "'"), 0);
$current = mysql_result(mysql_query("select count(*) from current WHERE device_id = '" . $device['device_id'] . "'"), 0);
$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'; }
if ($freqs) { $datas[] = 'frequencies'; }
if ($current) { $datas[] = 'current'; }
$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";
$type_text['frequencies'] = "Frequencies";
$type_text['current'] = "Current";
print_optionbar_start();
if(!$_GET['opta']) { $_GET['opta'] = "overview"; }
unset($sep);
foreach ($datas as $type) {
echo($sep);
if ($_GET['opta'] == $type)
{
echo("<strong>");
echo('<img src="images/icons/'.$type.'.png" class="optionicon" />');
} else {
echo('<img src="images/icons/greyscale/'.$type.'.png" class="optionicon" />');
}
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/health/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ."</a>\n");
if ($_GET['opta'] == $type) { echo("</strong>"); }
$sep = " | ";
}
print_optionbar_end();
if (is_file("pages/device/health/".mres($_GET['opta']).".inc.php"))
{
include("pages/device/health/".mres($_GET['opta']).".inc.php");
} else {
foreach ($datas as $type) {
if($type != "overview") {
$graph_title = $type_text[$type];
$graph_type = "device_".$type;
include ("includes/print-device-graph.php");
}
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
$sql = "SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."'";
if($debug) { echo($sql."\n"); }
$app_data = mysql_query($sql);
if(mysql_affected_rows())
{
echo('Applications: ');
while($app = mysql_fetch_array($app_data)) {
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
if(is_file($app_include))
{
include($app_include);
}
else
{
echo($app['app_type'].' include missing! ');
}
}
echo("\n");
}
?>

View File

@@ -0,0 +1,51 @@
<?php
## Polls Apache statistics from script via SNMP
$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
$apache_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$apache_cmd .= " nsExtendOutputFull.6.97.112.97.99.104.101";
$apache = `$apache_cmd`;
list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers,
$score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache);
if (!is_file($apache_rrd)) {
rrdtool_create ($apache_rrd, "--step 300 \
DS:access:DERIVE:600:0:125000000000 \
DS:kbyte:DERIVE:600:0:125000000000 \
DS:cpu:GAUGE:600:0:125000000000 \
DS:uptime:GAUGE:600:0:125000000000 \
DS:reqpersec:GAUGE:600:0:125000000000 \
DS:bytespersec:GAUGE:600:0:125000000000 \
DS:byesperreq:GAUGE:600:0:125000000000 \
DS:busyworkers:GAUGE:600:0:125000000000 \
DS:idleworkers:GAUGE:600:0:125000000000 \
DS:sb_wait:GAUGE:600:0:125000000000 \
DS:sb_start:GAUGE:600:0:125000000000 \
DS:sb_reading:GAUGE:600:0:125000000000 \
DS:sb_writing:GAUGE:600:0:125000000000 \
DS:sb_keepalive:GAUGE:600:0:125000000000 \
DS:sb_dns:GAUGE:600:0:125000000000 \
DS:sb_closing:GAUGE:600:0:125000000000 \
DS:sb_logging:GAUGE:600:0:125000000000 \
DS:sb_graceful:GAUGE:600:0:125000000000 \
DS:sb_idle:GAUGE:600:0:125000000000 \
DS:sb_open:GAUGE: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($apache_rrd, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open");
?>