Dynamic config system

This commit is contained in:
laf
2015-01-22 21:22:37 +00:00
parent a148613dfa
commit 6e84535031
18 changed files with 544 additions and 68 deletions

99
html/form_new_config.php Normal file
View File

@@ -0,0 +1,99 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
enable_debug();
include_once("../includes/defaults.inc.php");
include_once("../config.php");
include_once("../includes/definitions.inc.php");
include_once("includes/functions.inc.php");
include_once("../includes/functions.php");
include_once("includes/authenticate.inc.php");
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
$new_conf_type = $_POST['new_conf_type'];
$new_conf_name = $_POST['new_conf_name'];
$new_conf_desc = $_POST['new_conf_desc'];
if(empty($new_conf_name))
{
echo("You haven't specified a config name");
exit;
}
elseif(empty($new_conf_desc))
{
echo("You haven't specified a config description");
exit;
}
elseif(empty($_POST['new_conf_single_value']) && empty($_POST['new_conf_multi_value']))
{
echo("You haven't specified a config value");
exit;
}
$db_inserted = '0';
if($new_conf_type == 'Single')
{
$new_conf_type = 'single';
$new_conf_value = $_POST['new_conf_single_value'];
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
elseif($new_conf_type == 'Single Array')
{
$new_conf_type = 'single-array';
$new_conf_value = $_POST['new_conf_single_value'];
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
elseif($new_conf_type == 'Standard Array' || $new_conf_type == 'Multi Array')
{
if($new_conf_type == 'Standard Array')
{
$new_conf_type = 'array';
}
elseif($new_conf_type == 'Multi Array')
{
$new_conf_type = 'multi-array';
}
else
{
# $new_conf_type is invalid so clear values so we don't create any config
$new_conf_value = '';
}
$new_conf_value = nl2br($_POST['new_conf_multi_value']);
$values = explode('<br />',$new_conf_value);
foreach ($values as $item)
{
$new_conf_value = trim($item);
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
}
}
else
{
echo('Bad config type!');
$db_inserted = 0;
exit;
}
if($db_inserted == 1)
{
echo('Your new config item has been added');
}
else
{
echo('An error occurred adding your config item to the database');
}
?>

View File

@@ -0,0 +1,48 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
// FUA
if(!is_numeric($_POST['config_id']))
{
echo('error with data');
exit;
}
else
{
if($_POST['state'] == 'true')
{
$state = 1;
}
elseif($_POST['state'] == 'false')
{
$state = 0;
}
else
{
$state = 0;
}
$update = dbUpdate(array('config_disabled' => $state), 'config', '`config_id` = ?', array($_POST['config_id']));
if(!empty($update) || $update == '0')
{
echo('success');
exit;
}
else
{
echo('error');
exit;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
// FUA
if(!is_numeric($_POST['config_id']) || empty($_POST['data']))
{
echo('error with data');
exit;
}
else
{
$data = mres($_POST['data']);
$update = dbUpdate(array('config_value' => "$data"), 'config', '`config_id` = ?', array($_POST['config_id']));
if(!empty($update) || $update == '0')
{
echo('success');
exit;
}
else
{
echo('error');
exit;
}
}

View File

@@ -774,7 +774,16 @@ function clean_bootgrid($string) {
$output = str_replace(array("\r","\n"), "", $string);
$output = addslashes($output);
return $output;
}
//Insert new config items
function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc) {
if (dbInsert(array('config_name' => $new_conf_name, 'config_value' => $new_conf_value, 'config_default' => $new_conf_value, 'config_type' => $new_conf_type, 'config_desc' => $new_conf_desc, 'config_group' => '500_Custom Settings', 'config_sub_group' => '01_Custom settings', 'config_hidden' => '0', 'config_disabled' => '0'), 'config')) {
$db_inserted = 1;
} else {
$db_inserted = 0;
}
return($db_inserted);
}
?>

View File

@@ -13,7 +13,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($devi
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }

View File

@@ -14,7 +14,7 @@ if (count($sensors))
<table class="table table-hover table-condensed table-striped">');
foreach ($sensors as $sensor)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}

View File

@@ -22,7 +22,7 @@ if (count($mempools))
foreach ($mempools as $mempool)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }

View File

@@ -4,7 +4,7 @@ if (!isset($vars['view']) ) { $vars['view'] = "graphs"; }
$port = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($vars['port']));
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }

View File

@@ -106,7 +106,7 @@ if ($vars['view'] == 'minigraphs')
foreach ($ports as $port)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }

View File

