First cut at working poller for MIBs

This commit is contained in:
Paul Gear
2015-06-16 08:27:56 +10:00
parent 8f5bc4cdb6
commit 4af7dd8225
6 changed files with 129 additions and 18 deletions
+24
View File
@@ -346,4 +346,28 @@ function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_gra
return TRUE;
}
/*
* Please use this instead of creating & updating RRD files manually.
* @param device Device object - only 'hostname' is used at present
* @param name Array of name objects - filename will be constructed using this with a "-" delimiter
* @param def Array of data definitions
* @param val Array of value definitions
*
*/
function rrd_create_update($device, $name, $def, $val, $step = 300)
{
global $config;
$rrd = implode("/", array($config['rrd_dir'], $device['hostname'], safename(implode("-", $name)).".rrd"));
d_echo("RRD file: $rrd");
if (!is_file($rrd)) {
// add the --step and the rra definitions to the array
$newdef = "--step $step ".implode(' ', $def).$config['rrd_rra'];
d_echo("Creating RRD $rrd: $newdef");
rrdtool_create($rrd, $newdef);
}
rrdtool_update($rrd, $val);
}
?>