Merge pull request #2007 from QuxLabs/qux-issue-8

Added working memcached support
This commit is contained in:
Neil Lathwood
2015-10-01 17:08:03 +01:00
22 changed files with 129 additions and 200 deletions

View File

@@ -0,0 +1,16 @@
# Memcached
LibreNMS can store SQL results in memcached to achieve performance advantages of in-memory value storage and removing work load for frequent queries off the MySQL backend.
To enable memcached in your install you need to have `memcached` installed and the PHP extension `php5-memcached` or `php-memcached` and add the following lines to your `config.php`:
```php
$config['memcached']['enable'] = true;
$config['memcached']['host'] = "localhost";
$config['memcached']['port'] = 11211;
```
By default values are kept for 4 Minutes inside the memcached, you can adjust this retention time by modifying the `$config['memcached']['ttl']` value to any desired amount of seconds.
It's strongly discouraged to set this above `300` (5 Minutes) to avoid interferences with the polling, discovery and alerting processes.
If you use the Distributed Poller, you can point this to the same memcached instance. However a local memcached will perform better in any case.

View File

@@ -72,22 +72,16 @@ if (isset($_GET['term'],$_GET['device_id'])) {
$_GET['device_id'] = mres($_GET['device_id']);
if (strstr($_GET['term'], '.')) {
$term = explode('.', $_GET['term']);
if ($config['memcached']['enable']) {
$chk = $memcache->get('rule-suggest_'.$term[0]);
}
if (!(sizeof($chk) > 0) || $chk === false) {
if ($term[0] == 'macros') {
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
$chk[] = 'macros.'.$macro;
}
if ($term[0] == 'macros') {
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
$chk[] = 'macros.'.$macro;
}
else {
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
foreach ($tmp as $tst) {
if (isset($tst['Field'])) {
$chk[] = $term[0].'.'.$tst['Field'];
}
}
else {
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
foreach ($tmp as $tst) {
if (isset($tst['Field'])) {
$chk[] = $term[0].'.'.$tst['Field'];
}
}
}
@@ -95,29 +89,18 @@ if (isset($_GET['term'],$_GET['device_id'])) {
$current = true;
}
else {
if ($config['memcached']['enable']) {
$chk = $memcache->get('rule-suggest-toplvl');
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach ($tmp as $tst) {
$chk[] = $tst['TABLE_NAME'].'.';
}
if (!(sizeof($chk) > 0) || $chk === false) {
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach ($tmp as $tst) {
$chk[] = $tst['TABLE_NAME'].'.';
}
$chk[] = 'macros.';
$chk[] = 'bills.';
}
$chk[] = 'macros.';
$chk[] = 'bills.';
}
if (sizeof($chk) > 0) {
if ($config['memcached']['enable']) {
$memcache->set('rule-suggest-'.$oterm, $chk, 86400);
// Cache for 24h
}
$obj = levsort($_GET['term'], $chk);
$obj = array_chunk($obj, 20, true);
$obj = $obj[0];
$obj = levsort($_GET['term'], $chk);
$obj = array_chunk($obj, 20, true);
$obj = $obj[0];
$flds = array();
if ($current === true) {
foreach ($obj as $fld) {

View File

@@ -3,7 +3,7 @@
function authenticate($username, $password) {
$encrypted_old = md5($password);
$row = dbFetchRow('SELECT username,password FROM `users` WHERE `username`= ?', array($username));
$row = dbFetchRow('SELECT username,password FROM `users` WHERE `username`= ?', array($username), true);
if ($row['username'] && $row['username'] == $username) {
// Migrate from old, unhashed password
if ($row['password'] == $encrypted_old) {
@@ -36,7 +36,7 @@ function authenticate($username, $password) {
function reauthenticate($sess_id, $token) {
list($uname,$hash) = explode('|', $token);
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'");
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'", array(), true);
$hasher = new PasswordHash(8, false);
if ($hasher->CheckPassword($uname.$session['session_token'], $hash)) {
$_SESSION['username'] = $uname;
@@ -59,7 +59,7 @@ function passwordscanchange($username='') {
return 1;
}
else {
return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username));
return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username), true);
}
}//end passwordscanchange()
@@ -114,20 +114,20 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
function user_exists($username) {
$return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username));
$return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
return $return;
}//end user_exists()
function get_userlevel($username) {
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username));
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username), true);
}//end get_userlevel()
function get_userid($username) {
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username));
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username), true);
}//end get_userid()
@@ -158,7 +158,7 @@ function can_update_users() {
function get_user($user_id) {
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id));
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id), true);
}//end get_user()

