Exemple #1
0
function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
{
    $usedoids = array();
    foreach ($oids as $index => $array) {
        foreach ($array as $oid => $val) {
            $type = oid_rrd_type($oid, $mibdef);
            if ($type === false) {
                continue;
            }
            $usedoids[$index][$oid] = $val;
            rrd_create_update($device, array($mibname, $mibdef[$oid]['shortname'], $index), array("DS:" . $mibdef[$oid]['dsname'] . ":{$type}"), "N:{$val}");
        }
    }
    tag_graphs($mibname, $usedoids, $mibdef, $graphs);
    update_mib_graph_types($mibname, $usedoids, $mibdef, $graphs);
}
Exemple #2
0
function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
{
    $usedoids = array();
    $deviceoids = array();
    foreach ($oids as $index => $array) {
        foreach ($array as $obj => $val) {
            // build up the device_oid row for saving into the database
            $numvalue = is_numeric($val) ? $val + 0 : 0;
            $deviceoids[] = array('device_id' => $device['device_id'], 'oid' => $mibdef[$obj]['oid'] . "." . $index, 'module' => $mibdef[$obj]['module'], 'mib' => $mibdef[$obj]['mib'], 'object_type' => $obj, 'value' => $val, 'numvalue' => $numvalue);
            $type = oid_rrd_type($obj, $mibdef);
            if ($type === false) {
                continue;
            }
            $usedoids[$index][$obj] = $val;
            $tags = array('rrd_def' => array("DS:mibval:{$type}"), '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'], 'mib' => $mibdef[$obj]['mib'], 'object_type' => $obj);
            data_update($device, 'mibval', $tags, $val);
        }
    }
    tag_graphs($mibname, $usedoids, $mibdef, $graphs);
    update_mib_graph_types($mibname, $usedoids, $mibdef, $graphs);
    // update database
    $columns = array('device_id', 'oid', 'module', 'mib', 'object_type', 'value', 'numvalue');
    update_db_table('device_oids', $columns, 2, $deviceoids);
}
Exemple #3
0
function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
{
    $usedoids = array();
    $deviceoids = array();
    foreach ($oids as $index => $array) {
        foreach ($array as $obj => $val) {
            // build up the device_oid row for saving into the database
            $numvalue = is_numeric($val) ? $val + 0 : 0;
            $deviceoids[] = array('device_id' => $device['device_id'], 'oid' => $mibdef[$obj]['oid'] . "." . $index, 'module' => $mibdef[$obj]['module'], 'mib' => $mibdef[$obj]['mib'], 'object_type' => $obj, 'value' => $val, 'numvalue' => $numvalue);
            $type = oid_rrd_type($obj, $mibdef);
            if ($type === false) {
                continue;
            }
            $usedoids[$index][$obj] = $val;
            // if there's a file from the previous version of MIB-based polling, rename it
            if (rrd_file_exists($device, array($mibname, $mibdef[$obj]['object_type'], $index)) && !rrd_file_exists($device, array($mibname, $mibdef[$obj]['shortname'], $index))) {
                rrd_file_rename($device, array($mibname, $mibdef[$obj]['object_type'], $index), array($mibname, $mibdef[$obj]['shortname'], $index));
                // Note: polling proceeds regardless of rename result
            }
            rrd_create_update($device, array($mibname, $mibdef[$obj]['shortname'], $index), array("DS:mibval:{$type}"), array("mibval" => $val));
        }
    }
    tag_graphs($mibname, $usedoids, $mibdef, $graphs);
    update_mib_graph_types($mibname, $usedoids, $mibdef, $graphs);
    // update database
    $columns = array('device_id', 'oid', 'module', 'mib', 'object_type', 'value', 'numvalue');
    update_db_table('device_oids', $columns, 2, $deviceoids);
}