Example #1
0
        foreach ($config['mibs'][$mib]['status'] as $oid => $oid_data) {
            print_cli($oid . ' [');
            foreach ($oid_data['indexes'] as $index => $entry) {
                $entry['oid'] = $oid;
                if (empty($entry['oid_num'])) {
                    // Use snmptranslate if oid_num not set
                    $entry['oid_num'] = snmp_translate($oid . '.' . $index, $mib);
                }
                $value = snmp_get($device, $entry['oid_num'], '-OQUvsn');
                if (is_numeric($value)) {
                    // Fetch description from oid if specified
                    if (isset($entry['oid_descr'])) {
                        $entry['descr'] = snmp_get($device, $entry['oid_descr'], '-OQUvs');
                    }
                    rename_rrd($device, "status-" . $entry['type'] . '-' . $index, "status-" . $entry['type'] . '-' . "{$oid}.{$index}");
                    discover_status($device, $entry['oid_num'], "{$oid}.{$index}", $entry['type'], $entry['descr'], $value, array('entPhysicalClass' => $entry['measured']));
                }
            }
            print_cli('] ');
        }
        print_cli('] ');
    }
}
if (OBS_DEBUG > 1 && count($valid['sensor'])) {
    print_vars($valid['sensor']);
}
foreach (array_keys($config['sensor_types']) as $type) {
    check_valid_sensors($device, $type, $valid['sensor']);
}
if (OBS_DEBUG > 1 && count($valid['status'])) {
    print_vars($valid['status']);
    $value = $entry['npSmokeStatus'];
    if ($value) {
        discover_status($device, $oid, 'npSmokeStatus.' . $index, 'dskf-mib-smoke-state', $descr, $value, array('entPhysicalClass' => 'other'));
    }
}
$cache_discovery['DKSF-50-11-X-X-X']['loop'] = snmpwalk_cache_multi_oid($device, 'npCurLoopTable', array(), 'DKSF-50-11-X-X-X');
foreach ($cache_discovery['DKSF-50-11-X-X-X']['loop'] as $index => $entry) {
    if ($entry['npCurLoopPower'] == 'off' || $entry['npCurLoopStatus'] == 'notPowered') {
        continue;
    }
    $descr = 'Analog Smoke ' . $index;
    // Loop state
    $oid = '.1.3.6.1.4.1.25728.8300.1.1.2.' . $index;
    $value = $entry['npCurLoopStatus'];
    if ($value) {
        discover_status($device, $oid, 'npCurLoopStatus.' . $index, 'dskf-mib-loop-state', $descr, $value, array('entPhysicalClass' => 'other'));
    }
    // Loop current
    $oid = '.1.3.6.1.4.1.25728.8300.1.1.3.' . $index;
    $value = $entry['npCurLoopI'];
    if ($value) {
        discover_sensor($valid['sensor'], 'current', $device, $oid, 'npCurLoopI.' . $index, 'dskf-mib-loop', $descr, 0.001, $value);
    }
    // Loop voltage
    $oid = '.1.3.6.1.4.1.25728.8300.1.1.4.' . $index;
    $value = $entry['npCurLoopV'];
    if ($value) {
        discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'npCurLoopV.' . $index, 'dskf-mib-loop', $descr, 0.001, $value);
    }
    // Loop resistance
    $oid = '.1.3.6.1.4.1.25728.8300.1.1.5.' . $index;
