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";

View File

@@ -341,6 +341,20 @@ $config['allow_unauth_graphs'] = 0; # Allow graphs to be viewed by an
$config['allow_unauth_graphs_cidr'] = array(); # Allow graphs to be viewed without authorisation from certain IP ranges
$config['auth_mechanism'] = "mysql"; # Available mechanisms: mysql (default), ldap, http-auth
### LDAP Authentication
$config['auth_ldap_version'] = 3; # v2 or v3
$config['auth_ldap_server'] = "ldap.yourserver.com";
$config['auth_ldap_port'] = 389;
$config['auth_ldap_prefix'] = "uid=";
$config['auth_ldap_suffix'] = ",ou=People,dc=example,dc=com";
$config['auth_ldap_group'] = "cn=observium,ou=groups,dc=example,dc=com";
$config['auth_ldap_groupbase'] = "ou=group,dc=example,dc=com";
$config['auth_ldap_groups']['admin']['level'] = 10;
$config['auth_ldap_groups']['pfy']['level'] = 7;
$config['auth_ldap_groups']['support']['level'] = 1;
### Sensors
$config['allow_entity_sensor']['amperes'] = 1;
@@ -393,20 +407,6 @@ $config['syslog_filter'][] = "diskio.c"; ## Ignore some crappy stuff from SNMP
$config['enable_libvirt'] = 0; # Enable Libvirt VM support
$config['libvirt_protocols'] = array("qemu+ssh","xen+ssh"); # Mechanisms used, add or remove if not using this on any of your machines.
### LDAP Authentication
$config['auth_ldap_version'] = 3; # v2 or v3
$config['auth_ldap_server'] = "ldap.yourserver.com";
$config['auth_ldap_port'] = 389;
$config['auth_ldap_prefix'] = "uid=";
$config['auth_ldap_suffix'] = ",ou=People,dc=example,dc=com";
$config['auth_ldap_group'] = "cn=observium,ou=groups,dc=example,dc=com";
$config['auth_ldap_groupbase'] = "ou=group,dc=example,dc=com";
$config['auth_ldap_groups']['admin']['level'] = 10;
$config['auth_ldap_groups']['pfy']['level'] = 7;
$config['auth_ldap_groups']['support']['level'] = 1;
### Hardcoded ASN descriptions
$config['astext'][65332] = "Cymru FullBogon Feed";
$config['astext'][65333] = "Cymru Bogon Feed";

View File

@@ -2,7 +2,7 @@
function poll_sensor($device, $class, $unit)
{
global $config;
global $config; global $memcache;
foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `poller_type` = 'snmp'", array($class, $device['device_id'])) as $sensor)
{
@@ -72,9 +72,14 @@ function poll_sensor($device, $class, $unit)
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
if ($config['memcached']['enable'])
{
$memcache->set('sensor-'.$sensor['sensor_id'].'-value', $sensor_value);
} else {
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id']));
}
}
}
function poll_device($device, $options)
{

View File

@@ -36,8 +36,16 @@ foreach (dbFetchRows("SELECT * FROM storage WHERE device_id = ?", array($device[
rrdtool_update($storage_rrd,"N:".$storage['used'].":".$storage['free']);
$update = dbUpdate(array('storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent),
'storage', '`storage_id` = ?', array($storage['storage_id']));
if ($config['memcached']['enable'])
{
$memcache->set('storage-'.$storage['storage_id'].'-used', $storage['used']);
$memcache->set('storage-'.$storage['storage_id'].'-free', $storage['free']);
$memcache->set('storage-'.$storage['storage_id'].'-size', $storage['size']);
$memcache->set('storage-'.$storage['storage_id'].'-units', $storage['units']);
$memcache->set('storage-'.$storage['storage_id'].'-used', $percent);
} else {
$update = dbUpdate(array('storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id']));
}
echo("\n");
}

View File

@@ -11,13 +11,12 @@ include_once("includes/defaults.inc.php");
include_once("config.php");
include_once("includes/functions.php");
include_once("includes/discovery/functions.inc.php");
include_once('Net/SmartIRC.php');
mysql_close();
# Redirect to /dev/null or logfile if you aren't using screen to keep tabs
echo "Observer Bot Starting ...\n";
echo "Observium Bot Starting ...\n";
echo "\n";
echo "Timestamp Command\n";
echo "----------------- ------- \n";

View File

@@ -2,3 +2,4 @@ ALTER TABLE `vlans` ADD `vlan_type` VARCHAR( 16 ) NULL;
ALTER TABLE `vlans` CHANGE `vlan_domain` `vlan_domain` INT NULL DEFAULT NULL;
ALTER TABLE `vlans` CHANGE `vlan_descr` `vlan_name` VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE `vlans` ADD `vlan_mtu` INT NULL;
ALTER TABLE `applications` ADD `app_status` VARCHAR( 8 ) NOT NULL ;