function discover_new_device_ip($host)
{
    global $config;
    if (match_network($config['autodiscovery']['ip_nets'], $host)) {
        if (isPingable($host)) {
            echo "Pingable ";
            foreach ($config['snmp']['community'] as $community) {
                $device = deviceArray($host, $community, "v2c", "161", "udp", NULL);
                print_message("Trying community {$community} ...");
                if (isSNMPable($device)) {
                    echo "SNMPable ";
                    $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
                    if (dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE sysName = ?", array($snmphost)) == '0') {
                        $device_id = createHost($snmphost, $community, "v2c", "161", "udp");
                        $device = device_by_id_cache($device_id, 1);
                        array_push($GLOBALS['devices'], $device);
                        return $device_id;
                    } else {
                        echo "Already have host with sysName {$snmphost}\n";
                    }
                }
            }
        }
    }
}
Example #2
0
function getValue($host, $port, $id, $inout)
{
    global $config;
    $oid = 'IF-MIB::ifHC' . $inout . 'Octets.' . $id;
    $device = dbFetchRow("SELECT * from `devices` WHERE `hostname` = '" . mres($host) . "' LIMIT 1");
    $value = snmp_get($device, $oid, '-O qv');
    if (!is_numeric($value)) {
        $oid = 'IF-MIB::if' . $inout . 'Octets.' . $id;
        $value = snmp_get($device, $oid, '-Oqv');
    }
    return $value;
}
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @subpackage functions
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
function discover_new_device_ip($host, $source = 'xdp', $protocol = NULL, $device = NULL, $port = NULL)
{
    global $config;
    print_debug("Discovering possible new device on {$host}");
    if ($config['autodiscovery'][$source]) {
        if (match_network($config['autodiscovery']['ip_nets'], $host)) {
            $db = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS P, devices AS D WHERE A.ipv4_address = ? AND P.port_id = A.port_id AND D.device_id = P.device_id", array($host));
            if (is_array($db)) {
                print_debug("Already have {$host} on " . $db['hostname']);
            } else {
                if (isPingable($host)) {
                    echo "Pingable ";
                    foreach ($config['snmp']['community'] as $community) {
                        $newdevice = deviceArray($host, $community, "v2c", "161", "udp", NULL);
                        print_message("Trying community {$community} ...");
                        if (isSNMPable($newdevice)) {
                            echo "SNMPable ";
                            $snmphost = snmp_get($newdevice, "sysName.0", "-Oqv", "SNMPv2-MIB");
                            if (dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE sysName = ?", array($snmphost)) == '0') {
                                $device_id = createHost($snmphost, $community, "v2c", "161", "udp");
                                $newdevice = device_by_id_cache($device_id, 1);
                                array_push($GLOBALS['devices'], $newdevice);
                                if (!$protocol) {
                                    $protocol = strtoupper($source);
                                }
                                if ($port) {
                                    humanize_port($port);
                                    log_event("Device autodiscovered through {$protocol} on " . $device['hostname'] . " (port " . $port['label'] . ")", $remote_device_id, 'interface', $port['port_id']);
                                } else {
                                    log_event("Device autodiscovered through {$protocol} on " . $device['hostname'], $remote_device_id);
                                }
                                return $device_id;
                            } else {
                                echo "Already have host with sysName {$snmphost}\n";
                            }
                        }
                    }
                } else {
                    print_debug("IP not pingable.");
                }
            }
        } else {
            print_debug("Host does not match configured nets");
        }
    } else {
        print_debug("Source {$source} disabled for autodiscovery!");
    }
}
Example #4
0
<?php

#ALCATEL-IND1-SYSTEM-MIB::systemHardwareMemoryMfg.0 = INTEGER: notreadable(12)
#ALCATEL-IND1-SYSTEM-MIB::systemHardwareMemorySize.0 = Gauge32: 268435456
#ALCATEL-IND1-HEALTH-MIB::healthDeviceMemoryLatest.0 = INTEGER: 74
#ALCATEL-IND1-HEALTH-MIB::healthDeviceMemory1MinAvg.0 = INTEGER: 74
#ALCATEL-IND1-HEALTH-MIB::healthDeviceMemory1HrAvg.0 = INTEGER: 74
#ALCATEL-IND1-HEALTH-MIB::healthDeviceMemory1HrMax.0 = INTEGER: 74
$mempool['units'] = "1";
$mempool['total'] = snmp_get($device, "systemHardwareMemorySize.0", "-OvQ", "ALCATEL-IND1-SYSTEM-MIB", "+" . $config['install_dir'] . "/mibs/aos");
$percent = snmp_get($device, "healthDeviceMemoryLatest.0", "-OvQ", "ALCATEL-IND1-HEALTH-MIB", "+" . $config['install_dir'] . "/mibs/aos");
$mempool['used'] = $mempool['total'] * ($percent / 100);
$mempool['free'] = $mempool['total'] - $mempool['used'];
Example #5
0
<?php

