diff --git a/html/includes/graphs/sensor/auth.inc.php b/html/includes/graphs/sensor/auth.inc.php index cdd274ca06..c16346dfab 100644 --- a/html/includes/graphs/sensor/auth.inc.php +++ b/html/includes/graphs/sensor/auth.inc.php @@ -9,7 +9,8 @@ if (is_numeric($id)) $device = device_by_id_cache($sensor['device_id']); ### This doesn't quite work for all yet. - $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename($sensor['sensor_class']."-" . $sensor['sensor_type'] . "-".$sensor['sensor_index'].".rrd"); + #$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename($sensor['sensor_class']."-" . $sensor['sensor_type'] . "-".$sensor['sensor_index'].".rrd"); + $rrd_filename = get_sensor_rrd($device, $sensor); $title = generate_device_link($device); $title .= " :: Sensor :: " . htmlentities($sensor['sensor_descr']); @@ -17,4 +18,4 @@ if (is_numeric($id)) } } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/current.inc.php b/html/includes/graphs/sensor/current.inc.php index c0d12ede42..381d1e2707 100644 --- a/html/includes/graphs/sensor/current.inc.php +++ b/html/includes/graphs/sensor/current.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $sensor['sensor_descr'] . ".rrd"); - $rrd_options .= " COMMENT:' Min Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 18),0,18); @@ -19,4 +17,4 @@ $rrd_options .= " GPRINT:sensor:MAX:%5.2lfA\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/fanspeed.inc.php b/html/includes/graphs/sensor/fanspeed.inc.php index c7c83859e5..d6cd7866fe 100644 --- a/html/includes/graphs/sensor/fanspeed.inc.php +++ b/html/includes/graphs/sensor/fanspeed.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fanspeed-" . $sensor['sensor_type'] .'-'. $sensor['sensor_index'] . ".rrd"); - $rrd_options .= " COMMENT:' Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 20),0,20); @@ -18,4 +16,4 @@ $rrd_options .= " GPRINT:sensor:MAX:%3.0lfrpm\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/frequency.inc.php b/html/includes/graphs/sensor/frequency.inc.php index ba3bf3f79c..27629e65cc 100644 --- a/html/includes/graphs/sensor/frequency.inc.php +++ b/html/includes/graphs/sensor/frequency.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("frequency-" . $sensor['sensor_descr'] . ".rrd"); - $rrd_options .= " COMMENT:' Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); @@ -18,4 +16,4 @@ $rrd_options .= " GPRINT:sensor:MAX:%3.0lfHz\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/humidity.inc.php b/html/includes/graphs/sensor/humidity.inc.php index 08a51035f1..da099cdc94 100644 --- a/html/includes/graphs/sensor/humidity.inc.php +++ b/html/includes/graphs/sensor/humidity.inc.php @@ -5,8 +5,6 @@ $scale_max = "40"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("humidity-" . $sensor['sensor_descr'] . ".rrd"); - $rrd_options .= " COMMENT:' Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); @@ -30,4 +28,4 @@ $rrd_options .= " GPRINT:sensor:MAX:%3.0lf%%\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/power.inc.php b/html/includes/graphs/sensor/power.inc.php index e7e356f2b7..948abdbca5 100644 --- a/html/includes/graphs/sensor/power.inc.php +++ b/html/includes/graphs/sensor/power.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/power-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " -A "; $rrd_options .= " COMMENT:' Last Max\\n'"; diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index baf6872121..ea34c3eb0c 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -5,8 +5,6 @@ $scale_max = "60"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " COMMENT:' Min Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 21),0,21); @@ -34,4 +32,4 @@ $rrd_options .= " GPRINT:sensor_max:MAX:%4.1lfC\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/sensor/voltage.inc.php b/html/includes/graphs/sensor/voltage.inc.php index dfd37e9de8..4722f04a76 100644 --- a/html/includes/graphs/sensor/voltage.inc.php +++ b/html/includes/graphs/sensor/voltage.inc.php @@ -4,8 +4,6 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/voltage-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " -A "; $rrd_options .= " COMMENT:' Last Max\\n'"; @@ -27,4 +25,4 @@ $rrd_options .= " GPRINT:sensor:MAX:%6.2lfV\\\\l"; if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; -?> \ No newline at end of file +?> diff --git a/includes/common.php b/includes/common.php index 800677f108..2b0fcd61e5 100644 --- a/includes/common.php +++ b/includes/common.php @@ -2,6 +2,21 @@ ## Common Functions +function get_sensor_rrd($device, $sensor) +{ + global $config; + + if($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") + { + $rrd_file = $config['rrd_dir']."/".$device['hostname']."/".safename("sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_descr'] . ".rrd"); + } else { + $rrd_file = $config['rrd_dir']."/".$device['hostname']."/".safename("sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_index'] . ".rrd"); + } + + return($rrd_file); + +} + function get_port_by_id($port_id) { if (is_numeric($port_id)) diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index a708b140d3..af9e5d5389 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -16,20 +16,35 @@ function poll_sensor($device, $class, $unit) if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; } if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; } - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd"); + $rrd_file = get_sensor_rrd($device, $sensor); + + #$rrd_file = $config['rrd_dir']."/".$device['hostname']."/".safename("sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_index'] . ".rrd"); + + ## FIXME - sensor name format change 2011/04/26 - remove this in $amount_of_time. + ## We don't want to reduce performance forever because douchebags don't svn up! + $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd"); + $old_rrd_file_b = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_index'] . ".rrd"); + if (is_file($old_rrd_file) && is_file($old_rrd_file_b)) + { + rename($old_rrd_file, $rrd_file); + unlink($old_rrd_file_b); + } elseif (is_file($old_rrd_file)) { + rename($old_rrd_file, $rrd_file); + } elseif (is_file($old_rrd_file_b)) { + rename($old_rrd_file_b, $rrd_file); + } if (!is_file($rrd_file)) { - rrdtool_create($rrd_file,"--step 300 \ DS:sensor:GAUGE:600:-20000:20000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:AVERAGE:0.5:12:2400 \ - RRA:AVERAGE:0.5:288:750 \ + RRA:AVERAGE:0.5:288:1200 \ RRA:MAX:0.5:12:2400 \ - RRA:MAX:0.5:288:750 \ + RRA:MAX:0.5:288:1200 \ RRA:MIN:0.5:12:2400 \ - RRA:MIN:0.5:288:750"); + RRA:MIN:0.5:288:1200"); } echo("$sensor_value $unit\n"); diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index d085bbabc4..7244ddac1b 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -23,8 +23,9 @@ while ($sensor = mysql_fetch_assoc($sensor_data)) if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; } if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; } - $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd"); - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + + $rrd_file = get_sensor_rrd($device, $sensor); if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } @@ -62,4 +63,4 @@ while ($sensor = mysql_fetch_assoc($sensor_data)) mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } -?> \ No newline at end of file +?> diff --git a/includes/polling/voltages.inc.php b/includes/polling/voltages.inc.php index 61d0db889c..87d88e6401 100755 --- a/includes/polling/voltages.inc.php +++ b/includes/polling/voltages.inc.php @@ -15,8 +15,8 @@ while ($sensor = mysql_fetch_assoc($sensor_data)) if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; } if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; } - $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd"); - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + $rrd_file = get_sensor_rrd($device, $sensor); if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } @@ -53,4 +53,4 @@ while ($sensor = mysql_fetch_assoc($sensor_data)) mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } -?> \ No newline at end of file +?>