mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix sensors rrd name issue
Use last instead of first, as last won't flush rrdcached Only stream_select if timeout > 0 Attempt to fix mysql
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id']));
|
||||
|
||||
$array = array(
|
||||
|
@@ -6,31 +6,31 @@ $mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])
|
||||
|
||||
if (rrdtool_check_rrd_exists($mysql_rrd)) {
|
||||
$rrd_filename = $mysql_rrd;
|
||||
}
|
||||
|
||||
$rrd_options .= ' DEF:a='.$rrd_filename.':IBIRd:AVERAGE ';
|
||||
$rrd_options .= ' DEF:b='.$rrd_filename.':IBIWr:AVERAGE ';
|
||||
$rrd_options .= ' DEF:c='.$rrd_filename.':IBILg:AVERAGE ';
|
||||
$rrd_options .= ' DEF:d='.$rrd_filename.':IBIFSc:AVERAGE ';
|
||||
$rrd_options .= ' DEF:a=' . $rrd_filename . ':IBIRd:AVERAGE ';
|
||||
$rrd_options .= ' DEF:b=' . $rrd_filename . ':IBIWr:AVERAGE ';
|
||||
$rrd_options .= ' DEF:c=' . $rrd_filename . ':IBILg:AVERAGE ';
|
||||
$rrd_options .= ' DEF:d=' . $rrd_filename . ':IBIFSc:AVERAGE ';
|
||||
|
||||
$rrd_options .= 'COMMENT:" Current Average Maximum\n" ';
|
||||
$rrd_options .= 'COMMENT:" Current Average Maximum\n" ';
|
||||
|
||||
$rrd_options .= 'LINE1:a#22FF22:"File Reads " ';
|
||||
$rrd_options .= 'GPRINT:a:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:a:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:a:MAX:"%6.2lf %s\\n" ';
|
||||
$rrd_options .= 'LINE1:a#22FF22:"File Reads " ';
|
||||
$rrd_options .= 'GPRINT:a:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:a:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:a:MAX:"%6.2lf %s\\n" ';
|
||||
|
||||
$rrd_options .= 'LINE1:b#0022FF:"File Writes " ';
|
||||
$rrd_options .= 'GPRINT:b:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:b:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:b:MAX:"%6.2lf %s\\n" ';
|
||||
$rrd_options .= 'LINE1:b#0022FF:"File Writes " ';
|
||||
$rrd_options .= 'GPRINT:b:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:b:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:b:MAX:"%6.2lf %s\\n" ';
|
||||
|
||||
$rrd_options .= 'LINE1:c#FF0000:"Log Writes " ';
|
||||
$rrd_options .= 'GPRINT:c:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:c:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:c:MAX:"%6.2lf %s\\n" ';
|
||||
$rrd_options .= 'LINE1:c#FF0000:"Log Writes " ';
|
||||
$rrd_options .= 'GPRINT:c:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:c:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:c:MAX:"%6.2lf %s\\n" ';
|
||||
|
||||
$rrd_options .= 'LINE1:d#00AAAA:"File syncs " ';
|
||||
$rrd_options .= 'GPRINT:d:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:d:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:d:MAX:"%6.2lf %s\\n" ';
|
||||
$rrd_options .= 'LINE1:d#00AAAA:"File syncs " ';
|
||||
$rrd_options .= 'GPRINT:d:LAST:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:d:AVERAGE:"%6.2lf %s" ';
|
||||
$rrd_options .= 'GPRINT:d:MAX:"%6.2lf %s\\n" ';
|
||||
}
|
@@ -57,9 +57,12 @@ $graph_types = array(
|
||||
'upkts' => 'Unicast Packets',
|
||||
'nupkts' => 'Non-Unicast Packets',
|
||||
'errors' => 'Errors',
|
||||
'etherlike' => 'Etherlike',
|
||||
);
|
||||
|
||||
if ($config['enable_ports_etherlike']) {
|
||||
$graph_types['etherlike'] = 'Etherlike';
|
||||
}
|
||||
|
||||
foreach ($graph_types as $type => $descr) {
|
||||
echo "$type_sep";
|
||||
if ($vars['graph'] == $type && $vars['view'] == 'graphs') {
|
||||
|
@@ -129,14 +129,19 @@ function sgn($int) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_sensor_rrd($device, $sensor) {
|
||||
function get_sensor_rrd($device, $sensor)
|
||||
{
|
||||
return rrd_name($device['hostname'], get_sensor_rrd_name($device, $sensor));
|
||||
}
|
||||
|
||||
function get_sensor_rrd_name($device, $sensor) {
|
||||
global $config;
|
||||
|
||||
# For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here.
|
||||
if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") {
|
||||
return "sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_descr'];
|
||||
return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_descr']);
|
||||
} else {
|
||||
return "sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_index'];
|
||||
return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_index']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,15 +15,6 @@ else {
|
||||
|
||||
echo ' mysql';
|
||||
|
||||
$data = explode("\n", $mysql);
|
||||
|
||||
$map = array();
|
||||
foreach ($data as $str) {
|
||||
list($key, $value) = explode(':', $str);
|
||||
$map[$key] = (float) trim($value);
|
||||
// $nstring .= (float)trim($elements[1]).":";
|
||||
}
|
||||
|
||||
// General Stats
|
||||
$mapping = array(
|
||||
'IDBLBSe' => 'cr',
|
||||
@@ -108,7 +99,15 @@ $mapping = array(
|
||||
'CUMi' => 'c9',
|
||||
);
|
||||
|
||||
unset($fields);
|
||||
$data = explode("\n", $mysql);
|
||||
|
||||
$map = array();
|
||||
foreach ($data as $str) {
|
||||
list($key, $value) = explode(':', $str);
|
||||
$map[$key] = (float) trim($value);
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
foreach ($mapping as $k => $v) {
|
||||
$fields[$k] = isset($map[$v]) ? $map[$v] : (-1);
|
||||
}
|
||||
|
@@ -107,7 +107,7 @@ function poll_sensor($device, $class, $unit) {
|
||||
$sensor_value = ($sensor_value * $sensor['sensor_multiplier']);
|
||||
}
|
||||
|
||||
$rrd_name = get_sensor_rrd($device, $sensor);
|
||||
$rrd_name = get_sensor_rrd_name($device, $sensor);
|
||||
$rrd_def = 'DS:sensor:GAUGE:600:-20000:20000';
|
||||
|
||||
echo "$sensor_value $unit\n";
|
||||
|
@@ -29,7 +29,7 @@ if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
|
||||
|
||||
echo $sensor." $unit\n";
|
||||
|
||||
$rrd_name = get_sensor_rrd($device, $ipmisensors);
|
||||
$rrd_name = get_sensor_rrd_name($device, $ipmisensors);
|
||||
$rrd_def = 'DS:sensor:GAUGE:600:-20000:20000';
|
||||
|
||||
$fields = array(
|
||||
|
@@ -186,7 +186,9 @@ function rrdtool($command, $filename, $options, $timeout=0)
|
||||
fwrite($rrd_pipes[0], $cmd."\n");
|
||||
}
|
||||
|
||||
stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout);
|
||||
if($timeout > 0) {
|
||||
stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout);
|
||||
}
|
||||
$output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2]));
|
||||
|
||||
if ($debug) {
|
||||
@@ -226,7 +228,7 @@ function rrdtool_check_rrd_exists($filename)
|
||||
{
|
||||
global $config;
|
||||
if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) {
|
||||
$chk = rrdtool('first', $filename, '', 5); // wait up to 5 seconds
|
||||
$chk = rrdtool('last', $filename, '', 5); // wait up to 5 seconds
|
||||
return substr(rtrim($chk[0]), -25) !== 'No such file or directory';
|
||||
} else {
|
||||
return is_file($filename);
|
||||
|
Reference in New Issue
Block a user