if ($device['os'] == 'qnap') {
    echo 'QNAP temperature ';
    // Turbo NAS Temperature
    $turbonas_temperature_oid = '.1.3.6.1.4.1.24681.1.3.6.0';
    // Turbo NAS Disk Temperature
    $disk_temperature_oid = '.1.3.6.1.4.1.24681.1.2.11.1.3.';
    // Get Turbo NAS temperature
    $turbonas_temperature = snmp_get($device, $turbonas_temperature_oid, '-Oqv');
    // Save the Turbo NAS temperature
    discover_sensor($valid['sensor'], 'temperature', $device, $turbonas_temperature_oid, '99', 'snmp', 'System Temperature', '1', '1', null, null, null, null, $turbonas_temperature);
    // Get all disks in the device
    $disks = snmpwalk_cache_multi_oid($device, 'SystemHdTable', array(), 'NAS-MIB');
    // Parse all disks in the device to get the temperatures
    if (is_array($disks)) {
        foreach ($disks as $disk_number => $entry) {
            // Get the disk temperature full oid
            $disk_oid = $disk_temperature_oid . $disk_number;
            // Get the temperature for the disk
            $disk_temperature = $entry['HdTemperature'];
            // Getting the disk information (Number and model)
            $disk_information = $entry['HdDescr'] . ' ' . $entry['HdModel'];
            // Save the temperature for the disk
            discover_sensor($valid['sensor'], 'temperature', $device, $disk_oid, $disk_number, 'snmp', $disk_information, '1', '1', null, null, null, null, $disk_temperature);
        }
    }
}
Example #6
0
<?php

