Exemple #1
0
function register_mibs($device, $mibs, $included_by)
{
    if (!is_mib_poller_enabled($device)) {
        return;
    }
    echo "MIB: registering\n";
    foreach ($mibs as $name => $module) {
        $translated = snmp_translate($name, $module);
        if ($translated) {
            $mod = $translated[0];
            $nam = $translated[1];
            echo "     {$mod}::{$nam}\n";
            if (snmp_mib_load($nam, $mod, $included_by) > 0) {
                // NOTE: `last_modified` omitted due to being automatically maintained by MySQL
                $columns = array('device_id', 'module', 'mib', 'included_by');
                $rows = array();
                $rows[] = array('device_id' => $device['device_id'], 'module' => $mod, 'mib' => $nam, 'included_by' => $included_by);
                update_db_table('device_mibs', $columns, 3, $rows);
            } else {
                echo "MIB: Could not load definition for {$mod}::{$nam}\n";
            }
        } else {
            echo "MIB: Could not find {$module}::{$name}\n";
        }
    }
    echo "\n";
}
Exemple #2
0
function poll_mibs($list, $device, &$graphs)
{
    if (!is_dev_attrib_enabled($device, "poll_mib")) {
        d_echo("MIB module disabled for " . $device['hostname'] . "\n");
        return;
    }
    $mibdefs = array();
    echo "MIB-based polling:";
    d_echo("\n");
    foreach ($list as $name => $module) {
        $translated = snmp_translate($name, $module);
        if ($translated) {
            echo " {$module}::{$name}";
            d_echo("\n");
            $mod = $translated[0];
            $nam = $translated[1];
            $mibdefs[$nam] = snmp_mib_load($nam, $mod);
            $oids = snmpwalk_cache_oid($device, $nam, array(), $mod, null, "-OQUsb");
            d_print_r($oids);
            save_mibs($device, $nam, $oids, $mibdefs[$nam], $graphs);
        } else {
            d_echo("MIB: no match for {$module}::{$name}\n");
        }
    }
    d_echo("Done MIB-based polling");
    echo "\n";
}