Example #1
2
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Note, device attrib 'eqlgrpmemid' sets in equallogic 'os' module.
$eqlgrpmemid = get_dev_attrib($device, 'eqlgrpmemid');
if (is_numeric($eqlgrpmemid)) {
    $mib = 'EQLDISK-MIB';
    echo " {$mib} ";
    // EQLDISK-MIB::eqlDiskModelNumber.1.1049142137.1 = STRING: ST3450857SS
    // EQLDISK-MIB::eqlDiskModelNumber.1.1049142137.2 = STRING: ST3450857SS
    // EQLDISK-MIB::eqlDiskStatus.1.1049142137.1 = INTEGER: on-line(1)
    // EQLDISK-MIB::eqlDiskStatus.1.1049142137.2 = INTEGER: on-line(1)
    // EQLDISK-MIB::eqlDiskId.1.1049142137.1 = INTEGER: 0
    // EQLDISK-MIB::eqlDiskId.1.1049142137.2 = INTEGER: 1
    $cache['equallogic']['eqlDiskTable'] = snmpwalk_cache_multi_oid($device, 'eqlDiskTable', array(), $mib, mib_dirs('equallogic'));
    foreach ($cache['equallogic']['eqlDiskTable'] as $index => $entry) {
        if (strstr($index, $eqlgrpmemid)) {
            $descr = 'Disk ' . $entry['eqlDiskId'] . ': ' . trim($entry['eqlDiskModelNumber']);
            $oid = '.1.3.6.1.4.1.12740.3.1.1.1.8.' . $index;
            $value = state_string_to_numeric('eql-disk-state', $entry['eqlDiskStatus']);
            if ($value != '') {
                discover_sensor($valid['sensor'], 'state', $device, $oid, 'eqlDiskStatus.' . $index, 'eql-disk-state', $descr, NULL, $value, array('entPhysicalClass' => 'storage'));
            }
        }
    }
}
// EOF
Example #2
1
            }
            print_debug('TEMP sensor: Fahrenheit -> Celsius');
        }
        if ($entry['sensorProbeTempStatus'] != 'noStatus') {
            discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'akcp', $descr, $scale_temp, $value, $limits);
        }
    }
    if ($entry['sensorProbeHumidityStatus']) {
        # Humidity sensor
        # FIXME do we need to take note of this? [sensorProbeHumidityOffset] => 0
        $descr = $entry['sensorProbeHumidityDescription'];
        $oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.3.{$index}";
        # SPAGENT-MIB:sensorProbeHumidityPercent.$index
        $value = $entry['sensorProbeHumidityPercent'];
        $limits = array('limit_high' => $entry['sensorProbeHumidityHighCritical'], 'limit_low' => $entry['sensorProbeHumidityLowCritical'], 'limit_high_warn' => $entry['sensorProbeHumidityHighWarning'], 'limit_low_warn' => $entry['sensorProbeHumidityLowWarning']);
        if ($entry['sensorProbeHumidityStatus'] != 'noStatus') {
            discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, 'akcp', $descr, 1, $value, $limits);
        }
    }
    if ($entry['sensorProbeSwitchStatus']) {
        # Switch sensor
        $descr = $entry['sensorProbeSwitchDescription'];
        $oid = ".1.3.6.1.4.1.3854.1.2.2.1.18.1.3.{$index}";
        # SPAGENT-MIB:sensorProbeSwitchStatus.$index
        $value = state_string_to_numeric('spagent-state', $entry['sensorProbeSwitchStatus']);
        if ($entry['sensorProbeSwitchStatus'] != 'noStatus') {
            discover_sensor($valid['sensor'], 'state', $device, $oid, $index, 'spagent-state', $descr, NULL, $value, array('entPhysicalClass' => 'other'));
        }
    }
}
// EOF
 /**
  * @dataProvider providerStateStringToNumeric
  */
 public function testStateStringToNumeric($type, $value, $result)
 {
     $this->assertSame($result, state_string_to_numeric($type, $value));
 }
        }
    }
}
// Physical Disks
$oids = snmpwalk_cache_oid($device, 'cpqDaPhyDrv', array(), 'CPQIDA-MIB', mib_dirs('hp'));
foreach ($oids as $index => $entry) {
    if ($entry['cpqDaPhyDrvTemperatureThreshold'] > 0) {
        $descr = "HDD " . $entry['cpqDaPhyDrvBay'];
        $oid = ".1.3.6.1.4.1.232.3.2.5.1.1.70." . $index;
        $value = $entry['cpqDaPhyDrvCurrentTemperature'];
        $high_limit = $entry['cpqDaPhyDrvTemperatureThreshold'];
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'cpqDaPhyDrv.' . $index, 'cpqida', $descr, 1, 1, NULL, NULL, NULL, $high_limit, $value);
    }
    if (isset($entry['cpqDaPhyDrvSmartStatus'])) {
        $descr = $descr . " SMART Status";
        $oid = ".1.3.6.1.4.1.232.3.2.5.1.1.57." . $index;
        $status = state_string_to_numeric('cpqida-smart-state', $entry['cpqDaPhyDrvSmartStatus']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, 'cpqDaPhyDrv.' . $index, 'cpqida-smart-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $status);
    }
}
// Logical Disks
$oids = snmpwalk_cache_oid($device, 'cpqDaLogDrv', array(), 'CPQIDA-MIB', mib_dirs('hp'));
foreach ($oids as $index => $entry) {
    if (isset($entry['cpqDaLogDrvCondition'])) {
        $descr = "Logical Drive " . $entry['cpqDaLogDrvIndex'] . ' (' . $entry['cpqDaLogDrvOsName'] . ') Status';
        $oid = ".1.3.6.1.4.1.232.3.2.3.1.1.11." . $index;
        $status = state_string_to_numeric('cpqida-smart-state', $entry['cpqDaLogDrvCondition']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, 'cpqDaLogDrv.' . $index, 'cpqida-smart-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $status);
    }
}
// EOF
Example #5
0
        $oid = ".1.3.6.1.4.1.318.1.1.2.1.2.{$index}";
        $value = $entry['mUpsEnvironRelativeHumidity'];
        discover_sensor($valid['sensor'], 'humidity', $device, $oid, "mUpsEnvironRelativeHumidity.{$index}", 'apc', $descr, 1, $value);
    }
    if (is_numeric($entry['mUpsEnvironAmbientTemperature2'])) {
        $descr = "Probe 2 Temperature";
        $oid = ".1.3.6.1.4.1.318.1.1.2.1.3.{$index}";
        $value = $entry['mUpsEnvironAmbientTemperature2'];
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, "mUpsEnvironAmbientTemperature2.{$index}", 'apc', $descr, 1, $value);
    }
    if (is_numeric($entry['mUpsEnvironRelativeHumidity2'])) {
        $descr = "Probe 2 Humidity";
        $oid = ".1.3.6.1.4.1.318.1.1.2.1.4.{$index}";
        $value = $entry['mUpsEnvironRelativeHumidity2'];
        discover_sensor($valid['sensor'], 'humidity', $device, $oid, "mUpsEnvironRelativeHumidity2.{$index}", 'apc', $descr, 1, $value);
    }
}
$cache['apc'] = array();
foreach (array("mUpsContactTable") as $table) {
    echo "{$table} ";
    $cache['apc'] = snmpwalk_cache_multi_oid($device, $table, $cache['apc'], "PowerNet-MIB", mib_dirs('apc'));
}
foreach ($cache['apc'] as $index => $entry) {
    if ($entry['monitoringStatus'] == "enabled") {
        $descr = $entry['description'];
        $oid = ".1.3.6.1.4.1.318.1.1.2.2.2.1.5.{$index}";
        $value = state_string_to_numeric('powernet-mupscontact-state', $entry['currentStatus']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, "currentStatus.{$index}", 'powernet-mupscontact-state', $descr, NULL, $value, array('entPhysicalClass' => 'other'));
    }
}
// EOF
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Supply
echo " TRAPEZE-NETWORKS-SYSTEM-MIB ";
$sensor_state_type = "trapeze-state";
$oids = snmpwalk_cache_oid($device, 'trpzSysPowerSupplyEntry', array(), 'TRAPEZE-NETWORKS-SYSTEM-MIB', mib_dirs('trapeze'));
foreach ($oids as $index => $entry) {
    if (isset($entry['trpzSysPowerSupplyStatus'])) {
        $oid = '.1.3.6.1.4.1.14525.4.8.1.1.13.1.2.1.' . $index;
        echo $index;
        //Not numerical values, only states
        $value = state_string_to_numeric($sensor_state_type, $entry['trpzSysPowerSupplyStatus']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $sensor_state_type, $entry['trpzSysPowerSupplyDescr'], NULL, $value, array('entPhysicalClass' => 'powerSupply'));
    }
}
// EOF
        }
    }
}
unset($divisor);
// Supply
echo " Supply ";
$oids = snmpwalk_cache_oid($device, 'ciscoEnvMonSupplyStatusEntry', array(), 'CISCO-ENVMON-MIB', mib_dirs('cisco'));
foreach ($oids as $index => $entry) {
    if (isset($entry['ciscoEnvMonSupplyState'])) {
        $oid = '.1.3.6.1.4.1.9.9.13.1.5.1.3.' . $index;
        //Not numerical values, only states
        $value = state_string_to_numeric($sensor_state_type, $entry['ciscoEnvMonSupplyState']);
        if ($value <= 4) {
            discover_sensor($valid['sensor'], 'power', $device, $oid, $index, $sensor_state_type, $entry['ciscoEnvMonSupplyStatusDescr'], 1, 1, NULL, NULL, NULL, NULL, $value);
        }
    }
}
// Fans
echo " Fans ";
$oids = snmpwalk_cache_oid($device, 'ciscoEnvMonFanStatusEntry', array(), 'CISCO-ENVMON-MIB', mib_dirs('cisco'));
foreach ($oids as $index => $entry) {
    if (isset($entry['ciscoEnvMonFanState'])) {
        $oid = '.1.3.6.1.4.1.9.9.13.1.4.1.3.' . $index;
        //Not numerical values, only states
        $value = state_string_to_numeric($sensor_state_type, $entry['ciscoEnvMonFanState']);
        if ($value <= 4) {
            discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $sensor_state_type, $entry['ciscoEnvMonFanStatusDescr'], 1, 1, NULL, NULL, NULL, NULL, $value);
        }
    }
}
// EOF
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo " JUNIPER-ALARM-MIB ";
$value = state_string_to_numeric('juniper-alarm-state', snmp_get($device, "jnxYellowAlarmState.0", "-Oqv", "JUNIPER-ALARM-MIB", mib_dirs('junos')));
if (is_numeric($value) && $value > 0) {
    $descr = "Yellow Alarm";
    $oid = ".1.3.6.1.4.1.2636.3.4.2.2.1.0";
    discover_sensor($valid['sensor'], 'state', $device, $oid, "jnxYellowAlarmState.0", 'juniper-alarm-state', $descr, NULL, $value);
}
$value = state_string_to_numeric('juniper-alarm-state', snmp_get($device, "jnxRedAlarmState.0", "-Oqv", "JUNIPER-ALARM-MIB", mib_dirs('junos')));
if (is_numeric($value) && $value > 0) {
    $descr = "Red Alarm";
    $oid = ".1.3.6.1.4.1.2636.3.4.2.3.1.0";
    discover_sensor($valid['sensor'], 'state', $device, $oid, "jnxRedAlarmState.0", 'juniper-alarm-state', $descr, NULL, $value);
}
// EOF
        discover_sensor($valid['sensor'], 'state', $device, $oid, "snChasPwrSupplyOperStatus.{$index}", 'foundry-sn-agent-oper-state', $descr, NULL, $value, array('entPhysicalClass' => 'powerSupply'));
    }
}
// Fans
// 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", mib_dirs('foundry'), TRUE);
}
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 = state_string_to_numeric('foundry-sn-agent-oper-state', $entry['snChasFan2OperStatus']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "snChasFan2OperStatus.{$index}", 'foundry-sn-agent-oper-state', $descr, NULL, $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", mib_dirs('foundry'), TRUE);
    }
    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 = state_string_to_numeric('foundry-sn-agent-oper-state', $entry['snChasFanOperStatus']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, "snChasFanOperStatus.{$index}", 'foundry-sn-agent-oper-state', $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
    }
}
// EOF
Example #10
0
$oids = snmpwalk_cache_oid($device, "oaLdDevFANOperStatus", $oids, "OADWDM-MIB", mib_dirs('mrv'));
if ($debug) {
    print_vars($oids);
}
foreach ($oids as $index => $entry) {
    if ($entry['oaLdCardType'] != 'empty') {
        $descr = "Slot {$index} " . $entry['oaLdCardType'];
        $oid = ".1.3.6.1.4.1.6926.1.41.3.1.1.26.{$index}";
        $value = $entry['oaLdCardTemp'];
        if ($value != 0) {
            discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'lambdadriver', $descr, 1, $value);
        }
    }
    if ($entry['oaLdDevPSOperStatus'] != 'empty') {
        $descr = "Power Supply {$index}";
        $oid = ".1.3.6.1.4.1.6926.1.41.1.10.1.2.1.5.{$index}";
        $value = state_string_to_numeric('oadwdm-powersupply-state', $entry['oaLdDevPSOperStatus']);
        if ($value != -1) {
            discover_sensor($valid['sensor'], 'state', $device, $oid, $index, 'oadwdm-powersupply-state', $descr, NULL, $value, array('entPhysicalClass' => 'powerSupply'));
        }
    }
    if ($entry['oaLdDevFANOperStatus'] != 'empty') {
        $descr = "Fan {$index}";
        $oid = ".1.3.6.1.4.1.6926.1.41.1.10.3.2.1.5.{$index}";
        $value = state_string_to_numeric('oadwdm-fan-state', $entry['oaLdDevFANOperStatus']);
        if ($value != -1) {
            discover_sensor($valid['sensor'], 'state', $device, $oid, $index, 'oadwdm-fan-state', $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
        }
    }
}
// EOF
Example #11
0
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$mib = 'HP-ICF-CHASSIS';
echo " {$mib} ";
$type_state = 'hp-icf-chassis-state';
$sensor_array = snmpwalk_cache_oid($device, 'hpicfSensorTable', array(), $mib, mib_dirs('hp'));
foreach ($sensor_array as $index => $entry) {
    $descr = $entry['hpicfSensorDescr'];
    // Find entPhysicalClass some way
    if (stripos($descr, 'fan') !== FALSE) {
        $entPhysicalClass = 'fan';
    } else {
        if (stripos($descr, 'power') !== FALSE) {
            $entPhysicalClass = 'power';
        } else {
            if (stripos($descr, 'temperature') !== FALSE) {
                $entPhysicalClass = 'temperature';
            } else {
                $entPhysicalClass = 'other';
            }
        }
    }
    $oid = '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.' . $index;
    $value = state_string_to_numeric($type_state, $entry['hpicfSensorStatus']);
    if ($entry['hpicfSensorStatus'] != 'notPresent') {
        discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $type_state, $descr, 1, $value, array('entPhysicalClass' => $entPhysicalClass));
    }
}
unset($sensor_array, $index, $value, $descr, $type_state);
// EOF
Example #12
0
    } elseif (strpos($descr, "Volt") !== FALSE) {
        $scale = 0.001;
        $type = "voltage";
    } elseif (strpos($descr, "Vtt") !== FALSE) {
        $scale = 0.001;
        $type = "voltage";
    } elseif (preg_match('/PowerSupply\\dFailureStatus/', $descr)) {
        $physical = 'power';
        $type = "state";
    } else {
        continue;
    }
    // Skip all other
    if ($type == 'state') {
        discover_sensor($valid['sensor'], $type, $device, $oid, $descr, 'netscaler-state', $descr, NULL, $value, array('entPhysicalClass' => $physical));
    } else {
        if (is_numeric($value)) {
            discover_sensor($valid['sensor'], $type, $device, $oid, $descr, 'netscaler-health', $descr, $scale, $value * $scale);
        }
    }
}
unset($ns_sensor_array);
$sysHighAvailabilityMode = snmp_get($device, 'sysHighAvailabilityMode.0', '-Ovq', 'NS-ROOT-MIB', mib_dirs('citrix'));
if ($sysHighAvailabilityMode) {
    $descr = 'HA Mode';
    $oid = '.1.3.6.1.4.1.5951.4.1.1.6.0';
    $value = state_string_to_numeric('netscaler-ha-state', $sysHighAvailabilityMode);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'sysHighAvailabilityMode.0', 'netscaler-ha-state', $descr, NULL, $value, array('entPhysicalClass' => 'other'));
}
unset($sysHighAvailabilityMode);
// EOF
Example #13
0
// AC-SYSTEM-MIB::acSysPowerSupplyGeographicalPosition.1 = Gauge32: 1
// AC-SYSTEM-MIB::acSysPowerSupplyGeographicalPosition.2 = Gauge32: 2
// AC-SYSTEM-MIB::acSysPowerSupplyExistence.1 = INTEGER: present(1)
// AC-SYSTEM-MIB::acSysPowerSupplyExistence.2 = INTEGER: present(1)
// AC-SYSTEM-MIB::acSysPowerSupplyHwversion.1 = STRING:
// AC-SYSTEM-MIB::acSysPowerSupplyHwversion.2 = STRING:
// AC-SYSTEM-MIB::acSysPowerSupplyLEDs.1 = Hex-STRING: E2 EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE
// AC-SYSTEM-MIB::acSysPowerSupplyLEDs.2 = Hex-STRING: E2 EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE
// AC-SYSTEM-MIB::acSysPowerSupplySeverity.1 = INTEGER: cleared(1)
// AC-SYSTEM-MIB::acSysPowerSupplySeverity.2 = INTEGER: cleared(1)
$oids = snmpwalk_cache_multi_oid($device, "acSysPowerSupplyTable", array(), "AC-SYSTEM-MIB", mib_dirs('audiocodes'));
$sensor_state_type = $sensor_type . '-power-state';
foreach ($oids as $index => $entry) {
    $descr = "Power Supply {$index}";
    $oid = ".1.3.6.1.4.1.5003.9.10.10.4.23.1.6.{$index}";
    $value = state_string_to_numeric($sensor_state_type, $entry['acSysPowerSupplySeverity']);
    if ($entry['acSysPowerSupplyExistence'] != 'missing') {
        discover_sensor($valid['sensor'], 'state', $device, $oid, "acSysPowerSupply.{$index}", $sensor_state_type, $descr, NULL, $value, array('entPhysicalClass' => 'power'));
    }
}
// AC-SYSTEM-MIB::acSysModuleTemperature.67911681 = INTEGER: -1
// AC-SYSTEM-MIB::acSysModuleTemperature.68173825 = INTEGER: -1
// AC-SYSTEM-MIB::acSysModuleTemperature.68435969 = INTEGER: -1
// AC-SYSTEM-MIB::acSysModuleTemperature.68956161 = INTEGER: -1
// AC-SYSTEM-MIB::acSysModuleType.67911681 = INTEGER: acMediant1000IPMediaModule(257)
// AC-SYSTEM-MIB::acSysModuleType.68173825 = INTEGER: acMediant1000IPMediaModule(257)
// AC-SYSTEM-MIB::acSysModuleType.68435969 = INTEGER: acMediant1000IPMediaModule(257)
// AC-SYSTEM-MIB::acSysModuleType.68956161 = INTEGER: acMediant1000CPUmodule(253)
// AC-SYSTEM-MIB::acSysModulePresence.67911681 = INTEGER: present(1)
// AC-SYSTEM-MIB::acSysModulePresence.68173825 = INTEGER: present(1)
// AC-SYSTEM-MIB::acSysModulePresence.68435969 = INTEGER: present(1)
Example #14
0
        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 = state_string_to_numeric('mge-status-state', $entry['upsmgBatteryLowCondition']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, "upsmgBatteryLowCondition.{$index}", 'mge-status-state', $descr, NULL, $value, array('entPhysicalClass' => 'battery'));
    }
    // MG-SNMP-UPS-MIB::upsmgBatteryReplacement.0 = no
    if (isset($entry['upsmgBatteryReplacement'])) {
        $descr = "Battery Replacement Needed";
        $oid = ".1.3.6.1.4.1.705.1.5.11.{$index}";
        $value = state_string_to_numeric('mge-status-state', $entry['upsmgBatteryReplacement']);
        discover_sensor($valid['sensor'], 'state', $device, $oid, "upsmgBatteryReplacement.{$index}", 'mge-status-state', $descr, NULL, $value, array('entPhysicalClass' => 'battery'));
    }
}
echo " ";
// Environmental monitoring
$cache['mge'] = array();
foreach (array("upsmgEnviron") as $table) {
    echo "{$table} ";
    $cache['mge'] = snmpwalk_cache_multi_oid($device, $table, $cache['mge'], "MG-SNMP-UPS-MIB", NULL, TRUE);
}
// MG-SNMP-UPS-MIB::upsmgEnvironAmbientTemp.0 = INTEGER: 0
// MG-SNMP-UPS-MIB::upsmgEnvironAmbientHumidity.0 = INTEGER: 0
$scale = 0.1;
foreach ($cache['mge'] as $index => $entry) {
    $descr = "Ambient";
foreach ($data as $index => $entry) {
    $oid = '.1.3.6.1.4.1.94.1.21.1.2.1.1.2.' . $index;
    $descr = 'Chassis Fan';
    if ($data_multi) {
        $descr .= " {$index}";
    }
    $value = state_string_to_numeric('ipso-sensor-state', $entry['ipsoFanOperStatus']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "ipsoFanOperStatus.{$index}", "ipso-sensor-state", $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
}
// NOKIA-IPSO-SYSTEM-MIB::ipsoPowerSupplyOverTemperature.1 = INTEGER: normal(1)
// NOKIA-IPSO-SYSTEM-MIB::ipsoPowerSupplyOperStatus.1 = INTEGER: running(1)
$data = snmpwalk_cache_multi_oid($device, 'ipsoPowerSupplyTable', array(), $mib, mib_dirs('checkpoint'));
$data_multi = count($data) > 1;
// Set TRUE if more than one index
foreach ($data as $index => $entry) {
    $oid = '.1.3.6.1.4.1.94.1.21.1.3.1.1.2.' . $index;
    $descr = 'Power Supply Temperature';
    if ($data_multi) {
        $descr .= " {$index}";
    }
    $value = state_string_to_numeric('ipso-temperature-state', $entry['ipsoPowerSupplyOverTemperature']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "ipsoPowerSupplyOverTemperature.{$index}", "ipso-temperature-state", $descr, NULL, $value, array('entPhysicalClass' => 'temperature'));
    $oid = '.1.3.6.1.4.1.94.1.21.1.3.1.1.3.' . $index;
    $descr = 'Power Supply';
    if ($data_multi) {
        $descr .= " {$index}";
    }
    $value = state_string_to_numeric('ipso-sensor-state', $entry['ipsoPowerSupplyOperStatus']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "ipsoPowerSupplyOperStatus.{$index}", "ipso-sensor-state", $descr, NULL, $value, array('entPhysicalClass' => 'other'));
}
// EOF
function discover_status($device, $oid, $index, $type, $status_descr, $current = NULL, $options = array(), $poller_type = 'snmp')
{
    global $config;
    // Init main
    $param_main = array('oid' => 'status_oid', 'status_descr' => 'status_descr');
    // Check state value
    if ($current !== NULL) {
        $state = state_string_to_numeric($type, $current);
        if ($state === FALSE) {
            print_debug("Skipped by unknown state value: {$current}, {$status_descr} ");
            return FALSE;
        } else {
            if ($config['status_states'][$type][$state]['event'] == 'ignore') {
                print_debug("Skipped by ignored state value: " . $config['status_states'][$type][$state]['name'] . ", {$status_descr} ");
                return FALSE;
            }
        }
        $current = $state;
    }
    // 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("Discover status: " . $device['hostname'] . ", {$oid}, {$index}, {$type}, {$status_descr}, {$current}, {$poller_type}, {$entPhysicalIndex}, {$entPhysicalClass}");
    // Check sensor ignore filters
    foreach ($config['ignore_sensor'] as $bi) {
        if (strcasecmp($bi, $status_descr) == 0) {
            print_debug("Skipped by equals: {$bi}, {$status_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_string'] as $bi) {
        if (stripos($status_descr, $bi) !== FALSE) {
            print_debug("Skipped by strpos: {$bi}, {$status_descr} ");
            return FALSE;
        }
    }
    foreach ($config['ignore_sensor_regexp'] as $bi) {
        if (preg_match($bi, $status_descr) > 0) {
            print_debug("Skipped by regexp: {$bi}, {$status_descr} ");
            return FALSE;
        }
    }
    if (dbFetchCell('SELECT COUNT(`status_id`) FROM `status`
                   WHERE `device_id` = ? AND `status_type` = ? AND `status_index` = ? AND `poller_type`= ?;', array($device['device_id'], $type, $index, $poller_type)) == '0') {
        $status_insert = array('poller_type' => $poller_type, 'device_id' => $device['device_id'], 'status_index' => $index, 'status_type' => $type);
        foreach ($param_main as $key => $column) {
            $status_insert[$column] = ${$key};
        }
        foreach ($param_opt as $key) {
            if (is_null(${$key})) {
                ${$key} = array('NULL');
            }
            // If param null, convert to array(NULL) for dbFacile
            $status_insert[$key] = ${$key};
        }
        $status_id = dbInsert($status_insert, 'status');
        $status_insert = array('status_id' => $status_id, 'status_value' => $current, 'status_polled' => 'NOW()');
        dbInsert($status_insert, 'status-state');
        print_debug("( {$status_id} inserted )");
        echo "+";
        if ($poller_type != 'ipmi') {
            // Suppress events for IPMI, see: http://jira.observium.org/browse/OBSERVIUM-959
            log_event("Status added: {$class} {$type} {$index} {$status_descr}", $device, 'status', $status_id);
        }
    } else {
        $status_entry = dbFetchRow("SELECT * FROM `status` WHERE `device_id` = ? AND `status_type` = ? AND `status_index` = ? AND `poller_type`= ?;", array($device['device_id'], $type, $index, $poller_type));
        // FIXME. Remove in r7000
        /* DS also changed.. f**k.
           $old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . get_sensor_rrd($device, array('sensor_class' => 'state', 'sensor_type' => $type, 'sensor_index' => $index, 'sensor_descr' => $status_entry['status_descr'], 'poller_type' => $poller_type));
           $new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . get_status_rrd($device, $status_entry);
           if (is_file($old_rrd)) { rename($old_rrd, $new_rrd); print_warning("Moved RRD"); }
           */
        $update = array();
        foreach ($param_main as $key => $column) {
            if (${$key} != $status_entry[$column]) {
                $update[$column] = ${$key};
            }
        }
        foreach ($param_opt as $key) {
            if (${$key} != $status_entry[$key]) {
                $update[$key] = ${$key};
            }
        }
        if (count($update)) {
            $updated = dbUpdate($update, 'status', '`status_id` = ?', array($status_entry['status_id']));
            echo "U";
            log_event("Status updated: {$type} {$index} {$status_descr}", $device, 'status', $status_entry['status_id']);
        } else {
            echo ".";
        }
    }
    $GLOBALS['valid']['status'][$type][$index] = 1;
}
    $descr = "Fan";
    if (count($oids) > 1) {
        $descr .= " " . ($index + 1);
    }
    $oid = ".1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.6.1.3." . $index;
    $value = state_string_to_numeric('fastpath-boxservices-private-state', $entry['boxServicesFanItemState']);
    if ($entry['boxServicesFanItemState'] != 'notpresent') {
        // FIXME should be a state sensor. subtype fanspeed. (or fanspeed sensor, subtype state)
        discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, "boxServicesFanItemState.{$index}", 'fastpath-boxservices-private-state', $descr, 1, $value, array('entPhysicalClass' => 'fan'));
        if ($entry['boxServicesFanSpeed'] != 0) {
            // FIXME - could add a fan speed sensor here, but none of my devices have non-zero values.
            // duty level is most likely a percentage?
        }
    }
}
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyIndex.0 = INTEGER: 0
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyIndex.1 = INTEGER: 1
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemType.0 = INTEGER: fixed(1)
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemType.1 = INTEGER: removable(2)
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemState.0 = INTEGER: operational(2)
// FASTPATH-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemState.1 = INTEGER: operational(2)
$oids = snmpwalk_cache_multi_oid($device, "boxServicesPowSuppliesTable", array(), "FASTPATH-BOXSERVICES-PRIVATE-MIB", mib_dirs('broadcom', 'dell'));
foreach ($oids as $index => $entry) {
    $descr = ucfirst($entry['boxServicesPowSupplyItemType'] . ' Power Supply');
    $oid = ".1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1.3." . $index;
    $value = state_string_to_numeric('fastpath-boxservices-private-state', $entry['boxServicesPowSupplyItemState']);
    if ($entry['boxServicesPowSupplyItemState'] != 'notpresent') {
        discover_sensor($valid['sensor'], 'state', $device, $oid, "boxServicesPowSupplyItemState.{$index}", 'fastpath-boxservices-private-state', $descr, 1, $value, array('entPhysicalClass' => 'power'));
    }
}
// EOF
        $oid = ".1.3.6.1.4.1.674.10895.3000.1.2.110.7.1.1.3." . $index;
        $current = state_string_to_numeric('dell-vendor-state', $entry['envMonFanState']);
        $query = "SELECT sensor_id FROM `sensors` WHERE `device_id` = '" . $device['device_id'] . "' AND `sensor_class` = 'fanspeed'";
        $query .= " AND `sensor_type` IN ('radlan-hwenvironment-state','fastpath-boxservices-private-state')";
        $query .= " AND (`sensor_index` IN ('rlEnvMonFanState.{$index}') OR `sensor_descr` = '{$descr}')";
        if ($entry['envMonFanState'] != 'notPresent' && !count(dbFetchRows($query))) {
            discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, "envMonFanState.{$index}", 'dell-vendor-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $current);
        }
    }
}
// Dell-Vendor-MIB::envMonSupplyStatusDescr.67109185 = STRING: ps1
// Dell-Vendor-MIB::envMonSupplyStatusDescr.67109186 = STRING: ps2
// Dell-Vendor-MIB::envMonSupplyState.67109185 = INTEGER: normal(1)
// Dell-Vendor-MIB::envMonSupplyState.67109186 = INTEGER: notPresent(5)
// Dell-Vendor-MIB::envMonSupplySource.67109185 = INTEGER: ac(2)
// Dell-Vendor-MIB::envMonSupplySource.67109186 = INTEGER: unknown(1)
$oids = snmpwalk_cache_multi_oid($device, "envMonSupplyStatusTable", array(), "Dell-Vendor-MIB", mib_dirs('dell'));
if (is_array($oids)) {
    foreach ($oids as $index => $entry) {
        $descr = ucfirst($entry['envMonSupplyStatusDescr']);
        $oid = ".1.3.6.1.4.1.674.10895.3000.1.2.110.7.2.1.3." . $index;
        $current = state_string_to_numeric('dell-vendor-state', $entry['envMonSupplyState']);
        // Ignore all PSU when we find another MIB has delivered. Descriptions and indexes are different so we cannot match them up.
        $query = "SELECT sensor_id FROM `sensors` WHERE `device_id` = '" . $device['device_id'] . "' AND `sensor_class` = 'power'";
        $query .= " AND `sensor_type` IN ('radlan-hwenvironment-state','fastpath-boxservices-private-state')";
        if ($entry['envMonSupplyState'] != 'notPresent' && !count(dbFetchRows($query))) {
            discover_sensor($valid['sensor'], 'power', $device, $oid, "envMonSupplyState.{$index}", 'dell-vendor-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $current);
        }
    }
}
// EOF
Example #19
0
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// .1.3.6.1.4.1.17163.1.1.2.7.0 STEELHEAD-MIB::systemHealth.0 = INTEGER: critical(50000)
// .1.3.6.1.4.1.17163.1.1.2.8.0 STEELHEAD-MIB::optServiceStatus.0 = INTEGER: stopped(8)
// .1.3.6.1.4.1.17163.1.1.2.9.0 STEELHEAD-MIB::systemTemperature.0 = Gauge32: 0
echo " STEELHEAD-MIB ";
$oid = "1.3.6.1.4.1.17163.1.1.2.7.0";
$value = state_string_to_numeric('steelhead-system-state', snmp_get($device, "systemHealth.0", "-Oqv", "STEELHEAD-MIB", mib_dirs('riverbed')));
if (is_numeric($value) && $value > 0) {
    $descr = "System Health";
    discover_sensor($valid['sensor'], 'state', $device, $oid, "systemHealth.0", 'steelhead-system-state', $descr, NULL, $value, array('entPhysicalClass' => 'chassis'));
}
$oid = "1.3.6.1.4.1.17163.1.1.2.8.0";
$value = state_string_to_numeric('steelhead-service-state', snmp_get($device, "optServiceStatus.0", "-Oqv", "STEELHEAD-MIB", mib_dirs('riverbed')));
if (is_numeric($value) && $value > 0) {
    $descr = "Service Status";
    discover_sensor($valid['sensor'], 'state', $device, $oid, "optServiceStatus.0", 'steelhead-service-state', $descr, NULL, $value, array('entPhysicalClass' => 'other'));
}
$oid = "1.3.6.1.4.1.17163.1.1.2.9.0";
$value = snmp_get($device, "systemTemperature.0", "-Oqv", "STEELHEAD-MIB", mib_dirs('riverbed'));
if (is_numeric($value) && $value > 0) {
    $descr = "System Temperature";
    discover_sensor($valid['sensor'], 'temperature', $device, $oid, "systemTemperature.0", 'steelhead-mib', $descr, 1, $value);
}
// EOF
Example #20
0
if ($thermal_status) {
    $descr = "Thermal Status";
    $oid = ".1.3.6.1.4.1.232.6.2.6.1.0";
    $value = state_string_to_numeric('cpqhlth-state', $thermal_status);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'cpqHeThermalCondition.0', 'cpqhlth-state', $descr, NULL, $value, array('entPhysicalClass' => 'temperature'));
}
if ($system_fan_status) {
    $descr = "System Fan Status";
    $oid = ".1.3.6.1.4.1.232.6.2.6.4.0";
    $value = state_string_to_numeric('cpqhlth-state', $system_fan_status);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'cpqHeThermalSystemFanStatus.0', 'cpqhlth-state', $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
}
if ($cpu_fan_status) {
    $descr = "CPU Fan Status";
    $oid = ".1.3.6.1.4.1.232.6.2.6.5.0";
    $value = state_string_to_numeric('cpqhlth-state', $cpu_fan_status);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'cpqHeThermalCpuFanStatus.0', 'cpqhlth-state', $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
}
// Temperatures
$oids = snmpwalk_cache_oid($device, "CpqHeTemperatureEntry", array(), "CPQHLTH-MIB", mib_dirs('hp'));
$descPatterns = array('/Cpu/', '/PowerSupply/');
$descReplace = array('CPU', 'PSU');
$descCount = array('CPU' => 1, 'PSU' => 1);
foreach ($oids as $index => $entry) {
    if ($entry['cpqHeTemperatureThreshold'] > 0) {
        $descr = ucfirst($entry['cpqHeTemperatureLocale']);
        if ($descr === 'System' || $descr === 'Memory') {
            continue;
        }
        if ($descr === 'Cpu' || $descr === 'PowerSupply') {
            $descr = preg_replace($descPatterns, $descReplace, $descr);
// RADLAN-HWENVIROMENT::rlEnvMonFanState.67109249 = INTEGER: normal(1)
// RADLAN-HWENVIROMENT::rlEnvMonFanState.67109250 = INTEGER: normal(1)
$oids = snmpwalk_cache_multi_oid($device, "rlEnvMonFanStatusTable", array(), "RADLAN-HWENVIROMENT", mib_dirs('radlan'));
if (is_array($oids)) {
    foreach ($oids as $index => $entry) {
        $descr = ucfirst($entry['rlEnvMonFanStatusDescr']);
        $oid = ".1.3.6.1.4.1.89.83.1.1.1.3." . $index;
        $current = state_string_to_numeric('radlan-hwenvironment-state', $entry['rlEnvMonFanState']);
        if ($entry['rlEnvMonFanState'] != 'notPresent') {
            discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, "rlEnvMonFanState.{$index}", 'radlan-hwenvironment-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $current);
        }
    }
}
// RADLAN-HWENVIROMENT::rlEnvMonSupplyStatusDescr.67109185 = STRING: "ps1"
// RADLAN-HWENVIROMENT::rlEnvMonSupplyStatusDescr.67109186 = STRING: "ps2"
// RADLAN-HWENVIROMENT::rlEnvMonSupplyState.67109185 = INTEGER: normal(1)
// RADLAN-HWENVIROMENT::rlEnvMonSupplyState.67109186 = INTEGER: notPresent(5)
// RADLAN-HWENVIROMENT::rlEnvMonSupplySource.67109185 = INTEGER: ac(2)
// RADLAN-HWENVIROMENT::rlEnvMonSupplySource.67109186 = INTEGER: unknown(1)
$oids = snmpwalk_cache_multi_oid($device, "rlEnvMonSupplyStatusTable", array(), "RADLAN-HWENVIROMENT", mib_dirs('radlan'));
if (is_array($oids)) {
    foreach ($oids as $index => $entry) {
        $descr = ucfirst($entry['rlEnvMonSupplyStatusDescr']);
        $oid = ".1.3.6.1.4.1.89.83.1.2.1.3." . $index;
        $current = state_string_to_numeric('radlan-hwenvironment-state', $entry['rlEnvMonSupplyState']);
        if ($entry['rlEnvMonSupplyState'] != 'notPresent') {
            discover_sensor($valid['sensor'], 'power', $device, $oid, "rlEnvMonSupplyState.{$index}", 'radlan-hwenvironment-state', $descr, 1, 1, NULL, NULL, NULL, NULL, $current);
        }
    }
}
// EOF
    // remove some information from the voltage description
    $descr = preg_replace('/ \\(millivolts\\)/', '', $descr);
    $oid = ".1.3.6.1.4.1.9148.3.3.1.2.1.1.4.{$index}";
    $value = $entry['apEnvMonVoltageStatusValue'] * $scale;
    if (is_numeric($value)) {
        discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, 'acme-env', $descr, $scale, $value);
    }
}
// FAN:
echo " Fan ";
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "apEnvMonFanState", $oids, "ACMEPACKET-ENVMON-MIB", mib_dirs('acme'));
foreach ($oids as $index => $entry) {
    $descr = trim(snmp_get($device, "apEnvMonFanStatusDescr.{$index}", "-Oqv", "ACMEPACKET-ENVMON-MIB", mib_dirs('acme')), '"');
    // remove some information from the voltage description
    $descr = preg_replace('/ [Ss]peed/', '', $descr);
    $oid = ".1.3.6.1.4.1.9148.3.3.1.4.1.1.5.{$index}";
    $value = state_string_to_numeric('acme-env-state', $entry['apEnvMonFanState']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "apEnvMonFanState.{$index}", 'acme-env-state', $descr, NULL, $value, array('entPhysicalClass' => 'fan'));
}
// Power
echo " Power ";
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "apEnvMonPowerSupplyState", $oids, "ACMEPACKET-ENVMON-MIB", mib_dirs('acme'));
foreach ($oids as $index => $entry) {
    $descr = trim(snmp_get($device, "apEnvMonPowerSupplyStatusDescr.{$index}", "-Oqv", "ACMEPACKET-ENVMON-MIB", mib_dirs('acme')), '"');
    $oid = ".1.3.6.1.4.1.9148.3.3.1.5.1.1.4.{$index}";
    $value = state_string_to_numeric('acme-env-state', $entry['apEnvMonPowerSupplyState']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, "apEnvMonPowerSupplyState.{$index}", 'acme-env-state', $descr, NULL, $value, array('entPhysicalClass' => 'power'));
}
// EOF
//
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyIndex.0 = INTEGER: 0
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyIndex.1 = INTEGER: 1
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemType.0 = INTEGER: fixed(1)
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemType.1 = INTEGER: removable(2)
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemState.0 = INTEGER: operational(2)
// DNOS-BOXSERVICES-PRIVATE-MIB::boxServicesPowSupplyItemState.1 = INTEGER: notpresent(1)
$oid = 'boxServicesPowSuppliesTable';
$oids = snmpwalk_cache_multi_oid($device, $oid, array(), $mib);
$show_numbers = count($oids) > 1;
foreach ($oids as $index => $entry) {
    if ($entry['boxServicesPowSupplyItemState'] == 'notpresent') {
        continue;
    }
    // State Sensor
    $value = state_string_to_numeric('dnos-boxservices-state', $entry['boxServicesPowSupplyItemState']);
    $descr = dnos_boxservices_type_manip($entry['boxServicesPowSupplyItemType']) . ' PSU';
    if ($show_numbers) {
        $descr .= ' ' . ($index + 1);
    }
    $sensor_oid = ".1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.7.1.3.{$index}";
    $options = array('entPhysicalClass' => 'power');
    discover_sensor($valid['sensor'], 'state', $device, $sensor_oid, "boxServicesPowSupplyState.{$index}", 'dnos-boxservices-state', $descr, NULL, $value, $options);
}
// Power Usage
//
// DNOS-BOXSERVICES-PRIVATE-MIB::boxsPwrUsageHistoryUnitSampleTime.1.1 = STRING: "6d:03:46:39"
// ...
// DNOS-BOXSERVICES-PRIVATE-MIB::boxsPwrUsageHistoryUnitSampleTime.1.60 = STRING: "3d:16:45:40"
// DNOS-BOXSERVICES-PRIVATE-MIB::boxsPwrUsageHistoryUnitSampleTime.2.1 = STRING: "6d:04:46:39"
// ...
Example #24
0
/**
 * Return normalized state array by type and value (numeric or string)
 *
 * DOCME parameter docs?
 */