if (!empty($agent_data['app']['nginx'])) {
    $nginx = $agent_data['app']['nginx'];
} else {
    // Polls nginx statistics from script via SNMP
    $nginx = snmp_get($device, 'nsExtendOutputFull.5.110.103.105.110.120', '-Ovq', 'NET-SNMP-EXTEND-MIB');
}
$nginx_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/app-nginx-' . $app['app_id'] . '.rrd';
echo ' nginx';
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
if (!is_file($nginx_rrd)) {
    rrdtool_create($nginx_rrd, '--step 300 
        DS:Requests:DERIVE:600:0:125000000000 
        DS:Active:GAUGE:600:0:125000000000 
        DS:Reading:GAUGE:600:0:125000000000 
        DS:Writing:GAUGE:600:0:125000000000 
        DS:Waiting:GAUGE:600:0:125000000000 ' . $config['rrd_rra']);
}
d_echo("active: {$active} reading: {$reading} writing: {$writing} waiting: {$waiting} Requests: {$req}");
$fields = array('Requests' => $req, 'Active' => $active, 'Reading' => $reading, 'Writing' => $writing, 'Waiting' => $waiting);
rrdtool_update($nginx_rrd, $fields);
$tags = array('name' => 'nginx', 'app_id' => $app['app_id']);
influx_update($device, 'app', $tags, $fields);
// Unset the variables we set here
unset($nginx);
unset($nginx_rrd);
unset($active);
unset($reading);
unset($writing);
unset($req);
Example #7
0
<?php

$Descr_string = snmp_get($device, 'sysDescr.0', '-Oqv', 'SNMPv2-MIB');
$Descr_chopper = preg_split('/[ ]+/', "{$Descr_string}");
$version = 'Firmware ' . $Descr_chopper[1];
$hardware = $Descr_chopper[0] . ' Rev. ' . str_replace('"', '', snmp_get($device, '1.3.6.1.4.1.171.10.76.10.1.2.0', '-Oqv'));
if (preg_match('/^Cisco IOS Software, .+? Software \\([^\\-]+-([\\w\\d]+)-\\w\\), Version ([^,]+)/', $poll_device['sysDescr'], $regexp_result)) {
    $features = $regexp_result[1];
    $version = $regexp_result[2];
} elseif (false) {
    # Placeholder
    # Other regexp for other type of string
}
echo "\n" . $poll_device['sysDescr'] . "\n";
$oids = "entPhysicalModelName.1 entPhysicalContainedIn.1 entPhysicalName.1 entPhysicalSoftwareRev.1 entPhysicalModelName.1001 entPhysicalContainedIn.1001 cardDescr.1 cardSlotNumber.1";
$data = snmp_get_multi($device, $oids, "-OQUs", "ENTITY-MIB:OLD-CISCO-CHASSIS-MIB");
if ($data[1]['entPhysicalContainedIn'] == "0") {
    if (!empty($data[1]['entPhysicalSoftwareRev'])) {
        $version = $data[1]['entPhysicalSoftwareRev'];
    }
    if (!empty($data[1]['entPhysicalName'])) {
        $hardware = $data[1]['entPhysicalName'];
    }
    if (!empty($data[1]['entPhysicalModelName'])) {
        $hardware = $data[1]['entPhysicalModelName'];
    }
}
#   if ($slot_1 == "-1" && strpos($descr_1, "No") === FALSE) { $ciscomodel = $descr_1; }
#   if (($contained_1 == "0" || $name_1 == "Chassis") && strpos($model_1, "No") === FALSE) { $ciscomodel = $model_1; list($version_1) = explode(",",$ver_1); }
#   if ($contained_1001 == "0" && strpos($model_1001, "No") === FALSE) { $ciscomodel = $model_1001; }
#   $ciscomodel = str_replace("\"","",$ciscomodel);
#   if ($ciscomodel) { $hardware = $ciscomodel; unset($ciscomodel); }
if (empty($hardware)) {
    $hardware = snmp_get($device, "sysObjectID.0", "-Osqv", "SNMPv2-MIB:CISCO-PRODUCTS-MIB");
}
#if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; }
Example #9
0
<?php

// Polls powerdns statistics from script via SNMP
$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/app-powerdns-' . $app['app_id'] . '.rrd';
$options = '-O qv';
$mib = 'NET-SNMP-EXTEND-MIB';
$oid = 'nsExtendOutputFull.8.112.111.119.101.114.100.110.115';
if ($agent_data['app']['powerdns']) {
    $powerdns = $agent_data['app']['powerdns'];
} else {
    $powerdns = snmp_get($device, $oid, $options, $mib);
}
echo ' powerdns';
list($corrupt, $def_cacheInserts, $def_cacheLookup, $latency, $pc_hit, $pc_miss, $pc_size, $qsize, $qc_hit, $qc_miss, $rec_answers, $rec_questions, $servfail, $tcp_answers, $tcp_queries, $timedout, $udp_answers, $udp_queries, $udp4_answers, $udp4_queries, $udp6_answers, $udp6_queries) = explode("\n", $powerdns);
if (!is_file($rrd_filename)) {
    rrdtool_create($rrd_filename, '--step 300 
        DS:corruptPackets:DERIVE:600:0:125000000000 
        DS:def_cacheInserts:DERIVE:600:0:125000000000 
        DS:def_cacheLookup:DERIVE:600:0:125000000000 
        DS:latency:DERIVE:600:0:125000000000 
        DS:pc_hit:DERIVE:600:0:125000000000 
        DS:pc_miss:DERIVE:600:0:125000000000 
        DS:pc_size:DERIVE:600:0:125000000000 
        DS:qsize:DERIVE:600:0:125000000000 
        DS:qc_hit:DERIVE:600:0:125000000000 
        DS:qc_miss:DERIVE:600:0:125000000000 
        DS:rec_answers:DERIVE:600:0:125000000000 
        DS:rec_questions:DERIVE:600:0:125000000000 
        DS:servfailPackets:DERIVE:600:0:125000000000 
        DS:q_tcpAnswers:DERIVE:600:0:125000000000 
        DS:q_tcpQueries:DERIVE:600:0:125000000000 
Example #10
0
<?php

echo 'IPv4 Addresses : ';
$oids = trim(snmp_walk($device, 'ipAdEntIfIndex', '-Osq', 'IP-MIB'));
$oids = str_replace('ipAdEntIfIndex.', '', $oids);
foreach (explode("\n", $oids) as $data) {
    $data = trim($data);
    list($oid, $ifIndex) = explode(' ', $data);
    $mask = trim(snmp_get($device, "ipAdEntNetMask.{$oid}", '-Oqv', 'IP-MIB'));
    $addr = Net_IPv4::parseAddress("{$oid}/{$mask}");
    $network = $addr->network . '/' . $addr->bitmask;
    $cidr = $addr->bitmask;
    if (dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex)) != '0' && $oid != '0.0.0.0' && $oid != 'ipAdEntIfIndex') {
        $port_id = dbFetchCell('SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex));
        if (dbFetchCell('SELECT COUNT(*) FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($network)) < '1') {
            dbInsert(array('ipv4_network' => $network), 'ipv4_networks');
            // echo("Create Subnet $network\n");
            echo 'S';
        }
        $ipv4_network_id = dbFetchCell('SELECT `ipv4_network_id` FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($network));
        if (dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `ipv4_prefixlen` = ? AND `port_id` = ?', array($oid, $cidr, $port_id)) == '0') {
            dbInsert(array('ipv4_address' => $oid, 'ipv4_prefixlen' => $cidr, 'ipv4_network_id' => $ipv4_network_id, 'port_id' => $port_id), 'ipv4_addresses');
            // echo("Added $oid/$cidr to $port_id ( $hostname $ifIndex )\n $i_query\n");
            echo '+';
        } else {
            echo '.';
        }
        $full_address = "{$oid}/{$cidr}|{$ifIndex}";
        $valid_v4[$full_address] = 1;
    } else {
        echo '!';
Example #11
0
        $current = snmp_get($device, $freq_oid, '-Oqv') / 10;
        $type = 'rfc1628';
        $divisor = 10;
        if ($device['os'] == 'huaweiups') {
            $divisor = 100;
        }
        $index = '3.2.0.' . $i;
        discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
    }
    $freq_oid = '1.3.6.1.2.1.33.1.4.2.0';
    $descr = 'Output';
    $current = snmp_get($device, $freq_oid, '-Oqv') / 10;
    $type = 'rfc1628';
    $divisor = 10;
    if ($device['os'] == 'huaweiups') {
        $divisor = 100;
    }
    $index = '4.2.0';
    discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
    $freq_oid = '1.3.6.1.2.1.33.1.5.1.0';
    $descr = 'Bypass';
    $current = snmp_get($device, $freq_oid, '-Oqv') / 10;
    $type = 'rfc1628';
    $divisor = 10;
    if ($device['os'] == 'huaweiups') {
        $divisor = 100;
    }
    $index = '5.1.0';
    discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
//end if
Example #12
0
 if ($device['os'] == 'pbn') {
     preg_match('/^.* Build (?<build>\\d+)/', $device['version'], $version);
     if ($version[build] <= 16607) {
         // Buggy version :-(
         $tm = '1';
     }
 }
 // read the 802.1D subtree
 $stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', array(), 'RSTP-MIB');
 $stp = array('protocolSpecification' => $stp_raw[0]['dot1dStpProtocolSpecification'], 'priority' => $stp_raw[0]['dot1dStpPriority'], 'topChanges' => $stp_raw[0]['dot1dStpTopChanges'], 'rootCost' => $stp_raw[0]['dot1dStpRootCost'], 'rootPort' => $stp_raw[0]['dot1dStpRootPort'], 'maxAge' => $stp_raw[0]['dot1dStpMaxAge'] * $tm, 'helloTime' => $stp_raw[0]['dot1dStpHelloTime'] * $tm, 'holdTime' => $stp_raw[0]['dot1dStpHoldTime'] * $tm, 'forwardDelay' => $stp_raw[0]['dot1dStpForwardDelay'] * $tm, 'bridgeMaxAge' => $stp_raw[0]['dot1dStpBridgeMaxAge'] * $tm, 'bridgeHelloTime' => $stp_raw[0]['dot1dStpBridgeHelloTime'] * $tm, 'bridgeForwardDelay' => $stp_raw[0]['dot1dStpBridgeForwardDelay'] * $tm);
 // set device binding
 $stp['device_id'] = $device['device_id'];
 // read the 802.1D bridge address and set as MAC in database
 $mac_raw = snmp_get($device, 'dot1dBaseBridgeAddress.0', '-Oqv', 'RSTP-MIB');
 // read Time as timetics (in hundredths of a seconds) since last topology change and convert to seconds
 $time_since_change = snmp_get($device, 'dot1dStpTimeSinceTopologyChange.0', '-Ovt', 'RSTP-MIB');
 if ($time_since_change > '100') {
     $time_since_change = substr($time_since_change, 0, -2);
     // convert to seconds since change
 } else {
     $time_since_change = '0';
 }
 $stp['timeSinceTopologyChange'] = $time_since_change;
 // designated root is stored in format 2 octet bridge priority + MAC address, so we need to normalize it
 $dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[0]['dot1dStpDesignatedRoot']));
 $dr = substr($dr, -12);
 //remove first two octets
 $stp['designatedRoot'] = $dr;
 // normalize the MAC
 $mac_array = explode(':', $mac_raw);
 foreach ($mac_array as &$octet) {
Example #13
0
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$oids = snmpwalk_cache_oid($device, 'isDeviceConfigTable', array(), 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceMonitorTemperatureTable', $oids, 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceConfigTemperatureTable', $oids, 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceMonitorHumidityTable', $oids, 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceConfigHumidityTable', $oids, 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceMonitorDigitalInTable', $oids, 'ISPRO-MIB');
$oids = snmpwalk_cache_oid($device, 'isDeviceConfigDigitalInTable', $oids, 'ISPRO-MIB');
// isConfigTemperatureUnit.0 = INTEGER: celsius(1)
$isConfigTemperatureUnit = snmp_get($device, 'isConfigTemperatureUnit.0', '-Oqv', 'ISPRO-MIB');
foreach ($oids as $index => $entry) {
    // Skip if this sensor has been disabled for display in the web interface
    if ($entry['isDeviceConfigDisplay'] == 'enabled') {
        // Temperature
        // isDeviceConfigTemperatureIndex.1 = INTEGER: 1
        // isDeviceMonitorTemperatureName.1 = STRING: "Temperature1"
        // isDeviceMonitorTemperature.1 = INTEGER: 3121
        // isDeviceConfigTemperatureName.1 = STRING: "Temperature1"
        $descr = $entry['isDeviceMonitorTemperatureName'];
        $oid = ".1.3.6.1.4.1.19011.1.3.2.1.3.1.1.1.3.{$index}";
        $value = $entry['isDeviceMonitorTemperature'];
        // Warning/Critical limits can be enabled/disabled in the web interface. Use them as supplied if enabled, calculate our own if not enabled.
        //
        // isDeviceConfigTemperatureLowWarning.1 = INTEGER: 2300
        // isDeviceConfigTemperatureLowCritical.1 = INTEGER: 2000
Example #14
0
<?php

// Simple hard-coded poller for Fortinet Fortigate
// Yes, it really can be this simple.
echo "Fortigate MemPool";
$mempool['perc'] = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemUsage.0", "-OvQ");
$mempool['total'] = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemCapacity.0", "-OvQ");
$mempool['used'] = $mempool['total'] * ($mempool['perc'] / 100);
$mempool['free'] = $mempool['total'] - $mempool['used'];
echo "(U: " . $mempool['used'] . " T: " . $mempool['total'] . " F: " . $mempool['free'] . ") ";
Example #15
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
#NS-ROOT-MIB::sysHardwareVersionDesc.0 = STRING: "7000 v1 6*EZ+2*EM"
#NS-ROOT-MIB::sysBuildVersion.0 = STRING: "NetScaler NS8.1: Build 69.4, Date: Jan 28 2010, 02:00:43  "
$hardware = str_replace("\"", "", snmp_get($device, "sysHardwareVersionDesc.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
$version = str_replace("\"", "", snmp_get($device, "sysBuildVersion.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
$serial = str_replace("\"", "", snmp_get($device, "sysHardwareSerialNumber.0", "-Osqv", "SNMPv2-MIB:NS-ROOT-MIB", mib_dirs('citrix')));
list($version, $features) = explode(":", $version);
list(, $version) = explode(" ", $version);
list($features) = explode(",", trim($features));
// EOF
Example #16
0
                    $states = array(array($state_index_id, 'unknown', 0, 0, 3), array($state_index_id, 'ready', 1, 1, 0), array($state_index_id, 'failed', 1, 2, 2), array($state_index_id, 'online', 1, 3, 1), array($state_index_id, 'offline', 1, 4, 2), array($state_index_id, 'degraded', 1, 6, 2), array($state_index_id, 'verifying', 1, 7, 1), array($state_index_id, 'resynching', 1, 15, 1), array($state_index_id, 'regenerating', 1, 16, 1), array($state_index_id, 'failedRedundancy', 1, 18, 2), array($state_index_id, 'rebuilding', 1, 24, 1), array($state_index_id, 'formatting', 1, 26, 1), array($state_index_id, 'reconstructing', 1, 32, 1), array($state_index_id, 'initializing', 1, 35, 1), array($state_index_id, 'backgroundInit', 1, 36, 1), array($state_index_id, 'permanentlyDegraded', 1, 52, 2));
                } elseif ($state_name == 'batteryState') {
                    $states = array(array($state_index_id, 'ready', 0, 1, 0), array($state_index_id, 'failed', 1, 2, 2), array($state_index_id, 'degraded', 1, 6, 2), array($state_index_id, 'reconditioning', 1, 7, 1), array($state_index_id, 'high', 1, 9, 1), array($state_index_id, 'low', 1, 10, 1), array($state_index_id, 'charging', 1, 12, 1), array($state_index_id, 'missing', 1, 21, 2), array($state_index_id, 'learning', 1, 36, 1));
                }
                foreach ($states as $value) {
                    $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                    dbInsert($insert, 'state_translations');
                }
            }
            foreach ($temp as $index => $entry) {
                if (strpos($index, '54.') === false) {
                    //Because Dell is buggy
                    if ($state_name == 'intrusionStatus') {
                        $descr = $tablevalue[3];
                    } elseif ($state_name == 'batteryState') {
                        $descr = str_replace('"', "", snmp_get($device, "batteryConnectionControllerName." . $index . "", "-Ovqn", $tablevalue[4])) . ' - ' . $temp[$index][$tablevalue[3]];
                    } elseif ($state_name == 'arrayDiskState') {
                        $descr = str_replace('"', "", snmp_get($device, "arrayDiskEnclosureConnectionEnclosureName." . $index . "", "-Ovqn", $tablevalue[4])) . ' - ' . $temp[$index][$tablevalue[3]];
                    } else {
                        $descr = clean($temp[$index][$tablevalue[3]]);
                        // Use clean as virtualDiskDeviceName is user defined
                    }
                    //Discover Sensors
                    discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index);
                    //Create Sensor To State Index
                    create_sensor_to_state_index($device, $state_name, $index);
                }
            }
        }
    }
}
Example #17
0
<?php

echo " EXTREME-BASE-MIB ";
if ($device['os'] == 'xos') {
    // Power Usage
    $descr = "Power Usage";
    $oid = "1.3.6.1.4.1.1916.1.1.1.40.1.0";
    // extremeSystemPowerUsage
    $value = snmp_get($device, $oid, '-Oqv', 'EXTREME-BASE-MIB');
    $divisor = "1000";
    if (is_numeric($value)) {
        $value = $value / $divisor;
        // Nasty hack to divide the first value by 1000 since the divisor only works for polling after the sensor has been added
        discover_sensor($valid['sensor'], 'power', $device, $oid, '1', 'extreme-power', $descr, $divisor, 1, null, null, null, null, $value);
        // No limits have been specified since all equipment is different and will use different amount of Watts
    }
}
// EOF
Example #18
0
*/
$sysdescr_value = snmp_get($device, "sysDescr.0", "-Ovq");
if (strpos($sysdescr_value, 'IBM Networking Operating System') !== false) {
    $hardware = str_replace("IBM Networking Operating System", "", $sysdescr_value);
    if (strpos($sysdescr_value, 'G8052') !== false) {
        $version = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq"), '" ');
        $serial = trim(snmp_get($device, ".1.3.6.1.4.1.26543.100.100.14.9.0", "-Ovq"), '" ');
    }
    if (strpos($sysdescr_value, 'G8316') !== false) {
        $version = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq"), '" ');
        $serial = trim(snmp_get($device, ".1.3.6.1.4.1.20301.100.100.14.9.0", "-Ovq"), '" ');
    }
    if (strpos($sysdescr_value, 'G8264CS') !== false) {
        $version = trim(snmp_get($device, ".1.3.6.1.4.1.20301.2.7.15.1.1.1.10.0", "-Ovq"), '" ');
        $serial = trim(snmp_get($device, ".1.3.6.1.4.1.20301.100.100.14.9.0", "-Ovq"), '" ');
    }
    if (strpos($sysdescr_value, 'G8264-T') !== false) {
        $version = trim(snmp_get($device, ".1.3.6.1.4.1.20301.2.7.13.1.1.1.10.0", "-Ovq"), '" ');
        $serial = trim(snmp_get($device, ".1.3.6.1.4.1.20301.100.100.14.9.0", "-Ovq"), '" ');
    }
    if (empty($version)) {
        $version = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq"), '" ');
    }
    if (empty($serial)) {
        $serial = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.11.1", "-Ovq"), '" ');
    }
} elseif (strpos($sysdescr_value, 'IBM Flex System Fabric') !== false) {
    $hardware = str_replace("IBM Flex System Fabric", "", $sysdescr_value);
    $version = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq"), '" ');
    $serial = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.11.1", "-Ovq"), '" ');
}
Example #19
0
<?php

// ...7.0 = STRING: "MFG:Hewlett-Packard;CMD:PJL,MLC,BIDI-ECP,PCL,POSTSCRIPT,PCLXL;MDL:hp LaserJet 1320 series;CLS:PRINTER;DES:Hewlett-Packard LaserJet 1320 series;MEM:9MB;COMMENT:RES=1200x1;"
$jdinfo = explode(';', trim(snmp_get($device, '1.3.6.1.4.1.11.2.3.9.1.1.7.0', '-OQv', '', ''), '" '));
foreach ($jdinfo as $jdi) {
    list($key, $value) = explode(':', $jdi);
    $jetdirect[$key] = $value;
}
$hardware = $jetdirect['DES'];
if ($hardware == '') {
    $hardware = $jetdirect['DESCRIPTION'];
}
if ($hardware == '') {
    $hardware = $jetdirect['MODEL'];
}
// Strip off useless brand fields
$hardware = str_replace('HP ', '', $hardware);
$hardware = str_replace('Hewlett-Packard ', '', $hardware);
$hardware = str_ireplace(' Series', '', $hardware);
$hardware = ucfirst($hardware);
Example #20
0
/*
 * LibreNMS
 *
 * Copyright (c) 2015 Steve Calvário <https://github.com/Calvario/>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if ($device['os'] == 'dsm') {
    echo 'DSM UPS Load';
    // UPS Device Manufacturer, example return : SNMPv2-SMI::enterprises.6574.4.1.2.0 = STRING: "American Power Conversion"
    $ups_device_manufacturer_oid = '.1.3.6.1.4.1.6574.4.1.2.0';
    $ups_device_manufacturer = str_replace('"', '', snmp_get($device, $ups_device_manufacturer_oid, '-Oqv'));
    // Too long name for APC
    if ($ups_device_manufacturer == 'American Power Conversion') {
        $ups_device_manufacturer = 'APC';
    }
    // UPS Device Model, example return : SNMPv2-SMI::enterprises.6574.4.1.1.0 = STRING: "Back-UPS RS 900G"
    $ups_device_model_oid = '.1.3.6.1.4.1.6574.4.1.1.0';
    $ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model_oid, '-Oqv'));
    // UPS Load Value, example return : SNMPv2-SMI::enterprises.6574.4.2.12.1.0 = Opaque: Float: 4.000000
    $ups_load_oid = '.1.3.6.1.4.1.6574.4.2.12.1.0';
    $ups_load = snmp_get($device, $ups_load_oid, '-Oqv');
    if (is_numeric($ups_load)) {
        discover_sensor($valid['sensor'], 'load', $device, $ups_load_oid, 0, 'snmp', $ups_device_manufacturer . ' ' . $ups_device_model . ' - UPS Load', '1', '1', 0, null, null, 100, intval($ups_load));
    }
}
//end if
Example #21
0
function first_oid_match($device, $list)
{
    foreach ($list as $item) {
        $tmp = trim(snmp_get($device, $item, "-Ovq"), '" ');
        if (!empty($tmp)) {
            return $tmp;
        }
    }
}
Example #22
0
<?php

$proc = substr(snmp_get($device, "swCpuUsage.0", "-Ovq", "DMswitch-MIB"), 0, 2);
Example #23
0
<?php

$version = trim(snmp_get($device, '1.3.6.1.4.1.14988.1.1.4.4.0', '-OQv', '', ''), '"');
if (strstr($poll_device['sysDescr'], 'RouterOS')) {
    $hardware = substr($poll_device['sysDescr'], 9);
}
$features = 'Level ' . trim(snmp_get($device, '1.3.6.1.4.1.14988.1.1.4.3.0', '-OQv', '', ''), '"');
Example #24
0
 * the source code distribution for details.
 */
global $config;
$oids = 'entPhysicalModelName.1 entPhysicalSoftwareRev.1 entPhysicalSerialNum.1';
$data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB');
if (isset($data[1]['entPhysicalSoftwareRev']) && $data[1]['entPhysicalSoftwareRev'] != '') {
    $version = $data[1]['entPhysicalSoftwareRev'];
}
if (isset($data[1]['entPhysicalName']) && $data[1]['entPhysicalName'] != '') {
    $hardware = $data[1]['entPhysicalName'];
}
if (isset($data[1]['entPhysicalModelName']) && $data[1]['entPhysicalModelName'] != '') {
    $hardware = $data[1]['entPhysicalModelName'];
}
if (empty($hardware)) {
    $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
}
$stats = snmpwalk_cache_oid($device, "bsnAPEntry", $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$radios = snmpwalk_cache_oid($device, "bsnAPIfEntry", $radios, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$APstats = snmpwalk_cache_oid($device, 'bsnApIfNoOfUsers', $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
$loadParams = snmpwalk_cache_oid($device, "bsnAPIfLoadChannelUtilization", $loadParams, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$interferences = snmpwalk_cache_oid($device, "bsnAPIfInterferencePower", $interferences, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb');
$numAccessPoints = count($stats);
$numClients = 0;
foreach ($APstats as $key => $value) {
    $numClients += $value['bsnApIfNoOfUsers'];
}
$rrd_def = array('DS:NUMAPS:GAUGE:600:0:12500000000', 'DS:NUMCLIENTS:GAUGE:600:0:12500000000');
$fields = array('NUMAPS' => $numAccessPoints, 'NUMCLIENTS' => $numClients);
$tags = compact('rrd_def');
data_update($device, 'ciscowlc', $tags, $fields);
Example #25
0
    } else {
        $limits = array();
    }
    $temperature_oid = ".1.3.6.1.4.1.18248.20.1.2.1.1.2.1";
    discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, 1, 'papouch-th2e', "Temperature", $scale, $temperature * $scale, $limits);
}
$temperature = snmp_get($device, "1.3.6.1.4.1.18248.20.1.2.1.1.2.3", "-Oqv");
if (is_numeric($temperature) && $temperature > 0) {
    if (snmp_get($device, "1.3.6.1.4.1.18248.20.1.3.1.1.1.3", "-Oqv")) {
        $limits = array('limit_low' => snmp_get($device, "1.3.6.1.4.1.18248.20.1.3.1.1.2.3", "-Oqv") * $scale);
        // The MIB is invalid and I can't find the max value in snmpwalk :[ *sigh*
        // Hysteresis parameter value is in SNMPv2-SMI::enterprises.18248.20.1.3.1.1.3.3 = INTEGER: 100
    } else {
        $limits = array();
    }
    $temperature_oid = ".1.3.6.1.4.1.18248.20.1.2.1.1.2.3";
    discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, "3", 'papouch-th2e', "Dew Point", $scale, $temperature * $scale, $limits);
}
$humidity = snmp_get($device, "1.3.6.1.4.1.18248.20.1.2.1.1.2.1", "-Oqv");
if (is_numeric($humidity) && $humidity > 0) {
    if (snmp_get($device, "1.3.6.1.4.1.18248.20.1.2.1.1.1.2", "-Oqv")) {
        $limits = array('limit_low' => snmp_get($device, "1.3.6.1.4.1.18248.20.1.3.1.1.2.2", "-Oqv") * $scale);
        // The MIB is invalid and I can't find the max value in snmpwalk :[ *sigh*
        // Hysteresis parameter value is in SNMPv2-SMI::enterprises.18248.20.1.3.1.1.3.2 = INTEGER: 100
    } else {
        $limits = array();
    }
    $humidity_oid = ".1.3.6.1.4.1.18248.20.1.2.1.1.2.2";
    discover_sensor($valid['sensor'], 'humidity', $device, $humidity_oid, 1, 'papouch-th2e', "Humidity", $scale, $humidity * $scale, $limits);
}
// EOF
Example #26
0
<?php

/*
 * LibreNMS
 *
 * Copyright (c) 2016 Søren Friis Rosiak <*****@*****.**> 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if ($device['os'] == 'riverbed') {
    $tables = array(array('systemHealth.0', '1.3.6.1.4.1.17163.1.1.2.7.0', 'systemHealth', 'System Health'), array('optServiceStatus.0', '1.3.6.1.4.1.17163.1.1.2.8.0', 'optServiceStatus', 'Optimization Service Status'));
    foreach ($tables as $tablevalue) {
        $temp = snmp_get($device, $tablevalue[0], "-Ovqe", "STEELHEAD-MIB");
        $oid = $tablevalue[1];
        if (is_numeric($temp)) {
            //Create State Index
            $state_name = $tablevalue[2];
            $state_index_id = create_state_index($state_name);
            //Create State Translation
            if ($state_index_id !== null) {
                if ($state_name == 'systemHealth') {
                    $states = array(array($state_index_id, 'healthy', 0, 10000, 0), array($state_index_id, 'degraded', 0, 30000, 1), array($state_index_id, 'admissionControl', 0, 31000, 1), array($state_index_id, 'critical', 0, 50000, 2));
                } else {
                    $states = array(array($state_index_id, 'none', 0, 0, 3), array($state_index_id, 'unmanaged', 0, 1, 3), array($state_index_id, 'running', 0, 2, 0), array($state_index_id, 'sentCom1', 0, 3, 1), array($state_index_id, 'sentTerm1', 0, 4, 1), array($state_index_id, 'sentTerm2', 0, 5, 1), array($state_index_id, 'sentTerm3', 0, 6, 1), array($state_index_id, 'pending', 0, 7, 1), array($state_index_id, 'stopped', 0, 8, 2));
                }
                foreach ($states as $value) {
                    $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                    dbInsert($insert, 'state_translations');
Example #27
0
     $ip_len = 4;
     $ip_ver = 'ipv4';
 }
 $ip_cast = 1;
 if ($peer_afi['safi'] == 'multicast') {
     $ip_cast = 2;
 } else {
     if ($peer_afi['safi'] == 'unicastAndMulticast') {
         $ip_cast = 3;
     } else {
         if ($peer_afi['safi'] == 'vpn') {
             $ip_cast = 128;
         }
     }
 }
 $check = snmp_get($device, 'cbgpPeer2AcceptedPrefixes.' . $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast, '', 'CISCO-BGP4-MIB', $config['mibdir']);
 if (!empty($check)) {
     $cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast;
     $cbgp_data_tmp = snmp_get_multi($device, ' cbgpPeer2AcceptedPrefixes.' . $cgp_peer_identifier . ' cbgpPeer2DeniedPrefixes.' . $cgp_peer_identifier . ' cbgpPeer2PrefixAdminLimit.' . $cgp_peer_identifier . ' cbgpPeer2PrefixThreshold.' . $cgp_peer_identifier . ' cbgpPeer2PrefixClearThreshold.' . $cgp_peer_identifier . ' cbgpPeer2AdvertisedPrefixes.' . $cgp_peer_identifier . ' cbgpPeer2SuppressedPrefixes.' . $cgp_peer_identifier . ' cbgpPeer2WithdrawnPrefixes.' . $cgp_peer_identifier, '-OQUs', 'CISCO-BGP4-MIB', $config['mibdir']);
     $ident = "{$ip_ver}.\"" . $peer['bgpPeerIdentifier'] . '"' . '.' . $ip_type . '.' . $ip_cast;
     unset($cbgp_data);
     $temp_keys = array_keys($cbgp_data_tmp);
     unset($temp_data);
     $temp_data['cbgpPeer2AcceptedPrefixes'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2AcceptedPrefixes'];
     $temp_data['cbgpPeer2DeniedPrefixes'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2DeniedPrefixes'];
     $temp_data['cbgpPeer2PrefixAdminLimit'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2PrefixAdminLimit'];
     $temp_data['cbgpPeer2PrefixThreshold'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2PrefixThreshold'];
     $temp_data['cbgpPeer2PrefixClearThreshold'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2PrefixClearThreshold'];
     $temp_data['cbgpPeer2AdvertisedPrefixes'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2AdvertisedPrefixes'];
     $temp_data['cbgpPeer2SuppressedPrefixes'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2SuppressedPrefixes'];
     $temp_data['cbgpPeer2WithdrawnPrefixes'] = $cbgp_data_tmp[$temp_keys[0]]['cbgpPeer2WithdrawnPrefixes'];
Example #28
0
<?php

$sysObjectId = snmp_get($device, 'SNMPv2-MIB::sysObjectID.0', '-Ovqn');
switch ($sysObjectId) {
    case '.1.3.6.1.4.1.674.10895.3031':
        /*
         * Devices supported:
         * Dell Powerconnect 55xx
         */
        $proc = snmp_get($device, $processor['processor_oid'], '-O Uqnv', '""');
        break;
    default:
        $values = trim(snmp_get($device, 'dellLanExtension.6132.1.1.1.1.4.4.0', '-OvQ', 'Dell-Vendor-MIB'), '"');
        preg_match('/5 Sec \\((.*)%\\),.*1 Min \\((.*)%\\),.*5 Min \\((.*)%\\)$/', $values, $matches);
        $proc = $matches[3];
}
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo " ALCATEL-IND1-HEALTH-MIB ";
$descr = "Chassis Temperature";
$oid = ".1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.17.0";
$value = snmp_get($device, $oid, "-Oqv");
if (is_numeric($value) && $value > 0) {
    discover_sensor($valid['sensor'], 'temperature', $device, $oid, 1, 'alcatel-device', $descr, 1, 1, NULL, NULL, NULL, NULL, $value);
}
// EOF
Example #30
0
<?php

///
//  Hardcoded discovery of cpu usage on HP Procurve devices.
///
//  STATISTICS-MIB::hpSwitchCpuStat.0 = INTEGER: 10
if ($device['os'] == "procurve") {
    echo "Procurve : ";
    $descr = "Processor";
    $usage = snmp_get($device, ".1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "-OQUvs", "STATISTICS-MIB", mib_dirs('hp'));
    if (is_numeric($usage)) {
        discover_processor($valid['processor'], $device, "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "0", "procurve-fixed", $descr, "1", $usage, NULL, NULL);
    }
}
unset($processors_array);