@@ -19,7 +19,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.devi
{
$text_descr = $mempool['mempool_descr'];
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
if($debug) { print_r($state); }

View File

@@ -26,7 +26,7 @@ echo('<tr class=tablehead>
foreach (dbFetchRows($sql, $param) as $sensor)
{
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); }

View File

@@ -1,46 +1,248 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Global Settings
* @author f0o <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Page
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
/**
* Array-To-Table
* @param array $a N-Dimensional, Associative Array
* @return string
*/
function a2t($a) {
$r = "<table class='table table-condensed table-hover'><tbody>";
foreach( $a as $k=>$v ) {
if( !empty($v) ) {
$r .= "<tr><td class='col-md-2'><i><b>".$k."</b></i></td><td class='col-md-10'>".(is_array($v)?a2t($v):"<code>".wordwrap($v,75,"<br/>")."</code>")."</td></tr>";
}
}
$r .= '</tbody></table>';
return $r;
}
if ($_SESSION['userlevel'] >= '10') {
?>
<div class="modal fade" id="new-config-form" role="dialog" aria-hidden="true" title="Create new config item">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<form role="form" class="new_config_form">
<div class="form-group">
<label for="new_conf_type">Config type</label>
<select class="form-control" name="new_conf_type" id="new_conf_type" onChange="showInput();">
<option>Single</option>
<option>Standard Array</option>
<option>Multi Array</option>
<option>Single Array</option>
</select>
</div>
<div class="form-group">
<label for="new_conf_name">Config name</label>
<input type="text" class="form-control" name="new_conf_name" id="new_conf_name" placeholder="Enter the config name">
</div>
<div class="form-group" id="single_value">
<label for="new_conf_value">Config value</label>
<input type="text" class="form-control" name="new_conf_single_value" id="new_conf_single_value" placeholder="Enter the config value">
</div>
<div class="form-group" id="multi_value">
<label for="new_conf_value">Config value</label>
<textarea class="form-control" rows="3" name="new_conf_multi_value" id="new_conf_multi_value" placeholder="Enter the config value, each item must be on a new line"></textarea>
</div>
<script>
function showInput()
{
confType = $("#new_conf_type").val();
if(confType == 'Single' || confType == 'Single Array')
{
$('#multi_value').hide();
$('#single_value').show();
}
else if(confType == 'Standard Array' || confType == 'Multi Array')
{
$('#single_value').hide();
$('#multi_value').show();
}
}
$('#multi_value').toggle();
</script>
<div class="form-group">
<label for="new_conf_desc">Description</label>
<input type="text" class="form-control" name="new_conf_desc" id="new_conf_desc" placeholder="Enter the description of this config item">
</div>
</div>
</form>
<div class="modal-footer">
<button class="btn btn-success" id="submit">Add config</button>
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
</div>
</div>
</div>
</div>
<?php
$found=0;
echo('
<div class="row">
<div class="col-md-12">
<span id="thanks"></span>
</div>
</div>
<div class="row">
<div class="col-md-9">
<h4>System Settings</h4>
</div>
<div class="col-md-3">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button type="button" name="options" id="expand" class="btn btn-xs btn-default"> Expand
<button type="button" name="options" id="collapse" class="btn btn-xs btn-default"> Collapse
<button type="button" name="new_config" id="new_config_item" data-toggle="modal" data-target="#new-config-form" class="btn btn-xs btn-default"> New config item
</div>
</div>
</div>
</div>
<form class="form-horizontal" role="form" action="" method="post">
<div class="panel-group" id="accordion">
');
foreach (dbFetchRows("SELECT config_id,config_group FROM `config` WHERE config_hidden='0' GROUP BY config_group ORDER BY config_group ASC") as $group)
{
list($grp_num,$grp_title) = explode("_",$group['config_group']);
$found++;
echo('
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#'.$grp_num.'_expand">
'.$grp_title.'
</a>
</h4>
</div>
<div id="'.$grp_num.'_expand" class="panel-collapse collapse">
<div class="panel-body">
');
foreach (dbFetchRows("SELECT * FROM `config` WHERE config_group='".$group['config_group']."' ORDER BY config_sub_group ASC, config_name ASC") as $cfg)
{
$cfg_ids[] = $cfg['config_id'];
$cfg_disabled = '';
if($cfg['config_disabled'] == '1')
{
$cfg_disabled = 'checked';
}
echo('
<div class="form-group">
<label for="'.$cfg['config_id'].'" class="col-sm-3">'.$cfg['config_name'].': </label>
<div class="col-sm-6 config-response">
<input type="input" class="form-control input-sm config-item" name="'.$cfg['config_id'].'" id="'.$cfg['config_id'].'" value="'.$cfg['config_value'].'">
</div>
<div class="col-sm-1">
<div data-toggle="tooltip" title="'.$cfg['config_desc'].'" class="toolTip glyphicon glyphicon-question-sign"></div>
<script>
$(".toolTip").tooltip();
</script>
</div>
<div class="col-sm-2">
<input type="checkbox" name="config-status" data-config_id="'.$cfg['config_id'].'" data-off-text="On" data-on-text="Off" data-on-color="danger" '.$cfg_disabled.'>
</div>
</div>
');
}
echo('
</div>
</div>
</div>
');
}
echo('
<script>
$("#expand").click(function () {
$(".collapse").collapse("show");
});
$("#collapse").click(function () {
$(".collapse").collapse("hide");
});
</script>
');
if ($debug)
{
echo("<pre>");
print_r($config);
echo("</pre>");
}
?>
<script>
$(function() {
$("button#submit").click(function(){
$.ajax({
type: "POST",
url: "form_new_config.php",
data: $('form.new_config_form').serialize(),
success: function(msg){
$("#thanks").html('<div class="alert alert-info">'+msg+'</div>')
$("#new-config-form").modal('hide');
},
error: function(){
alert("failure");
}
});
});
});
</script>
<script>
$( ".config-item" ).blur(function(event) {
event.preventDefault();
var config_id = $(this).attr('id');
var data = $(this).val();
var $this = $(this);
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: { type: "config-item-update", config_id: config_id, data: data},
dataType: "html",
success: function(data){
$this.closest('.config-response').addClass('has-success');
setTimeout(function(){
$this.closest('.config-response').removeClass('has-success');
}, 2000);
},
error:function(){
$(this).closest('.config-response').addClass('has-error');
setTimeout(function(){
$this.closest('.config-response').removeClass('has-error');
}, 2000);
}
});
});
</script>
<script>
$("[name='config-status']").bootstrapSwitch('offColor','success');
$('input[name="config-status"]').on('switchChange.bootstrapSwitch', function(event, state) {
event.preventDefault();
var $this = $(this);
var config_id = $(this).data("config_id");
$.ajax({
type: 'POST',
url: '/ajax_form.php',
data: { type: "config-item-disable", config_id: config_id, state: state},
dataType: "html",
success: function(data){
//alert('good');
},
error:function(){
//alert('bad');
}
});
});
</script>
<?php
if( $_SESSION['userlevel'] >= 10 ) {
echo "<div class='table-responsive'>".a2t($config)."</div>";
} else {
include("includes/error-no-perm.inc.php");
}
?>

View File

@@ -1,5 +1,96 @@
<?php
// Observium Includes
include_once($config['install_dir'] . "/includes/dbFacile.php");
// Connect to database
$database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']);
if (!$database_link)
{
echo("<h2>MySQL Error</h2>");
echo(mysql_error());
die;
}
$database_db = mysql_select_db($config['db_name'], $database_link);
function create_array(&$arr,$string,$data,$type)
{
// The original source of this code is from Stackoverflow (www.stackoverflow.com).
// http://stackoverflow.com/questions/9145902/create-variable-length-array-from-string
// Answer provided by stewe (http://stackoverflow.com/users/511300/stewe)
// This code is slightly adapted from the original posting.
$a=explode(',',$string);
$last=count($a)-1;
$p=&$arr;
foreach($a as $k=>$key)
{
if ($k==$last)
{
if($type == 'multi')
{
$p[$key]=explode(',',$data);
}
elseif($type == 'single')
{
$p[$key]=$data;
}
}
else if (is_array($p))
{
// $p[$key]=array();
}
$p=&$p[$key];
}
}
// We should be able to get config values from the DB now.
// Single field config values
$config_vars = get_defined_vars();
$single_config = dbFetchRows("SELECT `config_name`, `config_value` FROM `config` WHERE `config_type` = 'single' AND `config_disabled` = '0'");
foreach ($single_config as $config_data)
{
$tmp_name = $config_data['config_name'];
if(!array_key_exists($config[$tmp_name], $config_vars))
{
$config[$tmp_name] = $config_data['config_value'];
}
}
// Array config values
$config_vars = get_defined_vars();
$array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'array' AND `config_disabled` = '0' GROUP BY config_name");
foreach ($array_config as $config_data)
{
$tmp_name = $config_data['config_name'];
if(!array_key_exists($config[$tmp_name], $config_vars))
{
$config[$tmp_name] = explode(',',$config_data['config_value']);
}
}
// Multi-array config values
$config_vars = get_defined_vars();
$multi_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'multi-array' AND `config_disabled` = '0' GROUP BY config_name");
foreach ($multi_array_config as $config_data)
{
create_array($config,$config_data['config_name'],$config_data['config_value'],'multi');
}
// Single-array config values
$config_vars = get_defined_vars();
$single_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'single-array' AND `config_disabled` = '0' GROUP BY config_name");
foreach ($single_array_config as $config_data)
{
// $tmp_name = explode(',',$config_data['config_name']);
// $new_name = implode('][',$tmp_name);
// if(!array_key_exists($config["{$tmp_name}"], $config_vars))
// {
// $config["{$new_name}"] = $config_data['config_value'];
// }
create_array($config,$config_data['config_name'],$config_data['config_value'],'single');
}
/////////////////////////////////////////////////////////
# NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE #
/////////////////////////////////////////////////////////
@@ -1726,17 +1817,7 @@ if (isset($_SERVER['HTTPS']))
$config['base_url'] = preg_replace('/^http:/','https:', $config['base_url']);
}
// Connect to database
$database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']);
if (!$database_link)
{
echo("<h2>MySQL Error</h2>");
echo(mysql_error());
die;
}
$database_db = mysql_select_db($config['db_name'], $database_link);
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if (class_exists("Memcached"))
{

View File

@@ -18,6 +18,7 @@ include_once("Net/IPv4.php");
include_once("Net/IPv6.php");
// Observium Includes
include_once($config['install_dir'] . "/includes/dbFacile.php");
include_once($config['install_dir'] . "/includes/common.php");
include_once($config['install_dir'] . "/includes/rrdtool.inc.php");
@@ -27,7 +28,6 @@ include_once($config['install_dir'] . "/includes/syslog.php");
include_once($config['install_dir'] . "/includes/rewrites.php");
include_once($config['install_dir'] . "/includes/snmp.inc.php");
include_once($config['install_dir'] . "/includes/services.inc.php");
include_once($config['install_dir'] . "/includes/dbFacile.php");
include_once($config['install_dir'] . "/includes/console_colour.php");
$console_color = new Console_Color2();

View File

@@ -97,7 +97,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'])
if ($config['memcached']['enable'] === TRUE)
{
$memcache->set('sensor-'.$sensor['sensor_id'].'-value', $sensor_value);
} else {

View File

@@ -46,7 +46,7 @@ foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device
$mempool['state']['mempool_lowestfree'] = $mempool['lowestfree'];
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if($debug) { print_r($mempool['state']); }
$memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']);

View File

@@ -164,7 +164,7 @@ foreach ($ports as $port)
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; }
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$state = $memcache->get('port-'.$port['port_id'].'-state');
if($debug) { print_r($state); }
@@ -184,7 +184,7 @@ foreach ($ports as $port)
$port['update']['poll_period'] = $polled_period;
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state']['poll_time'] = $polled;
$port['state']['poll_prev'] = $port['poll_time'];
@@ -303,7 +303,7 @@ foreach ($ports as $port)
$port['update'][$oid.'_prev'] = $port[$oid];
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state'][$oid] = $this_port[$oid];
$port['state'][$oid.'_prev'] = $port[$oid];
@@ -323,7 +323,7 @@ foreach ($ports as $port)
$port['update'][$oid.'_delta'] = $oid_diff;
}
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$port['state'][$oid.'_rate'] = $oid_rate;
$port['state'][$oid.'_delta'] = $oid_diff;
@@ -356,7 +356,7 @@ foreach ($ports as $port)
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'])
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'];
@@ -434,7 +434,7 @@ foreach ($ports as $port)
if ($device['os'] == "aos") { include("port-alcatel.inc.php"); }
// Update Memcached
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
if($debug) { print_r($port['state']); }
$memcache->set('port-'.$port['port_id'].'-state', $port['state']);

View File

@@ -36,7 +36,7 @@ foreach (dbFetchRows("SELECT * FROM storage WHERE device_id = ?", array($device[
rrdtool_update($storage_rrd,"N:".$storage['used'].":".$storage['free']);
if ($config['memcached']['enable'])
if ($config['memcached']['enable'] === TRUE)
{
$memcache->set('storage-'.$storage['storage_id'].'-used', $storage['used']);
$memcache->set('storage-'.$storage['storage_id'].'-free', $storage['free']);