function get_state_array($type, $value, $poller_type = 'snmp')
{
    $state_array = array('value' => FALSE);
    switch ($poller_type) {
        case 'agent':
        case 'ipmi':
            $state = state_string_to_numeric($type, $value, $poller_type);
            if ($state !== FALSE) {
                $state_array['value'] = $state;
                // Numeric value
                $state_array['name'] = $GLOBALS['config'][$poller_type]['states'][$type][$state]['name'];
                // Named value
                $state_array['event'] = $GLOBALS['config'][$poller_type]['states'][$type][$state]['event'];
                // Event type
                $state_array['mib'] = $poller_type;
            }
            break;
        default:
            // SNMP
            $state = state_string_to_numeric($type, $value);
            if ($state !== FALSE) {
                $mib = state_type_to_mib($type);
                $state_array['value'] = $state;
                // Numeric value
                $state_array['name'] = $GLOBALS['config']['mibs'][$mib]['states'][$type][$state]['name'];
                // Named value
                $state_array['event'] = $GLOBALS['config']['mibs'][$mib]['states'][$type][$state]['event'];
                // Event type
                $state_array['mib'] = $mib;
                // MIB name
            }
    }
    return $state_array;
}
Example #25
0
//ExaltComProducts::remLinkState.0 = INTEGER: almNORMAL(0)
//ExaltComProducts::remErrorDuration.0 = INTEGER: 3 Seconds
//ExaltComProducts::remErrorDurationStr.0 = STRING: 3 seconds.
//ExaltComProducts::remUnavailDuration.0 = INTEGER: 0 Seconds
//ExaltComProducts::remUnavailDurationStr.0 = STRING: 0 seconds.
$discover['state'] = snmp_get_multi($device, 'locLinkState.0 locErrorDuration.0 locUnavailDuration.0 remLinkState.0 remErrorDuration.0 remUnavailDuration.0', '-OQUs', 'ExaltComProducts', mib_dirs('exalt'));
$sensor_state_type = 'exaltcomproducts-state';
$options = array('entPhysicalClass' => 'linkstate');
if (!empty($discover['state'][0]['locLinkState'])) {
    $oid = '.1.3.6.1.4.1.25651.1.2.4.2.3.1.1.0';
    $value = state_string_to_numeric($sensor_state_type, $discover['state'][0]['locLinkState']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'locLinkState.0', $sensor_state_type, "Link Status (Internal)", NULL, $value, $options);
}
if (!empty($discover['state'][0]['remLinkState'])) {
    $oid = '.1.3.6.1.4.1.25651.1.2.4.2.4.1.1.0';
    $value = state_string_to_numeric($sensor_state_type, $discover['state'][0]['remLinkState']);
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'remLinkState.0', $sensor_state_type, "Link Status (Far end radio)", NULL, $value, $options);
}
if (is_numeric($discover['state'][0]['locErrorDuration']) && is_numeric($discover['state'][0]['locUnavailDuration'])) {
    $oid = '.1.3.6.1.4.1.25651.1.2.4.3.1.5.0';
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'locErrorDuration.0', 'exaltcomproducts', "Errored Seconds (Internal)", 1, $discover['state'][0]['locErrorDuration']);
    $oid = '.1.3.6.1.4.1.25651.1.2.4.3.1.7.0';
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'locUnavailDuration.0', 'exaltcomproducts', "Unavailable Seconds (Internal)", 1, $discover['state'][0]['locUnavailDuration']);
}
if (is_numeric($discover['state'][0]['remErrorDuration']) && is_numeric($discover['state'][0]['remUnavailDuration'])) {
    $oid = '.1.3.6.1.4.1.25651.1.2.4.3.2.5.0';
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'remErrorDuration.0', 'exaltcomproducts', "Errored Seconds (Far end radio)", 1, $discover['state'][0]['remErrorDuration']);
    $oid = '.1.3.6.1.4.1.25651.1.2.4.3.2.7.0';
    discover_sensor($valid['sensor'], 'state', $device, $oid, 'remUnavailDuration.0', 'exaltcomproducts', "Unavailable Seconds (Far end radio)", 1, $discover['state'][0]['remUnavailDuration']);
}
unset($discover, $oid, $value, $sensor_state_type);
}
// LSI-MegaRAID-SAS-MIB::fanID.0 = INTEGER: 0
// LSI-MegaRAID-SAS-MIB::enclosureId.0 = INTEGER: 0
// LSI-MegaRAID-SAS-MIB::fanStatus.0 = INTEGER: status-ok(2)
echo " enclosureFanTable ";
$cache['megaraid']['fan'] = snmpwalk_cache_multi_oid($device, "enclosureFanTable", array(), "LSI-MegaRAID-SAS-MIB", mib_dirs('lsi'));
foreach ($cache['megaraid']['fan'] as $index => $fan) {
    $encl = trim(trim($cache['megaraid']['encl'][$fan['enclosureId']]['vendorID'], '.') . " " . trim($cache['megaraid']['encl'][$fan['enclosureId']]['productID'], '.'));
    if ($encl == '') {
        $encl = 'Enclosure (' . $cache['megaraid']['encl'][$fan['enclosureId']]['enclosureIndex'] . ')';
        // Static string if no vendor/product ID for enclosure
    } else {
        $encl .= ' (' . $cache['megaraid']['encl'][$fan['enclosureId']]['enclosureIndex'] . ')';
    }
    $descr = $encl . " Fan " . ++$lsi_counter['fan'][$fan['enclosureId']];
    $value = state_string_to_numeric('lsi-megaraid-sas-sensor-state', $fan['fanStatus']);
    $oid = ".1.3.6.1.4.1.3582.4.1.5.3.1.3.{$index}";
    discover_sensor($valid['sensor'], 'state', $device, $oid, "fanStatus.{$index}", 'lsi-megaraid-sas-sensor-state', $descr, 1, $value);
}
/*
enclosure data:
    [1] => Array
        (
            [enclosureID] => 0
            [deviceId] => 8
            [enclosureIndex] => 1
            [slotCount] => 12
            [psCount] => 2
            [fanCount] => 10
            [tempSensorCount] => 6
            [alarmCount] => 1