mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-02 16:01:56 +02:00
Build in automated RRD file renaming
This commit is contained in:
@@ -14,14 +14,11 @@ if ($config['enable_printers']) {
|
|||||||
$tonerperc = round((snmp_get($device, $toner['toner_oid'], '-OUqnv') / $toner['toner_capacity'] * 100));
|
$tonerperc = round((snmp_get($device, $toner['toner_oid'], '-OUqnv') / $toner['toner_capacity'] * 100));
|
||||||
echo $tonerperc." %\n";
|
echo $tonerperc." %\n";
|
||||||
|
|
||||||
$old = array('toner', $toner['toner_descr']);
|
|
||||||
$new = array('toner', $toner['toner_index']);
|
|
||||||
rrd_file_rename($device, $old, $new);
|
|
||||||
|
|
||||||
$tags = array(
|
$tags = array(
|
||||||
'rrd_def' => 'DS:toner:GAUGE:600:0:20000',
|
'rrd_def' => 'DS:toner:GAUGE:600:0:20000',
|
||||||
'rrd_name' => $new,
|
'rrd_name' => array('toner', $toner['toner_index']),
|
||||||
'index' => $toner['toner_index'],
|
'rrd_oldname' => array('toner', $toner['toner_descr']),
|
||||||
|
'index' => $toner['toner_index'],
|
||||||
);
|
);
|
||||||
data_update($device, 'toner', $tags, $tonerperc);
|
data_update($device, 'toner', $tags, $tonerperc);
|
||||||
|
|
||||||
|
|||||||
@@ -341,6 +341,10 @@ function rrdtool_data_update($device, $measurement, $tags, $fields)
|
|||||||
|
|
||||||
$rrd_name = $tags['rrd_name'] ? $tags['rrd_name'] : $measurement;
|
$rrd_name = $tags['rrd_name'] ? $tags['rrd_name'] : $measurement;
|
||||||
$step = $tags['rrd_step'] ? $tags['rrd_step'] : 300;
|
$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);
|
$rrd = rrd_name($device['hostname'], $rrd_name);
|
||||||
if (!is_file($rrd) && $tags['rrd_def']) {
|
if (!is_file($rrd) && $tags['rrd_def']) {
|
||||||
|
|||||||
@@ -1142,14 +1142,10 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
|
|||||||
|
|
||||||
$usedoids[$index][$obj] = $val;
|
$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(
|
$tags = array(
|
||||||
'rrd_def' => array("DS:mibval:$type"),
|
'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,
|
'index' => $index,
|
||||||
'oid' => $mibdef[$obj]['oid'],
|
'oid' => $mibdef[$obj]['oid'],
|
||||||
'module' => $mibdef[$obj]['module'],
|
'module' => $mibdef[$obj]['module'],
|
||||||
|
|||||||
Reference in New Issue
Block a user