Build in automated RRD file renaming

This commit is contained in:
Paul Gear
2016-01-15 21:49:58 +10:00
parent f61d0a4016
commit ee75253310
3 changed files with 10 additions and 13 deletions
+4 -7
View File
@@ -14,14 +14,11 @@ if ($config['enable_printers']) {
$tonerperc = round((snmp_get($device, $toner['toner_oid'], '-OUqnv') / $toner['toner_capacity'] * 100));
echo $tonerperc." %\n";
$old = array('toner', $toner['toner_descr']);
$new = array('toner', $toner['toner_index']);
rrd_file_rename($device, $old, $new);
$tags = array(
'rrd_def' => 'DS:toner:GAUGE:600:0:20000',
'rrd_name' => $new,
'index' => $toner['toner_index'],
'rrd_def' => 'DS:toner:GAUGE:600:0:20000',
'rrd_name' => array('toner', $toner['toner_index']),
'rrd_oldname' => array('toner', $toner['toner_descr']),
'index' => $toner['toner_index'],
);
data_update($device, 'toner', $tags, $tonerperc);
+4
View File
@@ -341,6 +341,10 @@ function rrdtool_data_update($device, $measurement, $tags, $fields)
$rrd_name = $tags['rrd_name'] ? $tags['rrd_name'] : $measurement;
$step = $tags['rrd_step'] ? $tags['rrd_step'] : 300;
$oldname = $tags['rrd_oldname'];
if (isset($oldname) && !empty($oldname)) {
rrd_file_rename($device, $oldname, $rrd_name);
}
$rrd = rrd_name($device['hostname'], $rrd_name);
if (!is_file($rrd) && $tags['rrd_def']) {
+2 -6
View File
@@ -1142,14 +1142,10 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
$usedoids[$index][$obj] = $val;
// if there's a file from the previous version of MIB-based polling, rename it
$old = array($mibname, $mibdef[$obj]['object_type'], $index);
$new = array($mibname, $mibdef[$obj]['shortname'], $index);
rrd_file_rename($device, $old, $new);
$tags = array(
'rrd_def' => array("DS:mibval:$type"),
'rrd_name' => $new,
'rrd_name' => array($mibname, $mibdef[$obj]['shortname'], $index),
'rrd_oldname' => array($mibname, $mibdef[$obj]['object_type'], $index),
'index' => $index,
'oid' => $mibdef[$obj]['oid'],
'module' => $mibdef[$obj]['module'],