more memcached

git-svn-id: http://www.observium.org/svn/observer/trunk@3114 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-05-02 15:06:12 +00:00
parent 4f1ec54a47
commit 0376427943
9 changed files with 79 additions and 24 deletions

View File

@@ -9,8 +9,17 @@ if (count($sensors))
echo('<table width="100%" valign="top">');
foreach ($sensors as $sensor)
{
### FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
if ($config['memcached']['enable'])
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}
if(empty($sensor['sensor_current']))
{
$sensor['sensor_current'] = "NaN";
}
### FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
### FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"?
$graph_colour = str_replace("#", "", $row_colour);

View File

@@ -4,6 +4,17 @@ if (!isset($vars['view']) ) { $vars['view'] = "graphs"; }
$port = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($vars['port']));
if ($config['memcached']['enable'])
{
$oids = array('ifInOctets', 'ifOutOctets', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInErrors', 'ifOutErrors');
foreach($oids as $oid)
{
$port[$oid.'_rate'] = $memcache->get('port-'.$port['interface_id'].'-'.$oid.'_rate');
if($debug) { echo("MC[".$oid."->".$port[$oid.'_rate']."]"); }
}
}
$port_details = 1;
$hostname = $device['hostname'];

View File

@@ -107,8 +107,19 @@ if ($vars['view'] == 'minigraphs')
foreach ($ports as $port)
{
include("includes/print-interface.inc.php");
if ($config['memcached']['enable'])
{
$oids = array('ifInOctets', 'ifOutOctets', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInErrors', 'ifOutErrors');
foreach($oids as $oid)
{
$port[$oid.'_rate'] = $memcache->get('port-'.$port['interface_id'].'-'.$oid.'_rate');
if($debug) { echo("MC[".$oid."->".$port[$oid.'_rate']."]"); }
}
}
include("includes/print-interface.inc.php");
$i++;
}
echo("</table></div>");

View File

@@ -25,12 +25,23 @@ echo('<tr class=tablehead>
foreach (dbFetchRows($sql, $param) as $sensor)
{
if ($config['memcached']['enable'])
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}
if(empty($sensor['sensor_current']))
{
$sensor['sensor_current'] = "NaN";
} else {
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
}
$weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$sensor_popup = "<a href=\"graphs/id=" . $sensor['sensor_id'] . "/type=".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
" . $sensor['sensor_descr'] . "</a>";
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
$sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&amp;type=".$graph_type."&amp;from=$month&amp;to=$now&amp;width=300&amp;height=100";