Example #3
0
        discover_status($device, $oid, "accessPXStatusFrontDoorAlarmStatus.{$index}", 'powernet-door-alarm-state', $descr, $entry['accessPXStatusFrontDoorAlarmStatus']);
    }
    // accessPXConfigRearDoorLockControl.0 = INTEGER: lock(2)
    // accessPXConfigRearDoorMaxOpenTime.0 = INTEGER: 10
    // accessPXStatusRearDoorLock.0 = INTEGER: locked(2)
    // accessPXStatusRearDoor.0 = INTEGER: closed(2)
    // accessPXStatusRearDoorHandle.0 = INTEGER: closed(2)
    // accessPXStatusRearDoorMaxOpenTime.0 = INTEGER: 10
    // accessPXStatusRearDoorAlarmStatus.0 = INTEGER: 1
    if ($entry['accessPXStatusRearDoorLock']) {
        $descr = 'Rear Door Lock';
        $oid = ".1.3.6.1.4.1.318.1.1.20.1.6.1.{$index}";
        discover_status($device, $oid, "accessPXStatusRearDoorLock.{$index}", 'powernet-door-lock-state', $descr, $entry['accessPXStatusRearDoorLock']);
    }
    if ($entry['accessPXStatusRearDoor']) {
        $descr = 'Rear Door';
        $oid = ".1.3.6.1.4.1.318.1.1.20.1.6.2.{$index}";
        discover_status($device, $oid, "accessPXStatusRearDoor.{$index}", 'powernet-door-state', $descr, $entry['accessPXStatusRearDoor']);
    }
    if ($entry['accessPXStatusRearDoorHandle']) {
        $descr = 'Rear Door Handle';
        $oid = ".1.3.6.1.4.1.318.1.1.20.1.6.3.{$index}";
        discover_status($device, $oid, "accessPXStatusRearDoorHandle.{$index}", 'powernet-door-state', $descr, $entry['accessPXStatusRearDoorHandle']);
    }
    if ($entry['accessPXStatusRearDoorAlarmStatus']) {
        $descr = 'Rear Door Alarm Status';
        $oid = ".1.3.6.1.4.1.318.1.1.20.1.6.5.{$index}";
        discover_status($device, $oid, "accessPXStatusRearDoorAlarmStatus.{$index}", 'powernet-door-alarm-state', $descr, $entry['accessPXStatusRearDoorAlarmStatus']);
    }
}
// EOF
Example #4
0
        if ($entry['inletName'] != '') {
            $descr = "Inlet {$index}: " . $entry['inletName'];
        } else {
            $descr = "Inlet {$index}";
        }
        $rmsCurrentThreshold = hexdec($inlet_thresholds["{$index}.{$measure_type}"]);
        $limits = array('limit_low' => $inlet_thresholds[$index . '.' . $measure_type]['inletSensorEnabledThresholds'] & 128 ? $inlet_lower_crit_threshold[$index . '.' . $measure_type]['inletSensorLowerCriticalThreshold'] * $measure_data['scale'] : null, 'limit_low_warn' => $inlet_thresholds[$index . '.' . $measure_type]['inletSensorEnabledThresholds'] & 64 ? $inlet_lower_warn_threshold[$index . '.' . $measure_type]['inletSensorLowerWarningThreshold'] * $measure_data['scale'] : null, 'limit_high_warn' => $inlet_thresholds[$index . '.' . $measure_type]['inletSensorEnabledThresholds'] & 32 ? $inlet_upper_warn_threshold[$index . '.' . $measure_type]['inletSensorUpperWarningThreshold'] * $measure_data['scale'] : null, 'limit_high' => $inlet_thresholds[$index . '.' . $measure_type]['inletSensorEnabledThresholds'] & 16 ? $inlet_upper_crit_threshold[$index . '.' . $measure_type]['inletSensorUpperCriticalThreshold'] * $measure_data['scale'] : null);
        if ($value !== false) {
            discover_sensor($valid['sensor'], $measure_data['class'], $device, $oid, "inlet.{$index}.{$measure_type}", 'raritan', $descr, $measure_data['scale'], $value, $limits);
        }
    }
}
// Over Current Protectors
$over_current_protector_names = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorName.1", array(), "PDU2-MIB");
$protector_thresholds = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorSensorEnabledThresholds.1", array(), "PDU2-MIB");
$measurements = snmpwalk_cache_oid($device, "PDU2-MIB::measurementsOverCurrentProtectorSensorValue.1", array(), "PDU2-MIB");
$over_current_protector_lower_crit_threshold = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorSensorLowerCriticalThreshold.1", array(), "PDU2-MIB");
$over_current_protector_lower_warn_threshold = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorSensorLowerWarningThreshold.1", array(), "PDU2-MIB");
$over_current_protector_upper_warn_threshold = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorSensorUpperWarningThreshold.1", array(), "PDU2-MIB");
$over_current_protector_upper_crit_threshold = snmpwalk_cache_oid($device, "PDU2-MIB::overCurrentProtectorSensorUpperCriticalThreshold.1", array(), "PDU2-MIB");
foreach ($over_current_protector_names as $index => $entry) {
    $limits = array('limit_low' => $protector_thresholds[$index . '.rmsCurrent']['overCurrentProtectorSensorEnabledThresholds'] & 128 ? $over_current_protector_lower_crit_threshold[$index . '.rmsCurrent']['overCurrentProtectorSensorLowerCriticalThreshold'] * 0.1 : null, 'limit_low_warn' => $protector_thresholds[$index . '.rmsCurrent']['overCurrentProtectorSensorEnabledThresholds'] & 64 ? $over_current_protector_lower_warn_threshold[$index . '.rmsCurrent']['overCurrentProtectorSensorLowerWarningThreshold'] * 0.1 : null, 'limit_high_warn' => $protector_thresholds[$index . '.rmsCurrent']['overCurrentProtectorSensorEnabledThresholds'] & 32 ? $over_current_protector_upper_warn_threshold[$index . '.rmsCurrent']['overCurrentProtectorSensorUpperWarningThreshold'] * 0.1 : null, 'limit_high' => $protector_thresholds[$index . '.rmsCurrent']['overCurrentProtectorSensorEnabledThresholds'] & 16 ? $over_current_protector_upper_crit_threshold[$index . '.rmsCurrent']['overCurrentProtectorSensorUpperCriticalThreshold'] * 0.1 : null);
    $value = $measurements["{$index}.rmsCurrent"]['measurementsOverCurrentProtectorSensorValue'];
    $oid = ".1.3.6.1.4.1.13742.6.5.3.3.1.4.{$index}.1";
    discover_sensor($valid['sensor'], 'current', $device, $oid, "tripsensorvalue.{$index}", 'raritan', "Over Current Protector {$index}", 0.1, $value, $limits);
    $value = $measurements["{$index}.trip"]['measurementsOverCurrentProtectorSensorValue'];
    $oid = ".1.3.6.1.4.1.13742.6.5.3.3.1.4.{$index}.15";
    // discover_sensor($valid['sensor'], 'state', $device, $oid, "tripsensor.$index", 'raritan', "Over Current Protector $index", NULL, $value, array('entPhysicalClass' => 'power'));
    discover_status($device, $oid, "measurementsOverCurrentProtectorSensorValue" . $index, "pdu2-sensorstate", "Over Current Protector {$index}", $value, array('entPhysicalClass' => 'status'));
}
// EOF
        $stateoid = '.1.3.6.1.4.1.9.9.500.1.2.1.1.6.' . $index;
        $statedescr = 'Switch ' . $entry['cswSwitchNumCurrent'] . ' stacking state';
        if ($stack_count === 1 && $entry['cswSwitchNumCurrent'] == 1 && $stackredundant == 'false' && $ports_down === 2 && $entry['cswSwitchRole'] == 'master' && $entry['cswSwitchState'] == 'ready') {
            // Heh, on IOS 15.x stacking is always enabled and does not have any way to detect if stack module exists and stacking is configured
            $stack_count = 0;
            print_debug("Stacking exists, but not configured and not active.");
            break;
            // exit foreach
        }
        if (!empty($entry['cswSwitchRole'])) {
            discover_status($device, $roleoid, "cswSwitchRole.{$index}", 'cisco-stackwise-member-state', $roledescr, $entry['cswSwitchRole'], array('entPhysicalClass' => 'stack', 'entPhysicalIndex' => $index));
            discover_status($device, $stateoid, "cswSwitchState.{$index}", 'cisco-stackwise-switch-state', $statedescr, $entry['cswSwitchState'], array('entPhysicalClass' => 'stack', 'entPhysicalIndex' => $index));
        }
    }
    if ($stack_count) {
        $oid = '.1.3.6.1.4.1.9.9.500.1.1.3.0';
        $descr = 'Stack is redundant';
        discover_status($device, $oid, "cswRingRedundant.0", 'cisco-stackwise-redundant-state', $descr, $stackredundant, array('entPhysicalClass' => 'stack'));
        foreach ($stackportoper as $index => $entry) {
            $oid = '.1.3.6.1.4.1.9.9.500.1.2.2.1.1.' . $index;
            $port = get_port_by_index_cache($device, $index);
            $descr = 'Stackport ' . $port['port_label'];
            if (!empty($entry['cswStackPortOperStatus'])) {
                $options = array('entPhysicalClass' => 'port', 'entPhysicalIndex' => $index, 'measured_class' => 'port', 'measured_entity' => $port['port_id']);
                discover_status($device, $oid, "cswStackPortOperStatus.{$index}", 'cisco-stackwise-port-oper-state', $descr, $entry['cswStackPortOperStatus'], $options);
            }
        }
    }
}
unset($device_tmp);
// EOF
            }
        }
    }
}
// Collect data about outputs
$outlets = snmpwalk_cache_twopart_oid($device, 'outletTable', array(), 'EATON-EPDU-MIB');
$outlets = snmpwalk_cache_twopart_oid($device, 'outletCurrentTable', $outlets, 'EATON-EPDU-MIB');
// Power statistics currently not collected.
//$outlets      = snmpwalk_cache_twopart_oid($device, 'outletCurrentTable', $outlets, 'EATON-EPDU-MIB');
foreach ($outlets as $unit_id => $unit_data) {
    foreach ($unit_data as $outlet_id => $outlet) {
        $outlet_index = $unit_id . "." . $outlet_id;
        $outlet_descr = "Unit {$unit_id} " . $outlet['outletName'] . " (" . $outlet['outletType'] . ")";
        $outlet_capacity = $outlet['outletCurrentCapacity'] * 0.001;
        $current_value = $outlet['outletCurrent'];
        $percent_value = $outlet['outletCurrentPercentLoad'];
        $status_value = $outlet['outletCurrentThStatus'];
        $crest_value = $outlet['outletCurrentCrestFactor'];
        $current_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.3.' . $outlet_index;
        $percent_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.10.' . $outlet_index;
        $status_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.4.' . $outlet_index;
        $crest_oid = '.1.3.6.1.4.1.534.6.6.7.6.4.1.9.' . $outlet_index;
        discover_status($device, $status_oid, "outletCurrentThStatus." . $outlet_index, 'outletCurrentThStatus', $outlet_descr, $status_value, array('entPhysicalClass' => 'outlet'));
        $limits = array('limit_low' => $entry['outletCurrentThLowerCritical'] * 0.001, 'limit_low_warn' => $entry['outletCurrentThLowerWarning'] * 0.001, 'limit_high' => $entry['outletCurrentThUpperCritical'] * 0.001, 'limit_high_warn' => $entry['outletCurrentThUpperWarning'] * 0.001);
        discover_sensor($valid['sensor'], 'current', $device, $current_oid, "outletCurrent.{$outlet_index}", 'eaton-epdu-mib', $outlet_descr, 0.001, $current_value, $limits);
        discover_sensor($valid['sensor'], 'load', $device, $percent_oid, "outletCurrentPercentLoad.{$outlet_index}", 'eaton-epdu-mib', $outlet_descr, 1, $percent_value);
        discover_sensor($valid['sensor'], 'crestfactor', $device, $crest_oid, "outletCurrentCrestFactor.{$outlet_index}", 'eaton-epdu-mib', $outlet_descr, 1, $crest_value);
    }
}
//print_r($outlets);
/// EOF
                break;
            case 'value':
                if (in_array($unit, array('.C', 'degree C'))) {
                    $t = "temperature";
                } elseif ($unit == "V") {
                    $t = "voltage";
                } elseif ($unit == "%") {
                    if (stristr($name, "RPM")) {
                        $t = "load";
                    }
                } elseif ($unit == "l/min") {
                    $t = "waterflow";
                } elseif ($unit == "W") {
                    $t = "power";
                } elseif ($unit == "A") {
                    $t = "current";
                }
                break;
            default:
                continue;
        }
        if ($t) {
            if ($t == "status") {
                discover_status($device, $oid, $index, "rittal-cmc-iii-state", $name, $value, array('entPhysicalClass' => 'other'));
            } else {
                $limits = array();
                discover_sensor($valid['sensor'], $t, $device, $oid, "cmcIIIVarTable.{$deviceIndex}.{$sensorIndex}", "Rittal-CMC-III", $name, $scale, $value, $limits);
            }
        }
    }
}
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
echo " HH3C-STACK-MIB ";
$stack_members = snmpwalk_cache_multi_oid($device, 'hh3cStackBoardConfigTable', array(), 'HH3C-STACK-MIB', mib_dirs('hh3c'));
foreach ($stack_members as $index => $entry) {
    //HH3C-STACK-MIB::hh3cStackBoardRole.112 = INTEGER: slave(1)
    //HH3C-STACK-MIB::hh3cStackBoardBelongtoMember.112 = INTEGER: 1
    $value = $entry['hh3cStackBoardRole'];
    $oid = ".1.3.6.1.4.1.25506.2.91.3.1.1.{$index}";
    $descr = "Board " . $entry['hh3cStackBoardBelongtoMember'];
    discover_status($device, $oid, "hh3cStackBoardConfigTable." . $index, "hh3c-stack-board-status", $descr, $value, array('entPhysicalIndex' => $index, 'entPhysicalClass' => 'module'));
}
// EOF
                case 'lock':
                case 'access':
                case 'detACfirstAlarm':
                case 'detACmainAlarm':
                case 'detACfault':
                    $t = 'status';
                    break;
                default:
                    continue;
            }
            $name = $unit_name . ' ' . $name;
            $limits = array();
            if ($high != 0) {
                $limits['limit_high'] = $high;
            }
            if ($low != 0) {
                $limits['limit_low'] = $low;
            }
            if ($warn != 0) {
                $limits['limit_warn_high'] = $warn;
            }
            if ($t == 'status') {
                $oid = $table['statusOID'] . $index;
                discover_status($device, $oid, $index, "rittal-cmc-tc-state", $name, $status, array('entPhysicalClass' => 'status'));
            } else {
                discover_sensor($valid['sensor'], $t, $device, $oid, "{$tablename}.{$index}", "Rittal-CMC-TC", $name, $scale, $value, $limits);
            }
        }
    }
}
// EOF
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $sensor_descr, $scale = 1, $current = NULL, $options = array(), $poller_type = 'snmp')
{
    global $config;
    // If this is actually a status indicator, pass it off to discover_status() then return.
    if ($class == 'state' || $class == 'status') {
        print_debug("Redirect call to discover_status().");
        $return = discover_status($device, $oid, $index, $type, $sensor_descr, $current, $options, $poller_type);
        return $return;
    }
    // Init main
    $param_main = array('oid' => 'sensor_oid', 'sensor_descr' => 'sensor_descr', 'scale' => 'sensor_multiplier');
    // Init numeric values
    if (!is_numeric($scale) || $scale == 0) {
        $scale = 1;
    }
    // Skip discovery sensor if value not numeric or null (default)
    if ($current !== NULL) {
        // Some retarded devices report data with spaces and commas
        // STRING: "  20,4"
        $current = snmp_fix_numeric($current);
    }
    if (is_numeric($current)) {
        $f2c = FALSE;
        if ($class == 'temperature') {
            // This is weird hardcode for convert Fahrenheit to Celsius
            foreach (array(1, 0.1) as $scale_f2c) {
                if (float_cmp($scale, $scale_f2c * 5 / 9) === 0) {
                    //$scale = $scale_tmp;
                    $f2c = TRUE;
                    break;
                }
            }
        }
        if ($f2c) {
            $current = f2c($current * $scale_f2c);
            print_debug('TEMPERATURE sensor: Fahrenheit -> Celsius');
        } else {
            $current *= $scale;
        }
    } else {
        if ($current !== NULL) {
            print_debug("Sensor skipped by not numeric value: {$current}, {$sensor_descr} ");
            return FALSE;
        }
    }
    $param_limits = array('limit_high' => 'sensor_limit', 'limit_high_warn' => 'sensor_limit_warn', 'limit_low' => 'sensor_limit_low', 'limit_low_warn' => 'sensor_limit_low_warn');
    foreach ($param_limits as $key => $column) {
        ${$key} = is_numeric($options[$key]) ? $options[$key] : NULL;
    }
    // Init optional
    $param_opt = array('entPhysicalIndex', 'entPhysicalClass', 'entPhysicalIndex_measured', 'measured_class', 'measured_entity');
    foreach ($param_opt as $key) {
        ${$key} = $options[$key] ? $options[$key] : NULL;
    }
    print_debug("发现传感器: {$class}, " . $device['hostname'] . ", {$oid}, {$index}, {$type}, {$sensor_descr}, SCALE: {$scale}, LIMITS: ({$limit_low}, {$limit_low_warn}, {$limit_high_warn}, {$limit_high}), CURRENT: {$current}, {$poller_type}, {$entPhysicalIndex}, {$entPhysicalClass}");
    // Check sensor ignore filters
    foreach ($config['ignore_sensor'] as $bi) {
        if (strcasecmp($bi, $sensor_descr) == 0) {
            print_debug("Skipped by equals: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_string'] as $bi) {
        if (stripos($sensor_descr, $bi) !== FALSE) {
            print_debug("Skipped by strpos: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_regexp'] as $bi) {
        if (preg_match($bi, $sensor_descr) > 0) {
            print_debug("Skipped by regexp: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    if (!is_null($limit_low_warn) && !is_null($limit_high_warn) && $limit_low_warn > $limit_high_warn) {
        // Fix high/low thresholds (i.e. on negative numbers)
        list($limit_high_warn, $limit_low_warn) = array($limit_low_warn, $limit_high_warn);
    }
    if (dbFetchCell('SELECT COUNT(`sensor_id`) FROM `sensors`
                   WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?', array($poller_type, $class, $device['device_id'], $type, $index)) == '0') {
        if (!$limit_high) {
            $limit_high = sensor_limit_high($class, $current);
        }
        if (!$limit_low) {
            $limit_low = sensor_limit_low($class, $current);
        }
        if (!is_null($limit_low) && !is_null($limit_high) && $limit_low > $limit_high) {
            // Fix high/low thresholds (i.e. on negative numbers)
            list($limit_high, $limit_low) = array($limit_low, $limit_high);
            print_debug("High/low limits swapped.");
        }
        $sensor_insert = array('poller_type' => $poller_type, 'sensor_class' => $class, 'device_id' => $device['device_id'], 'sensor_index' => $index, 'sensor_type' => $type);
        foreach ($param_main as $key => $column) {
            $sensor_insert[$column] = ${$key};
        }
        foreach ($param_limits as $key => $column) {
            // Convert strings/numbers to (float) or to array('NULL')
            ${$key} = ${$key} === NULL ? array('NULL') : (double) ${$key};
            $sensor_insert[$column] = ${$key};
        }
        foreach ($param_opt as $key) {
            if (is_null(${$key})) {
                ${$key} = array('NULL');
            }
            $sensor_insert[$key] = ${$key};
        }
        $sensor_id = dbInsert($sensor_insert, 'sensors');
        $state_insert = array('sensor_id' => $sensor_id, 'sensor_value' => $current, 'sensor_polled' => 'NOW()');
        dbInsert($state_insert, 'sensors-state');
        print_debug("( {$sensor_id} inserted )");
        echo "+";
        if ($poller_type != 'ipmi') {
            // Suppress events for IPMI, see: http://jira.observium.org/browse/OBSERVIUM-959
            log_event("传感器已添加: {$class} {$type} {$index} {$sensor_descr}", $device, 'sensor', $sensor_id);
        }
    } else {
        $sensor_entry = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?", array($class, $device['device_id'], $type, $index));
        // Limits
        if (!$sensor_entry['sensor_custom_limit']) {
            if (!is_numeric($limit_high) && !is_numeric($limit_low)) {
                if ($sensor_entry['sensor_limit'] !== '') {
                    // Calculate a reasonable limit
                    $limit_high = sensor_limit_high($class, $current);
                } else {
                    // Use existing limit. (this is wrong! --mike)
                    $limit_high = $sensor_entry['sensor_limit'];
                }
                if ($sensor_entry['sensor_limit_low'] !== '') {
                    // Calculate a reasonable limit
                    $limit_low = sensor_limit_low($class, $current);
                } else {
                    // Use existing limit. (this is wrong! --mike)
                    $limit_low = $sensor_entry['sensor_limit_low'];
                }
            }
            // Fix high/low thresholds (i.e. on negative numbers)
            if (!is_null($limit_low) && !is_null($limit_high) && $limit_low > $limit_high) {
                list($limit_high, $limit_low) = array($limit_low, $limit_high);
                print_debug("High/low limits swapped.");
            }
            // Update limits
            $update = array();
            $update_msg = array();
            $debug_msg = 'Current sensor value: "' . $current . '", scale: "' . $scale . '"' . PHP_EOL;
            foreach ($param_limits as $key => $column) {
                // $key - param name, $$key - param value, $column - column name in DB for $key
                $debug_msg .= '  ' . $key . ': "' . $sensor_entry[$column] . '" -> "' . ${$key} . '"' . PHP_EOL;
                //convert strings/numbers to identical type (float) or to array('NULL') for correct comparison
                ${$key} = ${$key} === NULL ? array('NULL') : (double) ${$key};
                $sensor_entry[$column] = $sensor_entry[$column] === NULL ? array('NULL') : (double) $sensor_entry[$column];
                if (float_cmp(${$key}, $sensor_entry[$column], 0.1) !== 0) {
                    $update[$column] = ${$key};
                    $update_msg[] = $key . ' -> "' . (is_array(${$key}) ? 'NULL' : ${$key}) . '"';
                }
            }
            if (count($update)) {
                echo "L";
                print_debug($debug_msg);
                log_event('传感器已更新(限制): ' . implode(', ', $update_msg), $device, 'sensor', $sensor_entry['sensor_id']);
                $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id']));
            }
        }
        $update = array();
        foreach ($param_main as $key => $column) {
            if (float_cmp(${$key}, $sensor_entry[$column]) !== 0) {
                $update[$column] = ${$key};
            }
        }
        foreach ($param_opt as $key) {
            if (${$key} != $sensor_entry[$key]) {
                $update[$key] = ${$key};
            }
        }
        if (count($update)) {
            $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id']));
            echo "U";
            log_event("传感器已更新: {$class} {$type} {$index} {$sensor_descr}", $device, 'sensor', $sensor_entry['sensor_id']);
        } else {
            echo ".";
        }
    }
    $valid[$class][$type][$index] = 1;
}
Example #11
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$atto_fc_ports = snmpwalk_cache_oid($device, 'fcPortPortNumber', array(), 'ATTO6500N-MIB');
foreach ($atto_fc_ports as $port) {
    $index = $port['fcPortPortNumber'];
    $sensorName = "FiberChannel Port.{$index}";
    $oid = ".1.3.6.1.4.1.4547.2.3.3.1.1.3.{$index}";
    // FIXME why value NULL? Just use the entry from $port['whatevertheoidis'] ?
    discover_status($device, $index, "fcPortOperationalState.{$index}", 'atto6500n-mib-fcPort', $sensorName, NULL, array('entPhysicalClass' => 'port'));
}
$atto_sas_ports = snmpwalk_cache_oid($device, 'sasPortPortNumber', array(), 'ATTO6500N-MIB');
foreach ($atto_sas_ports as $port) {
    $index = $port['sasPortPortNumber'];
    $sensorName = "SAS Port {$index}";
    $oid = ".1.3.6.1.4.1.4547.2.3.3.3.1.2.{$index}";
    // FIXME same as above
    discover_status($device, $index, "sasPortOperationalState.{$index}", 'atto6500n-mib-sasPort', $sensorName, NULL, array('entPhysicalClass' => 'port'));
}
unset($atto_fc_ports, $atto_sas_ports);
// EOF
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateCoolingCapacity.0 = Gauge32: 81 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateHeatingCapacity.0 = Gauge32: 0 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateOperatingReason.0 = INTEGER: none(1)
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateOperatingMode.0 = INTEGER: auto(1)
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateFanCapacity.0 = Gauge32: 60 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateFreeCoolingCapacity.0 = Gauge32: 0 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateDehumidifyingCapacity.0 = Gauge32: 81 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateHumidifyingCapacity.0 = Gauge32: 0 percent
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateFreeCooling.0 = INTEGER: off(2)
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateElectricHeater.0 = INTEGER: off(2)
//LIEBERT-GP-ENVIRONMENTAL-MIB::lgpEnvStateHotWater.0 = INTEGER: off(2)
$lgpEnvState = snmpwalk_cache_oid($device, 'lgpEnvState', array(), 'LIEBERT-GP-ENVIRONMENTAL-MIB');
$states = array('lgpEnvStateSystem' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.1.0'), 'lgpEnvStateCooling' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.2.0'), 'lgpEnvStateHumidifying' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.4.0'), 'lgpEnvStateDehumidifying' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.5.0'), 'lgpEnvStateFan' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.7.0'), 'lgpEnvStateFreeCooling' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.20.0'), 'lgpEnvStateElectricHeater' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.21.0'), 'lgpEnvStateHotWater' => array('type' => 'state', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.22.0'), 'lgpEnvStateCoolingCapacity' => array('type' => 'capacity', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.9.0'), 'lgpEnvStateHeatingCapacity' => array('type' => 'capacity', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.10.0'), 'lgpEnvStateFanCapacity' => array('type' => 'capacity', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.16.0'), 'lgpEnvStateFreeCoolingCapacity' => array('type' => 'capacity', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.17.0'), 'lgpEnvStateDehumidifyingCapacity' => array('type' => 'capacity', 'oid' => '.1.3.6.1.4.1.476.1.42.3.4.3.18.0'));
foreach ($lgpEnvState[0] as $name => $value) {
    $descr = str_replace('lgpEnvState', '', $name);
    $descr = trim(preg_replace('/([A-Z][a-z]+\\d*)/', '$1 ', $descr));
    // turn "EnvStateSystem" into "Env State System"
    if (isset($states[$name])) {
        $oid = $states[$name]['oid'];
        switch ($states[$name]['type']) {
            case 'capacity':
                // Capacity
                discover_sensor($valid['sensor'], 'capacity', $device, $oid, "{$name}.0", 'liebert', $descr, 1, $value);
                break;
            default:
                // Statuses
                discover_status($device, $oid, "{$name}.0", 'liebert-state', $descr, $value);
        }
    }
}
// EOF
 if (isset($entry['upsmgBatteryRemainingTime'])) {
     $descr = "Battery Runtime Remaining";
     $oid = ".1.3.6.1.4.1.705.1.5.1.{$index}";
     $limits = array('limit_low' => snmp_get($device, "upsmgConfigLowBatteryTime.0", "-Oqv", "MG-SNMP-UPS-MIB"));
     $value = $entry['upsmgBatteryRemainingTime'];
     $scale = 1 / 60;
     // FIXME: Use this as limit?
     // MG-SNMP-UPS-MIB::upsmgConfigLowBatteryTime.0 = 180
     discover_sensor($valid['sensor'], 'runtime', $device, $oid, "upsmgBatteryRemainingTime.{$index}", 'mge', $descr, $scale, $value);
 }
 // MG-SNMP-UPS-MIB::upsmgBatteryFaultBattery.0 = no
 if (isset($entry['upsmgBatteryFaultBattery'])) {
     $descr = "Battery Fault";
     $oid = ".1.3.6.1.4.1.705.1.5.9.{$index}";
     $value = $entry['upsmgBatteryFaultBattery'];
     discover_status($device, $oid, "upsmgBatteryFaultBattery.{$index}", 'mge-status-state', $descr, $value, array('entPhysicalClass' => 'battery'));
 }
 // MG-SNMP-UPS-MIB::upsmgBatteryChargerFault.0 = no
 if (isset($entry['upsmgBatteryChargerFault'])) {
     $descr = "Charger Fault";
     $oid = ".1.3.6.1.4.1.705.1.5.15.{$index}";
     $value = $entry['upsmgBatteryChargerFault'];
     discover_sensor($valid['sensor'], 'state', $device, $oid, "upsmgBatteryChargerFault.{$index}", 'mge-status-state', $descr, NULL, $value, array('entPhysicalClass' => 'battery'));
 }
 // MG-SNMP-UPS-MIB::upsmgBatteryLowBattery.0 = no
 // According to MGE, LowCondition is the correct indicator, so we ignore LowBattery.
 // MG-SNMP-UPS-MIB::upsmgBatteryLowCondition.0 = no
 if (isset($entry['upsmgBatteryLowCondition'])) {
     $descr = "Battery Low";
     $oid = ".1.3.6.1.4.1.705.1.5.16.{$index}";
     $value = $entry['upsmgBatteryLowCondition'];
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2015 Adam Armstrong
 *
 */
echo " NS-ROOT-MIB ";
// Collect HAMode & HAState
$sysHighAvailabilityMode = snmp_get($device, 'sysHighAvailabilityMode.0', '-Ovq', 'NS-ROOT-MIB', mib_dirs('citrix'));
$haCurState = snmp_get($device, 'haCurState.0', '-Ovq', 'NS-ROOT-MIB', mib_dirs('citrix'));
if ($sysHighAvailabilityMode !== '' && $haCurState !== '') {
    $descr = 'High Availability Status';
    // $oid   = '.1.3.6.1.4.1.5951.4.1.1.6.0'; $oid   = '1.3.6.1.4.1.5951.4.1.1.23.24.0';
    // $value = $sysHighAvailabilityMode; $value = $haCurState;
    discover_status($device, 'netscaler-ha-0', '0', 'netscaler-ha', $descr, NULL, array('entPhysicalClass' => 'other'));
}
unset($sysHighAvailabilityMode);
unset($haCurState);
// EOF
    $descr = explode(',', $huawei['sensors_names'][$index]['hwEntityBomEnDesc']);
    $value = $entry['hwEntityTemperature'];
    if ($entry['hwEntityTemperature'] > 0 && $value <= 1000) {
        $options = array('limit_high' => snmp_get($device, "hwEntityTemperatureThreshold.{$index}", '-Osqv', 'HUAWEI-ENTITY-EXTENT-MIB'));
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'huawei', $descr[0], 1, $value, $options);
    }
}
unset($options);
foreach ($huawei['fan'] as $index => $entry) {
    $oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.10.1.5.' . $index;
    $fanstateoid = '.1.3.6.1.4.1.2011.5.25.31.1.1.10.1.7.' . $index;
    $value = $entry['hwEntityFanSpeed'];
    $descr = 'Slot ' . $entry['hwEntityFanSlot'] . ' Fan ' . $entry['hwEntityFanSn'];
    if ($entry['hwEntityFanSpeed'] > 0) {
        discover_sensor($valid['sensor'], 'load', $device, $oid, $index, 'huawei', $descr, 1, $value);
        discover_status($device, $fanstateoid, $index, 'huawei-entity-ext-mib-fan-state', $descr, $entry['hwEntityFanState'], array('entPhysicalClass' => 'fan'));
    }
}
foreach ($opticalarray as $index => $entry) {
    if ($entry['entPhysicalClass'] === 'port') {
        // Port found, get mapped ifIndex
        $sensor_port = $opticalarray[$index];
        if (isset($sensor_port['0']['entAliasMappingIdentifier']) && strpos($sensor_port['0']['entAliasMappingIdentifier'], 'fIndex')) {
            list(, $ifIndex) = explode('.', $sensor_port['0']['entAliasMappingIdentifier']);
            $port = get_port_by_index_cache($device['device_id'], $ifIndex);
            $temperatureoid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.5.' . $index;
            $voltageoid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.6.' . $index;
            $biascurrentoid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.7.' . $index;
            $rxpoweroid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8.' . $index;
            $txpoweroid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9.' . $index;
            //Optical module name
    }
}
//    [rectifierStatusID] => 2
//    [rectifierStatusStatus] => normal
//    [rectifierStatusOutputCurrent] => 42
//    [rectifierStatusOutputVoltage] => 5430
//    [rectifierStatusTemp] => 32
//    [rectifierStatusType] => FLATPACK2 48/2000 HE
//    [rectifierStatusSKU] => 241115.105
//    [rectifierStatusSerialNo] => 1051711xxxx
//    [rectifierStatusRevisionLevel] => 2.1
//.1.3.6.1.4.1.12148.9.5.5.2.1.1.1 = 2
//.1.3.6.1.4.1.12148.9.5.5.2.1.2.1 = normal
//.1.3.6.1.4.1.12148.9.5.5.2.1.3.1 = 42
//.1.3.6.1.4.1.12148.9.5.5.2.1.4.1 = 5429
//.1.3.6.1.4.1.12148.9.5.5.2.1.5.1 = 32
//.1.3.6.1.4.1.12148.9.5.5.2.1.6.1 = FLATPACK2 48/2000 HE
//.1.3.6.1.4.1.12148.9.5.5.2.1.7.1 = 241115.105
//.1.3.6.1.4.1.12148.9.5.5.2.1.8.1 = 1051711xxxx
//.1.3.6.1.4.1.12148.9.5.5.2.1.9.1 = 2.1
$oids = snmpwalk_cache_oid($device, 'rectifierStatusTable', array(), 'ELTEK-DISTRIBUTED-MIB');
foreach ($oids as $index => $entry) {
    if ($entry['rectifierStatusStatus'] != 'notPresent') {
        $descr = 'Rectifier ' . $entry['rectifierStatusID'] . ' (' . $entry['rectifierStatusType'] . ')';
        discover_sensor($valid['sensor'], 'voltage', $device, '.1.3.6.1.4.1.12148.9.5.5.2.1.4.' . $index, $index, 'eltek-distributed-mib_rectifierStatusOutputVoltage', $descr, 0.01, $entry['rectifierStatusOutputVoltage']);
        discover_sensor($valid['sensor'], 'current', $device, '.1.3.6.1.4.1.12148.9.5.5.2.1.3.' . $index, $index, 'eltek-distributed-mib_rectifierStatusOutputCurrent', $descr, 1, $entry['rectifierStatusOutputCurrent']);
        discover_sensor($valid['sensor'], 'temperature', $device, '.1.3.6.1.4.1.12148.9.5.5.2.1.5.' . $index, $index, 'eltek-distributed-mib_rectifierStatusTemp', $descr, 1, $entry['rectifierStatusTemp']);
        discover_status($device, '.1.3.6.1.4.1.12148.9.5.5.2.1.2.' . $index, 'rectifierStatusStatus.' . $index, 'eltek-distributed-mib_rectifierStatusStatus', $descr, $entry['rectifierStatusStatus']);
    }
}
// EOF
    $oid_name = 'shelfBPowerStatus';
    $oid_num = '.1.3.6.1.4.1.5504.3.2.2.1.2.' . $index;
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, 'shelfPowerStatus', $descr, $value, array('entPhysicalClass' => 'powersupply'));
    // Temperature Status
    $descr = "Temperature - {$name}";
    $oid_name = 'shelfTemperatureStatus';
    $oid_num = '.1.3.6.1.4.1.5504.3.2.2.1.3.' . $index;
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, 'shelfTemperatureStatus', $descr, $value, array('entPhysicalClass' => 'temperature'));
    // Fan Status
    $descr = "Fan Tray - {$name}";
    $oid_name = 'shelfFanTrayStatus';
    $oid_num = '.1.3.6.1.4.1.5504.3.2.2.1.4.' . $index;
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, 'shelfFanTrayStatus', $descr, $value, array('entPhysicalClass' => 'fan'));
}
//ZHONE-SHELF-MONITOR-MIB::shelfFanSpeed.1.1 = INTEGER: 9000
//ZHONE-SHELF-MONITOR-MIB::shelfFanSpeed.1.2 = INTEGER: 9000
//ZHONE-SHELF-MONITOR-MIB::shelfFanSpeed.1.3 = INTEGER: 9000
//ZHONE-SHELF-MONITOR-MIB::shelfFanLocation.1.1 = STRING: back
//ZHONE-SHELF-MONITOR-MIB::shelfFanLocation.1.2 = STRING: middle
//ZHONE-SHELF-MONITOR-MIB::shelfFanLocation.1.3 = STRING: front
//ZHONE-SHELF-MONITOR-MIB::shelfFanLowSpeedThreshold.1.1 = INTEGER: 544
//ZHONE-SHELF-MONITOR-MIB::shelfFanLowSpeedThreshold.1.2 = INTEGER: 544
//ZHONE-SHELF-MONITOR-MIB::shelfFanLowSpeedThreshold.1.3 = INTEGER: 544
$oids = snmpwalk_cache_oid($device, 'shelfFanTable', array(), $mib);
//print_vars($oids);
foreach ($oids as $index => $entry) {
    list($zhoneShelfIndex, $shelfFanIndex) = explode('.', $index);
    $name = "Shelf {$zhoneShelfIndex}";
$oids['PowerSupply'] = snmpwalk_cache_oid($device, 'extremePowerSupplyTable', array(), $mib);
//print_vars($oids);
foreach ($oids['PowerSupply'] as $index => &$entry) {
    if (empty($entity_array[$entry['extremePowerSupplyEntPhysicalIndex']]['entPhysicalDescr'])) {
        $name = "Power Supply {$index}";
    } else {
        $name = $entity_array[$entry['extremePowerSupplyEntPhysicalIndex']]['entPhysicalDescr'];
    }
    $entry['name'] = $name;
    $options = array('entPhysicalIndex' => $entry['extremePowerSupplyEntPhysicalIndex']);
    // Power Status
    $descr = $name;
    $oid_name = 'extremePowerSupplyStatus';
    $oid_num = '.1.3.6.1.4.1.1916.1.1.1.27.1.2.' . $index;
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, 'extremePowerSupplyStatus', $descr, $value, array_merge($options, array('entPhysicalClass' => 'powersupply')));
    $oid_name = 'extremePowerSupplyInputPowerUsage';
    $value = $entry[$oid_name];
    if ($value > 0) {
        $oid_num = ".1.3.6.1.4.1.1916.1.1.1.27.1.9.{$index}";
        $type = $mib . '-' . $oid_name;
        discover_sensor($valid['sensor'], 'power', $device, $oid_num, $index, $type, $descr, si_to_scale($entry['extremePowerSupplyInputPowerUsageUnitMultiplier']), $value, $options);
    }
}
//EXTREME-SYSTEM-MIB::extremePowerSupplyIndex.1.1 = INTEGER: 1
//EXTREME-SYSTEM-MIB::extremePowerSupplyIndex.2.1 = INTEGER: 2
//EXTREME-SYSTEM-MIB::extremePowerSupplyOutputSensorIdx.1.1 = INTEGER: 1
//EXTREME-SYSTEM-MIB::extremePowerSupplyOutputSensorIdx.2.1 = INTEGER: 1
//EXTREME-SYSTEM-MIB::extremePowerSupplyOutputVoltage.1.1 = INTEGER: 12060
//EXTREME-SYSTEM-MIB::extremePowerSupplyOutputVoltage.2.1 = INTEGER: 0
//EXTREME-SYSTEM-MIB::extremePowerSupplyOutputCurrent.1.1 = INTEGER: 4900
    list($type, $unit, $tray) = explode('.', $index);
    if (!isset($units[$unit])) {
        // Skip inactive Units
        continue;
    }
    $descr = $units[$unit];
    $oid_name = 'dellNetFanTrayOperStatus';
    $oid_num = ".1.3.6.1.4.1.6027.3.26.1.4.7.1.4.{$index}";
    $type = 'dellNetOperStatus';
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, $type, $descr . ' Fan ' . $tray, $value, array('entPhysicalClass' => 'fan'));
    $oid_name = 'dellNetPowerSupplyOperStatus';
    $oid_num = ".1.3.6.1.4.1.6027.3.26.1.4.6.1.4.{$index}";
    $type = 'dellNetOperStatus';
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, $type, $descr . ' PowerSupply ' . $tray, $value, array('entPhysicalClass' => 'powersupply'));
    $oid_name = 'dellNetPowerSupplyUsage';
    $oid_num = ".1.3.6.1.4.1.6027.3.26.1.4.6.1.10.{$index}";
    $type = $mib . '-' . $oid_name;
    $scale = 1;
    $value = $entry[$oid_name];
    if ($value > 0) {
        discover_sensor($valid['sensor'], 'power', $device, $oid_num, $index, $type, $descr . ' PowerSupply ' . $tray, $scale, $value);
    }
}
// DOM sensors
//DELL-NETWORKING-CHASSIS-MIB::dellNetSysIfXfpRecvPower.2097156 = INTEGER: 655.35 dB
//DELL-NETWORKING-CHASSIS-MIB::dellNetSysIfXfpRecvPower.2097284 = INTEGER: -8.50 dB
//DELL-NETWORKING-CHASSIS-MIB::dellNetSysIfXfpRecvPower.2097412 = INTEGER: .00 dB
//DELL-NETWORKING-CHASSIS-MIB::dellNetSysIfXfpRecvTemp.2097156 = INTEGER: 65535
//DELL-NETWORKING-CHASSIS-MIB::dellNetSysIfXfpRecvTemp.2097284 = INTEGER: 32
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$status_array = snmpwalk_cache_oid($device, 'cfwHardwareStatusTable', array(), 'CISCO-FIREWALL-MIB');
if ($status_array['netInterface']['cfwHardwareStatusValue'] != 'down') {
    // device is configured for failover
    $descr = 'Failover ' . strtolower($status_array['primaryUnit']['cfwHardwareInformation']);
    $oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.6';
    $value = $status_array['primaryUnit']['cfwHardwareStatusValue'];
    discover_status($device, $oid, 'cfwHardwareStatusValue.primaryUnit', 'cisco-firewall-hardware-primary-state', $descr, $value, array('entPhysicalClass' => 'other'));
    $descr = 'Failover ' . strtolower($status_array['secondaryUnit']['cfwHardwareInformation']);
    $oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.7';
    $value = $status_array['secondaryUnit']['cfwHardwareStatusValue'];
    discover_status($device, $oid, 'cfwHardwareStatusValue.secondaryUnit', 'cisco-firewall-hardware-secondary-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
// EOF
    $value = $entry['npRelHumSensorValueT'];
    if ($value) {
        $oid = '.1.3.6.1.4.1.25728.8400.2.4.' . $index;
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, "npRelHumSensorValueT.{$index}", 'dskf-mib', $descr, 1, $value);
    }
    // Humidity
    $descr = 'Humidity ' . $index;
    $value = $entry['npRelHumSensorValueH'];
    if ($value) {
        $oid = '.1.3.6.1.4.1.25728.8400.2.2.' . $index;
        discover_sensor($valid['sensor'], 'humidity', $device, $oid, "npRelHumSensorValueH.{$index}", 'dskf-mib', $descr, 1, $value);
    }
    $value = $entry['npRelHumSensorStatus'];
    if ($value) {
        $oid = '.1.3.6.1.4.1.25728.8400.2.3.' . $index;
        discover_status($device, $oid, 'npRelHumSensorStatus.' . $index, 'dskf-mib-hum-state', $descr, $value, array('entPhysicalClass' => 'humidity'));
    }
}
$cache_discovery['DKSF-60-4-X-X-X']['thermo'] = snmpwalk_cache_multi_oid($device, 'npThermoTable', array(), 'DKSF-60-4-X-X-X');
foreach ($cache_discovery['DKSF-60-4-X-X-X']['thermo'] as $index => $entry) {
    // Temperature
    $descr = $entry['npThermoMemo'] ? $entry['npThermoMemo'] : 'Thermo ' . $index;
    $value = $entry['npThermoValue'];
    if ($value && $entry['npThermoStatus'] != 'failed') {
        $oid = '.1.3.6.1.4.1.25728.8800.1.1.2.' . $index;
        $limits = array('limit_high' => $entry['npThermoHigh'], 'limit_low' => $entry['npThermoLow']);
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, "npThermoValue.{$index}", 'dskf-mib', $descr, 1, $value, $limits);
    }
}
$cache_discovery['DKSF-60-4-X-X-X']['io'] = snmpwalk_cache_multi_oid($device, 'npIoTable', array(), 'DKSF-60-4-X-X-X');
foreach ($cache_discovery['DKSF-60-4-X-X-X']['io'] as $index => $entry) {
Example #22
0
## Bypass Frequency
$oid = ".1.3.6.1.2.1.33.1.5.1.0";
# UPS-MIB:upsBypassFrequency.0
$value = snmp_get($device, $oid, "-Oqv");
if (is_numeric($value)) {
    discover_sensor($valid['sensor'], 'frequency', $device, $oid, "upsBypassFrequency", 'ups-mib', "Bypass", $scale, $value);
}
//UPS-MIB::upsTestId.0 = OID: UPS-MIB::upsTestNoTestsInitiated
//UPS-MIB::upsTestSpinLock.0 = INTEGER: 1
//UPS-MIB::upsTestResultsSummary.0 = INTEGER: noTestsInitiated(6)
//UPS-MIB::upsTestResultsDetail.0 = STRING: No test initiated.
//UPS-MIB::upsTestStartTime.0 = Timeticks: (0) 0:00:00.00
//UPS-MIB::upsTestElapsedTime.0 = INTEGER: 0
$ups_array = snmpwalk_cache_multi_oid($device, "upsTest", array(), "UPS-MIB");
if (isset($ups_array[0]['upsTestResultsSummary']) && $ups_array[0]['upsTestResultsSummary'] != 'noTestsInitiated') {
    $descr = "Diagnostics Results";
    $oid = ".1.3.6.1.2.1.33.1.7.3.0";
    $value = $ups_array[0]['upsTestResultsSummary'];
    $test_starttime = timeticks_to_sec($ups_array[0]['upsTestStartTime']);
    if ($test_starttime) {
        $test_sysUpime = timeticks_to_sec(snmp_get($device, "sysUpTime.0", "-OQUs", "SNMPv2-MIB"));
        if ($test_sysUpime) {
            $test_starttime = time() + $test_starttime - $test_sysUpime;
            // Unixtime of start test
            $descr .= ' (last ' . format_unixtime($test_starttime) . ')';
        }
    }
    discover_status($device, $oid, "upsTestResultsSummary.0", 'ups-mib-test-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
unset($ups_array);
// EOF
Example #23
0
    }
    $chassis = $entry['cpqRackCommonEnclosureTempChassis'];
    $name = $entry['cpqRackCommonEnclosureTempLocation'] ? $entry['cpqRackCommonEnclosureTempLocation'] : 'Sensor ' . $entry['cpqRackCommonEnclosureTempSensorIndex'];
    $descr = "{$name} - Rack {$rack}, Chassis {$chassis}";
    $oid_name = 'cpqRackCommonEnclosureTempCurrent';
    $oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.6.' . $index;
    $type = 'CPQRACK-MIB' . '-' . $oid_name;
    $value = $entry[$oid_name];
    $limits = array('limit_high' => $entry['cpqRackCommonEnclosureTempThreshold']);
    discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, 1, $value, $limits);
    // State
    $oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.8.' . $index;
    $value = $entry['cpqRackCommonEnclosureTempCondition'];
    //discover_status($device, $oid, 'cpqRackCommonEnclosureTempCondition.'.$index, 'cpqRackCommonEnclosureCondition', $descr, $value, array('entPhysicalClass' => 'chassis'));
}
// Fans
$oids = snmpwalk_cache_oid($device, 'cpqRackCommonEnclosureFanTable', array(), 'CPQRACK-MIB');
//print_vars($oids);
foreach ($oids as $index => $entry) {
    $rack = $entry['cpqRackCommonEnclosureFanRack'];
    if ($cpqrack[$rack]['cpqRackCommonEnclosureHasFans'] == 'false' || $entry['cpqRackCommonEnclosureFanPresent'] != 'present') {
        continue;
    }
    $chassis = $entry['cpqRackCommonEnclosureFanChassis'];
    $name = $entry['cpqRackCommonEnclosureFanLocation'] ? $entry['cpqRackCommonEnclosureFanLocation'] : $entry['cpqRackCommonEnclosureFanIndex'];
    $descr = "Fan {$name} - Rack {$rack}, Chassis {$chassis}";
    $oid = '.1.3.6.1.4.1.232.22.2.3.1.3.1.11.' . $index;
    $value = $entry['cpqRackCommonEnclosureFanCondition'];
    discover_status($device, $oid, 'cpqRackCommonEnclosureFanCondition.' . $index, 'cpqRackCommonEnclosureCondition', $descr, $value, array('entPhysicalClass' => 'fan'));
}
// EOF
Example #24
0
//CPQPOWER-MIB::breakerPercentLoad.2.6 = INTEGER: 0
//CPQPOWER-MIB::breakerStatus.1.1 = INTEGER: 0
//CPQPOWER-MIB::breakerStatus.2.6 = INTEGER: 0
$hppdu_breaker_array = snmpwalk_cache_multi_oid($device, 'pduOutputBreakerTable', array(), 'CPQPOWER-MIB');
foreach ($hppdu_breaker_array as $index => $entry) {
    if ($entry['breakerVoltage'] <= 0) {
        continue;
    }
    list($breaker_output, $breaker_unit) = explode('.', $index, 2);
    $breaker_descr = 'Breaker ' . $hppdu_array[$breaker_output]['pduName'] . ' Unit ' . $breaker_unit;
    // Find powerlimit by measure the reported output power devivded by the reported load of the PDU
    //$breaker_maxload = 100 * ($entry['breakerCurrent'] / $entry['breakerPercentLoad']);
    $breaker_maxload = $entry['breakerCurrent'] / $entry['breakerPercentLoad'];
    // breakerCurrent already scaled by 100
    $breaker_warnload = 0.8 * $breaker_maxload;
    $limits = array('limit_high' => round($breaker_maxload, 2), 'limit_high_warn' => round($breaker_warnload, 2));
    $descr = $breaker_descr . ' Current';
    $oid = ".1.3.6.1.4.1.232.165.2.3.2.1.3.{$index}";
    discover_sensor($valid['sensor'], 'current', $device, $oid, $index, 'CPQPOWER-MIB', $descr, 0.01, $entry['breakerCurrent'], $limits);
    $descr = $breaker_descr . ' Voltage';
    $oid = ".1.3.6.1.4.1.232.165.2.3.2.1.2.{$index}";
    discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, 'CPQPOWER-MIB', $descr, 1, $entry['breakerVoltage']);
    $descr = $breaker_descr . ' Load';
    $oid = ".1.3.6.1.4.1.232.165.2.3.2.1.4.{$index}";
    discover_sensor($valid['sensor'], 'capacity', $device, $oid, $index, 'CPQPOWER-MIB', $descr, 1, $entry['breakerPercentLoad']);
    $descr = $breaker_descr . ' Status';
    $oid = ".1.3.6.1.4.1.232.165.2.3.2.1.5.{$index}";
    discover_status($device, $oid, $index, 'cpqpower-pdu-breaker-status', $descr, $entry['breakerStatus'], array('entPhysicalClass' => 'power'));
}
unset($hpups_array, $hppdu_breaker_array);
// EOF
Example #25
0
/**
 * Discover a new sensor on a device
 *
 * This function adds a status sensor to a device, if it does not already exist.
 * Data on the sensor is updated if it has changed, and an event is logged with regards to the changes.
 *
 * Status sensors are handed off to discover_status().
 * Current sensor values are rectified in case they are broken (added spaces, etc).
 *
 * @param array &$valid        Array of currently valid sensors for poller type (used to delete later)
 * @param string $class        Class of sensor (voltage, temperature, etc.)
 * @param array $device        Device array sensor is being discovered on
 * @param string $oid          SNMP OID of sensor
 * @param string $index        SNMP index of sensor
 * @param string $type         Type of sensor
 * @param string $sensor_descr Description of sensor
 * @param int $scale           Scale of sensor (0.1 for 1:10 scale, 10 for 10:1 scale, etc)
 * @param string $value        Current sensor value
 * @param array $options       Options (sensor_unit, limit_auto, limit*)
 * @param string $poller_type  Type of poller being used (SNMP, Agent, etc) - Used to check valid sensors per poller type
 * @return bool
*/
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $sensor_descr, $scale = 1, $value = NULL, $options = array(), $poller_type = 'snmp')
{
    global $config;
    // If this is actually a status indicator, pass it off to discover_status() then return.
    if ($class == 'state' || $class == 'status') {
        print_debug("Redirecting call to discover_status().");
        return discover_status($device, $oid, $index, $type, $sensor_descr, $value, $options, $poller_type);
    }
    // Init main
    $param_main = array('oid' => 'sensor_oid', 'sensor_descr' => 'sensor_descr', 'scale' => 'sensor_multiplier');
    // Init numeric values
    if (!is_numeric($scale) || $scale == 0) {
        $scale = 1;
    }
    // Skip discovery sensor if value not numeric or null (default)
    if (strlen($value)) {
        // Some retarded devices report data with spaces and commas
        // STRING: "  20,4"
        $value = snmp_fix_numeric($value);
    }
    if (is_numeric($value)) {
        $value *= $scale;
        // Scale before unit conversion
        $value = value_to_si($value, $options['sensor_unit'], $class);
        // Convert if not SI unit
    } else {
        print_debug("Sensor skipped by not numeric value: '{$value}', '{$sensor_descr}'");
        if (strlen($value)) {
            print_debug("Perhaps this is named sensor, use discover_status() instead.");
        }
        return FALSE;
    }
    $param_limits = array('limit_high' => 'sensor_limit', 'limit_high_warn' => 'sensor_limit_warn', 'limit_low' => 'sensor_limit_low', 'limit_low_warn' => 'sensor_limit_low_warn');
    foreach ($param_limits as $key => $column) {
        // Set limits vars and unit convert if required
        ${$key} = is_numeric($options[$key]) ? value_to_si($options[$key], $options['sensor_unit'], $class) : NULL;
    }
    // Auto calculate high/low limits if not passed
    $limit_auto = !isset($options['limit_auto']) || (bool) $options['limit_auto'];
    // Init optional
    $param_opt = array('entPhysicalIndex', 'entPhysicalClass', 'entPhysicalIndex_measured', 'measured_class', 'measured_entity', 'sensor_unit');
    foreach ($param_opt as $key) {
        ${$key} = $options[$key] ? $options[$key] : NULL;
    }
    print_debug("Discover sensor: {$class}, " . $device['hostname'] . ", {$oid}, {$index}, {$type}, {$sensor_descr}, SCALE: {$scale}, LIMITS: ({$limit_low}, {$limit_low_warn}, {$limit_high_warn}, {$limit_high}), CURRENT: {$value}, {$poller_type}, {$entPhysicalIndex}, {$entPhysicalClass}");
    // Check sensor ignore filters
    foreach ($config['ignore_sensor'] as $bi) {
        if (strcasecmp($bi, $sensor_descr) == 0) {
            print_debug("Skipped by equals: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_string'] as $bi) {
        if (stripos($sensor_descr, $bi) !== FALSE) {
            print_debug("Skipped by strpos: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_regexp'] as $bi) {
        if (preg_match($bi, $sensor_descr) > 0) {
            print_debug("Skipped by regexp: {$bi}, {$sensor_descr} ");
            return FALSE;
        }
    }
    if (!is_null($limit_low_warn) && !is_null($limit_high_warn) && $limit_low_warn > $limit_high_warn) {
        // Fix high/low thresholds (i.e. on negative numbers)
        list($limit_high_warn, $limit_low_warn) = array($limit_low_warn, $limit_high_warn);
    }
    if (dbFetchCell('SELECT COUNT(`sensor_id`) FROM `sensors`
                   WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?', array($poller_type, $class, $device['device_id'], $type, $index)) == '0') {
        if (!$limit_high) {
            $limit_high = sensor_limit_high($class, $value, $limit_auto);
        }
        if (!$limit_low) {
            $limit_low = sensor_limit_low($class, $value, $limit_auto);
        }
        if (!is_null($limit_low) && !is_null($limit_high) && $limit_low > $limit_high) {
            // Fix high/low thresholds (i.e. on negative numbers)
            list($limit_high, $limit_low) = array($limit_low, $limit_high);
            print_debug("High/low limits swapped.");
        }
        $sensor_insert = array('poller_type' => $poller_type, 'sensor_class' => $class, 'device_id' => $device['device_id'], 'sensor_index' => $index, 'sensor_type' => $type);
        foreach ($param_main as $key => $column) {
            $sensor_insert[$column] = ${$key};
        }
        foreach ($param_limits as $key => $column) {
            // Convert strings/numbers to (float) or to array('NULL')
            ${$key} = ${$key} === NULL ? array('NULL') : (double) ${$key};
            $sensor_insert[$column] = ${$key};
        }
        foreach ($param_opt as $key) {
            if (is_null(${$key})) {
                ${$key} = array('NULL');
            }
            $sensor_insert[$key] = ${$key};
        }
        $sensor_id = dbInsert($sensor_insert, 'sensors');
        $state_insert = array('sensor_id' => $sensor_id, 'sensor_value' => $value, 'sensor_polled' => 'NOW()');
        dbInsert($state_insert, 'sensors-state');
        print_debug("( {$sensor_id} inserted )");
        echo '+';
        log_event("Sensor added: {$class} {$type} {$index} {$sensor_descr}", $device, 'sensor', $sensor_id);
    } else {
        $sensor_entry = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?", array($class, $device['device_id'], $type, $index));
        // Limits
        if (!$sensor_entry['sensor_custom_limit']) {
            if (!is_numeric($limit_high)) {
                if ($sensor_entry['sensor_limit'] !== '') {
                    // Calculate a reasonable limit
                    $limit_high = sensor_limit_high($class, $value, $limit_auto);
                } else {
                    // Use existing limit. (this is wrong! --mike)
                    $limit_high = $sensor_entry['sensor_limit'];
                }
            }
            if (!is_numeric($limit_low)) {
                if ($sensor_entry['sensor_limit_low'] !== '') {
                    // Calculate a reasonable limit
                    $limit_low = sensor_limit_low($class, $value, $limit_auto);
                } else {
                    // Use existing limit. (this is wrong! --mike)
                    $limit_low = $sensor_entry['sensor_limit_low'];
                }
            }
            // Fix high/low thresholds (i.e. on negative numbers)
            if (!is_null($limit_low) && !is_null($limit_high) && $limit_low > $limit_high) {
                list($limit_high, $limit_low) = array($limit_low, $limit_high);
                print_debug("High/low limits swapped.");
            }
            // Update limits
            $update = array();
            $update_msg = array();
            $debug_msg = 'Current sensor value: "' . $value . '", scale: "' . $scale . '"' . PHP_EOL;
            foreach ($param_limits as $key => $column) {
                // $key - param name, $$key - param value, $column - column name in DB for $key
                $debug_msg .= '  ' . $key . ': "' . $sensor_entry[$column] . '" -> "' . ${$key} . '"' . PHP_EOL;
                //convert strings/numbers to identical type (float) or to array('NULL') for correct comparison
                ${$key} = ${$key} === NULL ? array('NULL') : (double) ${$key};
                $sensor_entry[$column] = $sensor_entry[$column] === NULL ? array('NULL') : (double) $sensor_entry[$column];
                if (float_cmp(${$key}, $sensor_entry[$column], 0.1) !== 0) {
                    $update[$column] = ${$key};
                    $update_msg[] = $key . ' -> "' . (is_array(${$key}) ? 'NULL' : ${$key}) . '"';
                }
            }
            if (count($update)) {
                echo "L";
                print_debug($debug_msg);
                log_event('Sensor updated (limits): ' . implode(', ', $update_msg), $device, 'sensor', $sensor_entry['sensor_id']);
                $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id']));
            }
        }
        $update = array();
        foreach ($param_main as $key => $column) {
            if (float_cmp(${$key}, $sensor_entry[$column]) !== 0) {
                $update[$column] = ${$key};
            }
        }
        foreach ($param_opt as $key) {
            if (${$key} != $sensor_entry[$key]) {
                $update[$key] = ${$key};
            }
        }
        if (count($update)) {
            $updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id']));
            echo 'U';
            log_event("Sensor updated: {$class} {$type} {$index} {$sensor_descr}", $device, 'sensor', $sensor_entry['sensor_id']);
        } else {
            echo '.';
        }
    }
    $valid[$class][$type][$index] = 1;
}
}
// Fans
$cache['fnsnagent'] = array();
$stackable = 0;
// Stackable Switches
foreach (array('snChasFan2Table') as $table) {
    echo "{$table} ";
    $cache['fnsnagent'] = snmpwalk_cache_multi_oid($device, $table, $cache['fnsnagent'], 'FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
foreach ($cache['fnsnagent'] as $index => $entry) {
    $descr = "Fan {$index}";
    $oid = ".1.3.6.1.4.1.1991.1.1.1.3.2.1.4.{$index}";
    $value = $entry['snChasFan2OperStatus'];
    discover_status($device, $oid, "snChasFan2OperStatus.{$index}", 'foundry-sn-agent-oper-state', $descr, $value, array('entPhysicalClass' => 'fan'));
    $stackable = 1;
}
// Chassis and Non Stackable Switches
if ($stackable == 0) {
    $cache['fnsnagent'] = array();
    foreach (array('snChasPwrSupplyTable') as $table) {
        echo "{$table} ";
        $cache['fnsnagent'] = snmpwalk_cache_multi_oid($device, $table, $cache['fnsnagent'], 'FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
    }
    foreach ($cache['fnsnagent'] as $index => $entry) {
        $descr = "Fan {$index}";
        $oid = ".1.3.6.1.4.1.1991.1.1.1.2.1.1.3.{$index}";
        $value = $entry['snChasFanOperStatus'];
        discover_status($device, $oid, "snChasFanOperStatus.{$index}", 'foundry-sn-agent-oper-state', $descr, $value, array('entPhysicalClass' => 'fan'));
    }
}
// EOF
Example #27
0
    $options = array();
    // sensUnit: none (0), celsius (1), fahrenheit (2), kelvin (3), percent(4)
    switch ($entry['sensUnit']) {
        case 'celsius':
            $type = 'temperature';
            break;
        case 'fahrenheit':
            $type = 'temperature';
            $options['sensor_unit'] = 'F';
            break;
        case 'kelvin':
            $type = 'temperature';
            $options['sensor_unit'] = 'K';
            break;
        case 'percent':
            $type = 'humidity';
            break;
        default:
            continue 2;
            // continue foreach loop
    }
    if (is_numeric($value) && $entry['sensState'] != 'invalid') {
        discover_sensor($valid['sensor'], $type, $device, $oid, "steSensor.{$index}", 'ste', $descr, $scale, $value, $options);
    }
    $oid_name = 'sensState';
    $oid_num = ".1.3.6.1.4.1.21796.4.1.3.1.3.{$index}";
    $type = 'ste-SensorState';
    $value = $entry[$oid_name];
    discover_status($device, $oid_num, $oid_name . '.' . $index, $type, $descr, $value, array('entPhysicalClass' => 'other'));
}
// EOF
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
echo " F5-APM-MIB ";
// APM Config Sync State
// F5-BIGIP-APM-MIB::apmPmStatConfigSyncState."/Common/Sync-Group-1" = Counter64: 0
// F5-BIGIP-APM-MIB::apmPmStatConfigSyncState."/Common/Sync-Group-2" = Counter64: 0
$apmSync = snmpwalk_cache_multi_oid($device, 'apmPmStatConfigSyncState', array(), $mib, mib_dirs('f5'));
foreach ($apmSync as $profile => $sync) {
    $descr = 'APM Sync (' . $profile . ')';
    $oid = '.1.3.6.1.4.1.3375.2.6.1.8.3.1.2.\\"' . $profile . '\\"';
    $value = $sync['apmPmStatConfigSyncState'];
    discover_status($device, $oid, 'apmSync' . $profile, 'f5-apm-sync-state', $descr, $value, array('entPhysicalClass' => 'other'));
}
// EOF
    $value = $entry['scEnclFanStatus'];
    if ($value) {
        discover_status($device, $oid, 'scEnclFanStatus.' . $index, 'compellent-mib-state', $descr, $value, array('entPhysicalClass' => 'fan'));
    }
}
foreach ($cml['ctrl'] as $index => $entry) {
    $oid = '.1.3.6.1.4.1.16139.2.13.1.3.' . $index;
    $descr = 'Controller ' . $entry['scCtlrNbr'] . ' (' . $entry['scCtlrName'] . ')';
    $value = $entry['scCtlrStatus'];
    if ($value) {
        discover_status($device, $oid, 'scCtlrStatus.' . $index, 'compellent-mib-state', $descr, $value, array('entPhysicalClass' => 'other'));
    }
}
foreach ($cml['disk'] as $index => $entry) {
    $oid = '.1.3.6.1.4.1.16139.2.14.1.3.' . $index;
    $descr = 'Disk ' . $entry['scDiskNamePosition'];
    $value = $entry['scDiskStatus'];
    if ($value) {
        discover_status($device, $oid, 'scDiskStatus.' . $index, 'compellent-mib-state', $descr, $value, array('entPhysicalClass' => 'disk'));
    }
}
foreach ($cml['cache'] as $index => $entry) {
    $oid = '.1.3.6.1.4.1.16139.2.28.1.5.' . $index;
    $descr = 'Controller ' . $entry['scCacheNbr'] . ' Cache';
    $value = $entry['scCacheBatStat'];
    if ($value) {
        discover_status($device, $oid, 'scCacheBatStat.' . $index, 'compellent-mib-cache-state', $descr, $value, array('entPhysicalClass' => 'other'));
    }
}
unset($cml['temp'], $cml['fan'], $cml['ctrl'], $cml['disk'], $cml['cache'], $oid, $descr, $value);
// EOF
Example #30
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// Collect HAMode & HAState
$sysHighAvailabilityMode = snmp_get($device, 'sysHighAvailabilityMode.0', '-Ovq', 'NS-ROOT-MIB');
$haCurState = snmp_get($device, 'haCurState.0', '-Ovq', 'NS-ROOT-MIB');
if ($sysHighAvailabilityMode !== '' && $haCurState !== '') {
    $descr = 'High Availability Status';
    // $oid   = '.1.3.6.1.4.1.5951.4.1.1.6.0'; $oid   = '1.3.6.1.4.1.5951.4.1.1.23.24.0';
    // $value = $sysHighAvailabilityMode; $value = $haCurState;
    discover_status($device, 'ns-root-mib-ha-0', '0', 'ns-root-mib-ha', $descr, $haCurState, array('entPhysicalClass' => 'other'));
}
unset($sysHighAvailabilityMode);
unset($haCurState);
// EOF