View File

@@ -42,7 +42,7 @@ if ($rowCount != -1) {
$sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, `group_name`, D.last_polled_timetaken AS `last_polled_timetaken` $sql";
foreach (dbFetchRows($sql) as $device) {
foreach (dbFetchRows($sql,array(),true) as $device) {
if (empty($device['group_name'])) {
$device['group_name'] = 'General';
}

View File

@@ -32,7 +32,7 @@ function catchFatal() {
}
}
if (strpos($_SERVER['PATH_INFO'], "debug")) {
if (strpos($_SERVER['PATH_INFO'], "debug") || true) {
$debug = "1";
ini_set('display_errors', 0);
ini_set('display_startup_errors', 1);
@@ -66,6 +66,8 @@ require 'includes/functions.inc.php';
require 'includes/vars.inc.php';
require 'includes/plugins.inc.php';
$config['memcached']['ttl'] = $config['time']['now']+300;
Plugins::start();
$runtime_start = utime();

View File

@@ -22,7 +22,7 @@ else if ($vars['purge']) {
echo '<table cellpadding=5 cellspacing=0 border=0 width=100%>';
echo "<tr><td></td><td></td><td></td><td><a href='deleted-ports/purge=all/'><img src='images/16/cross.png' align=absmiddle></img> Purge All</a></td></tr>";
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) {
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id",array(),true) as $interface) {
$interface = ifLabel($interface, $interface);
if (port_permitted($interface['port_id'], $interface['device_id'])) {
echo '<tr class=list>';

View File

@@ -1,6 +1,7 @@
<?php
$no_refresh = TRUE;
$config['memcached']['enable'] = false;
$link_array = array('page' => 'device',
'device' => $device['device_id'],

View File

@@ -13,17 +13,6 @@ foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($devi
$row_colour = $list_colour_b;
}
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
d_echo($state);
if (is_array($state)) {
$mempool = array_merge($mempool, $state);
}
unset($state);
}
$text_descr = rewrite_entity_descr($mempool['mempool_descr']);
$mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/';

View File

@@ -12,10 +12,6 @@ if (count($sensors)) {
echo ' </div>
<table class="table table-hover table-condensed table-striped">';
foreach ($sensors as $sensor) {
if ($config['memcached']['enable'] === true) {
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}
if (empty($sensor['sensor_current'])) {
$sensor['sensor_current'] = 'NaN';
}

View File

@@ -19,17 +19,6 @@ if (count($mempools)) {
';
foreach ($mempools as $mempool) {
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
d_echo($state);
if (is_array($state)) {
$mempool = array_merge($mempool, $state);
}
unset($state);
}
$percent = round($mempool['mempool_perc'], 0);
$text_descr = rewrite_entity_descr($mempool['mempool_descr']);
$total = formatStorage($mempool['mempool_total']);

View File

@@ -6,17 +6,6 @@ if (!isset($vars['view'])) {
$port = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($vars['port']));
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
$port_details = 1;
$hostname = $device['hostname'];

View File

@@ -136,19 +136,7 @@ else {
}
foreach ($ports as $port) {
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
include 'includes/print-interface.inc.php';
$i++;
}

View File

@@ -22,11 +22,6 @@ echo '<tr class="tablehead">
</tr>';
foreach (dbFetchRows($sql, $param) as $sensor) {
if ($config['memcached']['enable'] === true) {
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
d_echo('Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']');
}
if (empty($sensor['sensor_current'])) {
$sensor['sensor_current'] = 'NaN';
}

View File

@@ -24,6 +24,7 @@
* @subpackage Page
*/
$pagetitle[] = 'Global Settings';
$config['memcached']['enable'] = false;
?>
<div class="container-fluid">

View File

@@ -238,8 +238,15 @@ function dbDelete($table, $where=null, $parameters=array()) {
* */
function dbFetchRows($sql, $parameters=array()) {
global $db_stats;
function dbFetchRows($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -251,6 +258,9 @@ function dbFetchRows($sql, $parameters=array()) {
}
mysql_free_result($result);
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
}
return $rows;
}
@@ -273,8 +283,8 @@ function dbFetchRows($sql, $parameters=array()) {
* */
function dbFetch($sql, $parameters=array()) {
return dbFetchRows($sql, $parameters);
function dbFetch($sql, $parameters=array(), $nocache=false) {
return dbFetchRows($sql, $parameters, $nocache);
/*
// for now, don't do the iterator thing
$result = dbQuery($sql, $parameters);
@@ -295,8 +305,15 @@ function dbFetch($sql, $parameters=array()) {
* */
function dbFetchRow($sql=null, $parameters=array()) {
global $db_stats;
function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -308,6 +325,9 @@ function dbFetchRow($sql=null, $parameters=array()) {
$db_stats['fetchrow_sec'] += number_format(($time_end - $time_start), 8);
$db_stats['fetchrow']++;
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
}
return $row;
}
else {
@@ -324,10 +344,10 @@ function dbFetchRow($sql=null, $parameters=array()) {
* */
function dbFetchCell($sql, $parameters=array()) {
function dbFetchCell($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$row = dbFetchRow($sql, $parameters);
$row = dbFetchRow($sql, $parameters, $nocache);
if ($row) {
return array_shift($row);
// shift first field off first row
@@ -349,11 +369,11 @@ function dbFetchCell($sql, $parameters=array()) {
* */
function dbFetchColumn($sql, $parameters=array()) {
function dbFetchColumn($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$cells = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$cells[] = array_shift($row);
}

View File

@@ -239,8 +239,15 @@ function dbDelete($table, $where=null, $parameters=array()) {
* */
function dbFetchRows($sql, $parameters=array()) {
global $db_stats;
function dbFetchRows($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -252,6 +259,9 @@ function dbFetchRows($sql, $parameters=array()) {
}
mysqli_free_result($result);
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
}
return $rows;
}
@@ -274,8 +284,8 @@ function dbFetchRows($sql, $parameters=array()) {
* */
function dbFetch($sql, $parameters=array()) {
return dbFetchRows($sql, $parameters);
function dbFetch($sql, $parameters=array(), $nocache=false) {
return dbFetchRows($sql, $parameters, $nocache);
/*
// for now, don't do the iterator thing
$result = dbQuery($sql, $parameters);
@@ -296,8 +306,15 @@ function dbFetch($sql, $parameters=array()) {
* */
function dbFetchRow($sql=null, $parameters=array()) {
global $db_stats;
function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -309,6 +326,9 @@ function dbFetchRow($sql=null, $parameters=array()) {
$db_stats['fetchrow_sec'] += number_format(($time_end - $time_start), 8);
$db_stats['fetchrow']++;
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
}
return $row;
}
else {
@@ -325,10 +345,11 @@ function dbFetchRow($sql=null, $parameters=array()) {
* */
function dbFetchCell($sql, $parameters=array()) {
global $db_stats;
function dbFetchCell($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
$time_start = microtime(true);
$row = dbFetchRow($sql, $parameters);
$row = dbFetchRow($sql, $parameters, $nocache);
if ($row) {
return array_shift($row);
// shift first field off first row
@@ -350,11 +371,11 @@ function dbFetchCell($sql, $parameters=array()) {
* */
function dbFetchColumn($sql, $parameters=array()) {
function dbFetchColumn($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$cells = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$cells[] = array_shift($row);
}
@@ -375,9 +396,9 @@ function dbFetchColumn($sql, $parameters=array()) {
*/
function dbFetchKeyValue($sql, $parameters=array()) {
function dbFetchKeyValue($sql, $parameters=array(), $nocache=false) {
$data = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$key = array_shift($row);
if (sizeof($row) == 1) {
// if there were only 2 fields in the result

View File

@@ -75,6 +75,7 @@ $config['sfdp'] = '/usr/bin/sfdp';
$config['memcached']['enable'] = false;
$config['memcached']['host'] = 'localhost';
$config['memcached']['port'] = 11211;
$config['memcached']['ttl'] = 240;
$config['slow_statistics'] = true;
// THIS WILL CHANGE TO FALSE IN FUTURE

View File

@@ -30,6 +30,19 @@ else {
$database_db = mysql_select_db($config['db_name'], $database_link);
}
if ($config['memcached']['enable'] === true) {
if (class_exists('Memcached')) {
$config['memcached']['ttl'] = 60;
$config['memcached']['resource'] = new Memcached();
$config['memcached']['resource']->addServer($config['memcached']['host'], $config['memcached']['port']);
}
else {
echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n";
echo "Try 'apt-get install php5-memcached' or 'pecl install memcached'. You will need the php5-dev and libmemcached-dev packages to use pecl.\n\n";
$config['memcached']['enable'] = 0;
}
}
$clone = $config;
foreach (dbFetchRows('select config_name,config_value from config') as $obj) {
$clone = array_replace_recursive($clone, mergecnf($obj));
@@ -1703,19 +1716,6 @@ if (isset($_SERVER['HTTPS'])) {
$config['base_url'] = preg_replace('/^http:/', 'https:', $config['base_url']);
}
if ($config['memcached']['enable'] === true) {
if (class_exists('Memcached')) {
$memcache = new Memcached();
$memcache->addServer($config['memcached']['host'], $config['memcached']['port']);
$memcache->getStats();
}
else {
echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n";
echo "Try 'apt-get install php5-memcached' or 'pecl install memcached'. You will need the php5-dev and libmemcached-dev packages to use pecl.\n\n";
$config['memcached']['enable'] = 0;
}
}
// Set some times needed by loads of scripts (it's dynamic, so we do it here!)
$config['time']['now'] = time();
$config['time']['now'] -= ($config['time']['now'] % 300);

View File

@@ -119,12 +119,7 @@ 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'] === true) {
$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']));
}
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id']));
}//end foreach
}//end poll_sensor()

View File

@@ -47,14 +47,7 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device
$mempool['state']['mempool_lowestfree'] = $mempool['lowestfree'];
}
if ($config['memcached']['enable'] === true) {
d_echo($mempool['state']);
$memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']);
}
else {
dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
}
dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
echo "\n";
}//end foreach

View File

@@ -244,17 +244,6 @@ foreach ($ports as $port) {
$this_port['ifDescr'] = $matches[1];
}
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
$polled_period = ($polled - $port['poll_time']);
$port['update'] = array();
@@ -266,12 +255,6 @@ foreach ($ports as $port) {
$port['update']['poll_period'] = $polled_period;
}
if ($config['memcached']['enable'] === true) {
$port['state']['poll_time'] = $polled;
$port['state']['poll_prev'] = $port['poll_time'];
$port['state']['poll_period'] = $polled_period;
}
// Copy ifHC[In|Out]Octets values to non-HC if they exist
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets'])) {
echo 'HC ';
@@ -400,11 +383,6 @@ foreach ($ports as $port) {
$port['update'][$oid.'_prev'] = $port[$oid];
}
if ($config['memcached']['enable'] === true) {
$port['state'][$oid] = $this_port[$oid];
$port['state'][$oid.'_prev'] = $port[$oid];
}
$oid_prev = $oid.'_prev';
if (isset($port[$oid])) {
$oid_diff = ($this_port[$oid] - $port[$oid]);
@@ -422,11 +400,6 @@ foreach ($ports as $port) {
$port['update'][$oid.'_delta'] = $oid_diff;
}
if ($config['memcached']['enable'] === true) {
$port['state'][$oid.'_rate'] = $oid_rate;
$port['state'][$oid.'_delta'] = $oid_diff;
}
d_echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n");
}//end if
}//end foreach
@@ -451,13 +424,6 @@ foreach ($ports as $port) {
echo 'bytes('.formatStorage($port['stats']['ifInOctets_diff']).'/'.formatStorage($port['stats']['ifOutOctets_diff']).')';
echo 'pkts('.format_si($port['stats']['ifInUcastPkts_rate']).'pps/'.format_si($port['stats']['ifOutUcastPkts_rate']).'pps)';
// Store aggregate in/out state
if ($config['memcached']['enable'] === true) {
$port['state']['ifOctets_rate'] = ($port['stats']['ifOutOctets_rate'] + $port['stats']['ifInOctets_rate']);
$port['state']['ifUcastPkts_rate'] = ($port['stats']['ifOutUcastPkts_rate'] + $port['stats']['ifInUcastPkts_rate']);
$port['state']['ifErrors_rate'] = ($port['stats']['ifOutErrors_rate'] + $port['stats']['ifInErrors_rate']);
}
// Port utilisation % threshold alerting. // FIXME allow setting threshold per-port. probably 90% of ports we don't care about.
if ($config['alerts']['port_util_alert'] && $port['ignore'] == '0') {
// Check for port saturation of $config['alerts']['port_util_perc'] or higher. Alert if we see this.
@@ -547,13 +513,6 @@ foreach ($ports as $port) {
include 'port-alcatel.inc.php';
}
// Update Memcached
if ($config['memcached']['enable'] === true) {
d_echo($port['state']);
$memcache->set('port-'.$port['port_id'].'-state', $port['state']);
}
foreach ($port['update'] as $key => $val_check) {
if (!isset($val_check)) {
unset($port['update'][$key]);

View File

@@ -37,16 +37,7 @@ foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device[
rrdtool_update($storage_rrd, $fields);
if ($config['memcached']['enable'] === true) {
$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'].'-perc', $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']));
}
$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";
}//end foreach