示例#1
0
<?php

$diskio_data = dbFetchRows('SELECT * FROM `ucd_diskio` WHERE `device_id`  = ?', array($device['device_id']));
if (count($diskio_data)) {
    $diskio_cache = array();
    $diskio_cache = snmpwalk_cache_oid($device, 'diskIOEntry', $diskio_cache, 'UCD-DISKIO-MIB');
    foreach ($diskio_data as $diskio) {
        $index = $diskio['diskio_index'];
        $entry = $diskio_cache[$index];
        echo $diskio['diskio_descr'] . ' ';
        d_echo($entry);
        $tags = array('rrd_name' => array('ucd_diskio', $diskio['diskio_descr']), 'rrd_def' => array('DS:read:DERIVE:600:0:125000000000', 'DS:written:DERIVE:600:0:125000000000', 'DS:reads:DERIVE:600:0:125000000000', 'DS:writes:DERIVE:600:0:125000000000'), 'descr' => $diskio['diskio_descr']);
        $fields = array('read' => $entry['diskIONReadX'], 'written' => $entry['diskIONWrittenX'], 'reads' => $entry['diskIOReads'], 'writes' => $entry['diskIOWrites']);
        data_update($device, 'ucd_diskio', $tags, $fields);
    }
    //end foreach
    echo "\n";
}
//end if
unset($diskio_data);
unset($diskio_cache);
示例#2
0
                d_echo("\n\nAdjacency Component: " . $key . "\n");
                d_echo("    Label: " . $array['label'] . "\n");
                d_echo("    Index: " . $array['index'] . "\n");
                d_echo("    Status: " . $array['status'] . "\n");
                d_echo("    Message: " . $array['error'] . "\n");
            } elseif ($array['otvtype'] == 'endpoint') {
                $count = 0;
                $endpoint = $array['endpoint'];
                if (isset($count_mac[$endpoint])) {
                    $count = $count_mac[$endpoint];
                }
                // Let's log some debugging
                d_echo("\n\nEndpoint Component: " . $key . "\n");
                d_echo("    Label: " . $array['label'] . "\n");
                d_echo("    MAC Count: " . $count . "\n");
                $rrd_name = array('cisco', 'otv', $endpoint, 'mac');
                $rrd_def = 'DS:count:GAUGE:600:0:U';
                $fields = array('count' => $count);
                $tags = compact('endpoint', 'rrd_name', 'rrd_def');
                data_update($device, 'cisco-otv-mac', $tags, $fields);
            }
            // End If
        }
        // End foreach components
        // Write the Components back to the DB.
        $component->setComponentPrefs($device['device_id'], $components);
    }
    // end if count components
    // Clean-up after yourself!
    unset($components, $component, $module);
}
示例#3
0
    d_echo("  radionum: {$radionum}\n");
    d_echo("  type: {$type}\n");
    d_echo("  channel: {$channel}\n");
    d_echo("  txpow: {$txpow}\n");
    d_echo("  radioutil: {$radioutil}\n");
    d_echo("  numasoclients: {$numasoclients}\n");
    d_echo("  interference: {$interference}\n");
    // if there is a numeric channel, assume the rest of the data is valid, I guess
    if (!is_numeric($channel)) {
        continue;
    }
    $rrd_name = array('arubaap', $name . $radionum);
    $rrd_def = array('DS:channel:GAUGE:600:0:200', 'DS:txpow:GAUGE:600:0:200', 'DS:radioutil:GAUGE:600:0:100', 'DS:nummonclients:GAUGE:600:0:500', 'DS:nummonbssid:GAUGE:600:0:200', 'DS:numasoclients:GAUGE:600:0:500', 'DS:interference:GAUGE:600:0:2000');
    $fields = array('channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'nummonclients' => $nummonclients, 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference);
    $tags = compact('name', 'radionum', 'rrd_name', 'rrd_def');
    data_update($device, 'arubaap', $tags, $fields);
    $foundid = 0;
    for ($z = 0; $z < sizeof($ap_db); $z++) {
        if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) {
            $foundid = $ap_db[$z]['accesspoint_id'];
            $ap_db[$z]['seen'] = 1;
            continue;
        }
    }
    if ($foundid == 0) {
        $ap_id = dbInsert(array('device_id' => $device['device_id'], 'name' => $name, 'radio_number' => $radionum, 'type' => $type, 'mac_addr' => $mac, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points');
    } else {
        dbUpdate(array('mac_addr' => $mac, 'type' => $type, 'deleted' => 0, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points', '`accesspoint_id` = ?', array($foundid));
    }
}
//end foreach
示例#4
0
        $rrd_name = array('sla', $sla_nr);
        $rrd_def = 'DS:rtt:GAUGE:600:0:300000';
        $tags = compact('sla_nr', 'rrd_name', 'rrd_def');
        data_update($device, 'sla', $tags, $fields);
        // Let's gather some per-type fields.
        switch ($rtt_type) {
            case 'jitter':
                $jitter = array('PacketLossSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.26'][$sla_nr], 'PacketLossDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.27'][$sla_nr], 'PacketOutOfSequence' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.28'][$sla_nr], 'PacketMIA' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.29'][$sla_nr], 'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.30'][$sla_nr], 'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla_nr] / 100, 'ICPIF' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.43'][$sla_nr], 'OWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.49'][$sla_nr], 'OWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.50'][$sla_nr], 'AvgSDJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.47'][$sla_nr], 'AvgDSJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.48'][$sla_nr]);
                $rrd_name = array('sla', $sla_nr, $rtt_type);
                $rrd_def = array('DS:PacketLossSD:GAUGE:600:0:U', 'DS:PacketLossDS:GAUGE:600:0:U', 'DS:PacketOutOfSequence:GAUGE:600:0:U', 'DS:PacketMIA:GAUGE:600:0:U', 'DS:PacketLateArrival:GAUGE:600:0:U', 'DS:MOS:GAUGE:600:0:U', 'DS:ICPIF:GAUGE:600:0:U', 'DS:OWAvgSD:GAUGE:600:0:U', 'DS:OWAvgDS:GAUGE:600:0:U', 'DS:AvgSDJ:GAUGE:600:0:U', 'DS:AvgDSJ:GAUGE:600:0:U');
                $tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
                data_update($device, 'sla', $tags, $jitter);
                $fields = array_merge($fields, $jitter);
                break;
            case 'icmpjitter':
                $icmpjitter = array('PacketLoss' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.26'][$sla_nr], 'PacketOosSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.28'][$sla_nr], 'PacketOosDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.29'][$sla_nr], 'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.32'][$sla_nr], 'JitterAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.45'][$sla_nr], 'JitterAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.46'][$sla_nr], 'LatencyOWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.47'][$sla_nr], 'LatencyOWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.48'][$sla_nr], 'JitterIAJOut' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.49'][$sla_nr], 'JitterIAJIn' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.50'][$sla_nr]);
                $rrd_name = array('sla', $sla_nr, $rtt_type);
                $rrd_def = array('DS:PacketLoss:GAUGE:600:0:U', 'DS:PacketOosSD:GAUGE:600:0:U', 'DS:PacketOosDS:GAUGE:600:0:U', 'DS:PacketLateArrival:GAUGE:600:0:U', 'DS:JitterAvgSD:GAUGE:600:0:U', 'DS:JitterAvgDS:GAUGE:600:0:U', 'DS:LatencyOWAvgSD:GAUGE:600:0:U', 'DS:LatencyOWAvgDS:GAUGE:600:0:U', 'DS:JitterIAJOut:GAUGE:600:0:U', 'DS:JitterIAJIn:GAUGE:600:0:U');
                $tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
                data_update($device, 'sla', $tags, $icmpjitter);
                $fields = array_merge($fields, $icmpjitter);
                break;
        }
        d_echo("The following datasources were collected for #" . $sla['sla_nr'] . ":\n");
        d_echo($fields);
        // Update the DB if necessary
        if (count($update) > 0) {
            $updated = dbUpdate($update, 'slas', '`sla_id` = ?', array($sla['sla_id']));
        }
    }
}
示例#5
0
function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
{
    $usedoids = array();
    $deviceoids = array();
    foreach ($oids as $index => $array) {
        foreach ($array as $obj => $val) {
            // build up the device_oid row for saving into the database
            $numvalue = is_numeric($val) ? $val + 0 : 0;
            $deviceoids[] = array('device_id' => $device['device_id'], 'oid' => $mibdef[$obj]['oid'] . "." . $index, 'module' => $mibdef[$obj]['module'], 'mib' => $mibdef[$obj]['mib'], 'object_type' => $obj, 'value' => $val, 'numvalue' => $numvalue);
            $type = oid_rrd_type($obj, $mibdef);
            if ($type === false) {
                continue;
            }
            $usedoids[$index][$obj] = $val;
            $tags = array('rrd_def' => array("DS:mibval:{$type}"), 'rrd_name' => array($mibname, $mibdef[$obj]['shortname'], $index), 'rrd_oldname' => array($mibname, $mibdef[$obj]['object_type'], $index), 'index' => $index, 'oid' => $mibdef[$obj]['oid'], 'module' => $mibdef[$obj]['module'], 'mib' => $mibdef[$obj]['mib'], 'object_type' => $obj);
            data_update($device, 'mibval', $tags, $val);
        }
    }
    tag_graphs($mibname, $usedoids, $mibdef, $graphs);
    update_mib_graph_types($mibname, $usedoids, $mibdef, $graphs);
    // update database
    $columns = array('device_id', 'oid', 'module', 'mib', 'object_type', 'value', 'numvalue');
    update_db_table('device_oids', $columns, 2, $deviceoids);
}
示例#6
0
 * Copyright (c) 2015 Aaron Daniels <*****@*****.**>
 *
 * 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_group'] == "cisco") {
    // TODO: Need to test partial PRI.
    // Total
    $total = 0;
    foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.2.1.2.2.1.3", null) as $key => $value) {
        // 81 is the ifType for DS0's
        if ($value[''] == "81") {
            $total++;
        }
    }
    // Active
    $active = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.10.19.1.1.4.0", null);
    $active = $active['1.3.6.1.4.1.9.10.19.1.1.4.0'][''];
    if (isset($active) && $active != "" && $total != 0) {
        $rrd_def = array('DS:total:GAUGE:600:0:U', 'DS:active:GAUGE:600:0:U');
        $fields = array('total' => $total, 'active' => $active);
        $tags = compact('rrd_def');
        data_update($device, 'cisco-iospri', $tags, $fields);
        $graphs['cisco-iospri'] = true;
        echo " Cisco IOS PRI ";
    }
    unset($rrd_def, $total, $active, $fields, $tags);
}
示例#7
0
function poll_device($device, $options)
{
    global $config, $device, $polled_devices, $db_stats, $memcache;
    $attribs = get_dev_attribs($device['device_id']);
    $status = 0;
    unset($array);
    $device_start = microtime(true);
    // Start counting device poll time
    echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
    $ip = dnslookup($device);
    if (!empty($ip) && $ip != inet6_ntop($device['ip'])) {
        log_event('Device IP changed to ' . $ip, $device, 'system');
        $db_ip = inet_pton($ip);
        dbUpdate(array('ip' => $db_ip), 'devices', 'device_id=?', array($device['device_id']));
    }
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo '(' . $device['os_group'] . ')';
    }
    echo "\n";
    unset($poll_update);
    unset($poll_update_query);
    unset($poll_separator);
    $poll_update_array = array();
    $update_array = array();
    $host_rrd = $config['rrd_dir'] . '/' . $device['hostname'];
    if (!is_dir($host_rrd)) {
        mkdir($host_rrd);
        echo "Created directory : {$host_rrd}\n";
    }
    $address_family = snmpTransportToAddressFamily($device['transport']);
    $ping_response = isPingable($device['hostname'], $address_family, $attribs);
    $device_perf = $ping_response['db'];
    $device_perf['device_id'] = $device['device_id'];
    $device_perf['timestamp'] = array('NOW()');
    if (can_ping_device($attribs) === true && is_array($device_perf)) {
        dbInsert($device_perf, 'device_perf');
    }
    $device['pingable'] = $ping_response['result'];
    $ping_time = $ping_response['last_ping_timetaken'];
    $response = array();
    $status_reason = '';
    if ($device['pingable']) {
        $device['snmpable'] = isSNMPable($device);
        if ($device['snmpable']) {
            $status = '1';
            $response['status_reason'] = '';
        } else {
            echo 'SNMP Unreachable';
            $status = '0';
            $response['status_reason'] = 'snmp';
        }
    } else {
        echo 'Unpingable';
        $status = '0';
        $response['status_reason'] = 'icmp';
    }
    if ($device['status'] != $status) {
        $poll_update .= $poll_separator . "`status` = '{$status}'";
        $poll_separator = ', ';
        dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
        log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, $status == '1' ? 'up' : 'down');
    }
    if ($status == '1') {
        $graphs = array();
        $oldgraphs = array();
        // we always want the core module to be included
        include 'includes/polling/core.inc.php';
        if ($options['m']) {
            foreach (explode(',', $options['m']) as $module) {
                if (is_file('includes/polling/' . $module . '.inc.php')) {
                    include 'includes/polling/' . $module . '.inc.php';
                }
            }
        } else {
            foreach ($config['poller_modules'] as $module => $module_status) {
                if ($attribs['poll_' . $module] || $module_status && !isset($attribs['poll_' . $module])) {
                    $module_start = microtime(true);
                    include 'includes/polling/' . $module . '.inc.php';
                    $module_time = microtime(true) - $module_start;
                    echo "Runtime for polling module '{$module}': {$module_time}\n";
                    // save per-module poller stats
                    $tags = array('module' => $module, 'rrd_def' => 'DS:poller:GAUGE:600:0:U', 'rrd_name' => array('poller-perf', $module));
                    $fields = array('poller' => $module_time);
                    data_update($device, 'poller-perf', $tags, $fields);
                    // remove old rrd
                    $oldrrd = rrd_name($device['hostname'], array('poller', $module, 'perf'));
                    if (is_file($oldrrd)) {
                        unlink($oldrrd);
                    }
                } else {
                    if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] == '0') {
                        echo "Module [ {$module} ] disabled on host.\n";
                    } else {
                        echo "Module [ {$module} ] disabled globally.\n";
                    }
                }
            }
        }
        //end if
        if (!$options['m']) {
            // FIXME EVENTLOGGING -- MAKE IT SO WE DO THIS PER-MODULE?
            // This code cycles through the graphs already known in the database and the ones we've defined as being polled here
            // If there any don't match, they're added/deleted from the database.
            // Ideally we should hold graphs for xx days/weeks/polls so that we don't needlessly hide information.
            foreach (dbFetch('SELECT `graph` FROM `device_graphs` WHERE `device_id` = ?', array($device['device_id'])) as $graph) {
                if (isset($graphs[$graph['graph']])) {
                    $oldgraphs[$graph['graph']] = true;
                } else {
                    dbDelete('device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph['graph']));
                }
            }
            foreach ($graphs as $graph => $value) {
                if (!isset($oldgraphs[$graph])) {
                    echo '+';
                    dbInsert(array('device_id' => $device['device_id'], 'graph' => $graph), 'device_graphs');
                }
                echo $graph . ' ';
            }
        }
        //end if
        $device_end = microtime(true);
        $device_run = $device_end - $device_start;
        $device_time = substr($device_run, 0, 5);
        // Poller performance
        if (!empty($device_time)) {
            $tags = array('rrd_def' => 'DS:poller:GAUGE:600:0:U', 'module' => 'ALL');
            $fields = array('poller' => $device_time);
            data_update($device, 'poller-perf', $tags, $fields);
        }
        // Ping response
        if (can_ping_device($attribs) === true && !empty($ping_time)) {
            $tags = array('rrd_def' => 'DS:ping:GAUGE:600:0:65535');
            $fields = array('ping' => $ping_time);
            $update_array['last_ping'] = array('NOW()');
            $update_array['last_ping_timetaken'] = $ping_time;
            data_update($device, 'ping-perf', $tags, $fields);
        }
        $update_array['last_polled'] = array('NOW()');
        $update_array['last_polled_timetaken'] = $device_time;
        // echo("$device_end - $device_start; $device_time $device_run");
        echo "Polled in {$device_time} seconds\n";
        d_echo('Updating ' . $device['hostname'] . "\n");
        d_echo($update_array);
        $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id']));
        if ($updated) {
            echo "UPDATED!\n";
        }
        unset($storage_cache);
        // Clear cache of hrStorage ** MAYBE FIXME? **
        unset($cache);
        // Clear cache (unify all things here?)
    }
    //end if
}
if ($device['os_group'] == 'cisco') {
    $data = snmpwalk_cache_oid($device, 'cipSecGlobalStats', null, 'CISCO-IPSEC-FLOW-MONITOR-MIB');
    $data = $data[0];
    // Use HC Counters if they exist
    if (is_numeric($data['cipSecGlobalHcInOctets'])) {
        $data['cipSecGlobalInOctets'] = $data['cipSecGlobalHcInOctets'];
    }
    if (is_numeric($data['cipSecGlobalHcOutOctets'])) {
        $data['cipSecGlobalOutOctets'] = $data['cipSecGlobalHcOutOctets'];
    }
    if (is_numeric($data['cipSecGlobalHcInDecompOctets'])) {
        $data['cipSecGlobalInDecompOctets'] = $data['cipSecGlobalHcInDecompOctets'];
    }
    if (is_numeric($data['cipSecGlobalHcOutUncompOctets'])) {
        $data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets'];
    }
    if ($data['cipSecGlobalActiveTunnels']) {
        $rrd_def = array('DS:Tunnels:GAUGE:600:0:U', 'DS:InOctets:COUNTER:600:0:100000000000', 'DS:OutOctets:COUNTER:600:0:100000000000', 'DS:InDecompOctets:COUNTER:600:0:100000000000', 'DS:OutUncompOctets:COUNTER:600:0:100000000000', 'DS:InPkts:COUNTER:600:0:100000000000', 'DS:OutPkts:COUNTER:600:0:100000000000', 'DS:InDrops:COUNTER:600:0:100000000000', 'DS:InReplayDrops:COUNTER:600:0:100000000000', 'DS:OutDrops:COUNTER:600:0:100000000000', 'DS:InAuths:COUNTER:600:0:100000000000', 'DS:OutAuths:COUNTER:600:0:100000000000', 'DS:InAuthFails:COUNTER:600:0:100000000000', 'DS:OutAuthFails:COUNTER:600:0:100000000000', 'DS:InDencrypts:COUNTER:600:0:100000000000', 'DS:OutEncrypts:COUNTER:600:0:100000000000', 'DS:InDecryptFails:COUNTER:600:0:100000000000', 'DS:OutEncryptFails:COUNTER:600:0:100000000000', 'DS:ProtocolUseFails:COUNTER:600:0:100000000000', 'DS:NoSaFails:COUNTER:600:0:100000000000', 'DS:SysCapFails:COUNTER:600:0:100000000000');
        $fields = array('Tunnels' => $data['cipSecGlobalActiveTunnels'], 'InOctets' => $data['cipSecGlobalInOctets'], 'OutOctets' => $data['cipSecGlobalOutOctets'], 'InDecompOctets' => $data['cipSecGlobalInDecompOctets'], 'OutUncompOctets' => $data['cipSecGlobalOutUncompOctets'], 'InPkts' => $data['cipSecGlobalInPkts'], 'OutPkts' => $data['cipSecGlobalOutPkts'], 'InDrops' => $data['cipSecGlobalInDrops'], 'InReplayDrops' => $data['cipSecGlobalInReplayDrops'], 'OutDrops' => $data['cipSecGlobalOutDrops'], 'InAuths' => $data['cipSecGlobalInAuths'], 'OutAuths' => $data['cipSecGlobalOutAuths'], 'InAuthFails' => $data['cipSecGlobalInAuthFails'], 'OutAuthFails' => $data['cipSecGlobalOutAuthFails'], 'InDencrypts' => $data['cipSecGlobalInDecrypts'], 'OutEncrypts' => $data['cipSecGlobalOutEncrypts'], 'InDecryptFails' => $data['cipSecGlobalInDecryptFails'], 'OutEncryptFails' => $data['cipSecGlobalOutEncryptFails'], 'ProtocolUseFails' => $data['cipSecGlobalProtocolUseFails'], 'NoSaFails' => $data['cipSecGlobalNoSaFails'], 'SysCapFails' => $data['cipSecGlobalSysCapFails']);
        $tags = compact('rrd_def');
        data_update($device, 'cipsec_flow', $tags, $fields);
        $graphs['cipsec_flow_tunnels'] = true;
        $graphs['cipsec_flow_pkts'] = true;
        $graphs['cipsec_flow_bits'] = true;
        $graphs['cipsec_flow_stats'] = true;
        echo ' cipsec_flow';
    }
    //end if
    unset($data, $rrd_def);
}
//end if
示例#9
0
<?php

// CISCO-VPDN-MGMT-MIB::cvpdnTunnelTotal.0 = Gauge32: 0 tunnels
// CISCO-VPDN-MGMT-MIB::cvpdnSessionTotal.0 = Gauge32: 0 users
// CISCO-VPDN-MGMT-MIB::cvpdnDeniedUsersTotal.0 = Counter32: 0 attempts
// CISCO-VPDN-MGMT-MIB::cvpdnSystemTunnelTotal.l2tp = Gauge32: 437 tunnels
// CISCO-VPDN-MGMT-MIB::cvpdnSystemSessionTotal.l2tp = Gauge32: 1029 sessions
// CISCO-VPDN-MGMT-MIB::cvpdnSystemDeniedUsersTotal.l2tp = Counter32: 0 attempts
// CISCO-VPDN-MGMT-MIB::cvpdnSystemClearSessions.0 = INTEGER: none(1)
if ($device['os_group'] == 'cisco') {
    $data = snmpwalk_cache_oid($device, 'cvpdnSystemEntry', null, 'CISCO-VPDN-MGMT-MIB');
    foreach ($data as $type => $vpdn) {
        if ($vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) {
            $rrd_name = array('vpdn', $type);
            $rrd_def = array('DS:tunnels:GAUGE:600:0:U', 'DS:sessions:GAUGE:600:0:U', 'DS:denied:COUNTER:600:0:100000');
            $fields = array('tunnels' => $vpdn['cvpdnSystemTunnelTotal'], 'sessions' => $vpdn['cvpdnSystemSessionTotal'], 'denied' => $vpdn['cvpdnSystemDeniedUsersTotal']);
            $tags = compact('type', 'rrd_name', 'rrd_def');
            data_update($device, 'vpdn', $tags, $fields);
            $graphs['vpdn_sessions_' . $type] = true;
            $graphs['vpdn_tunnels_' . $type] = true;
            echo " Cisco VPDN ({$type}) ";
        }
    }
    unset($data, $vpdn, $type, $rrd_filename);
}
//end if
示例#10
0
<?php

$fnSysVersion = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysVersion.0', '-Ovq');
$serial = snmp_get($device, 'ENTITY-MIB::entPhysicalSerialNum.1', '-Ovq');
$version = preg_replace('/(.+),(.+),(.+)/', '\\1||\\2||\\3', $fnSysVersion);
list($version, $features) = explode('||', $version);
if (isset($rewrite_fortinet_hardware[$poll_device['sysObjectID']])) {
    $hardware = $rewrite_fortinet_hardware[$poll_device['sysObjectID']];
}
if (empty($hardware)) {
    $hardware = snmp_get($device, 'ENTITY-MIB::entPhysicalModelName.1', '-Ovq');
}
$sessions = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysSesCount.0', '-Ovq');
if (is_numeric($sessions)) {
    $rrd_def = 'DS:sessions:GAUGE:600:0:3000000';
    print "Sessions: {$sessions}\n";
    $fields = array('sessions' => $sessions);
    $tags = compact('rrd_def');
    data_update($device, 'fortigate_sessions', $tags, $fields);
    $graphs['fortigate_sessions'] = true;
}
$cpu_usage = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0', '-Ovq');
if (is_numeric($cpu_usage)) {
    $rrd_def = 'DS:LOAD:GAUGE:600:-1:100';
    echo "CPU: {$cpu_usage}%\n";
    $fields = array('LOAD' => $cpu_usage);
    $tags = compact('rrd_def');
    data_update($device, 'fortigate_cpu', $tags, $fields);
    $graphs['fortigate_cpu'] = true;
}
示例#11
0
                    if ($gps == 'pTPSYNCNotConnected') {
                        $gps = 5;
                    } else {
                        if ($gps == 'initialising') {
                            $gps = 6;
                        } else {
                            if ($gps == 'clusterTimingMaster') {
                                $gps = 7;
                            } else {
                                if ($gps == 'acquiringLock') {
                                    $gps = 8;
                                } else {
                                    if ($gps == 'inactive') {
                                        $gps = 9;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if (is_numeric($gps)) {
    $rrd_def = 'DS:gps:GAUGE:600:0:10';
    $fields = array('gps' => $gps);
    $tags = compact('rrd_def');
    data_update($device, 'cambium-650-gps', $tags, $fields);
    $graphs['cambium_650_gps'] = TRUE;
}
示例#12
0
<?php

if ($device['os'] == 'asa' || $device['os'] == 'pix') {
    echo "ALTIGA-MIB SSL VPN Statistics \n";
    $tags = array();
    $oids = array('alSslStatsTotalSessions', 'alSslStatsActiveSessions', 'alSslStatsMaxSessions', 'alSslStatsPreDecryptOctets', 'alSslStatsPostDecryptOctets', 'alSslStatsPreEncryptOctets', 'alSslStatsPostEncryptOctets');
    $tags['rrd_def'] = array('DS:TotalSessions:COUNTER:600:U:100000', 'DS:ActiveSessions:GAUGE:600:0:U', 'DS:MaxSessions:GAUGE:600:0:U', 'DS:PreDecryptOctets:COUNTER:600:U:100000000000', 'DS:PostDecryptOctets:COUNTER:600:U:100000000000', 'DS:PreEncryptOctets:COUNTER:600:U:100000000000', 'DS:PostEncryptOctets:COUNTER:600:U:100000000000');
    $data_array = snmpwalk_cache_oid($device, $proto, array(), 'ALTIGA-SSL-STATS-MIB');
    $fields = array();
    $got_value = false;
    foreach ($oids as $oid) {
        if (is_numeric($data_array[0][$oid])) {
            $value = $data_array[0][$oid];
            if ($value > 0) {
                $got_value = true;
            }
        } else {
            $value = '0';
        }
        $fields[$oid] = $value;
    }
    if ($got_value) {
        data_update($device, 'altiga-ssl', $tags, $fields);
    }
    unset($tags, $fields, $oids, $data_array);
}
//end if
示例#13
0
 * 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_group'] == 'cisco' && $device['os'] == 'asa' && $device['type'] == 'firewall') {
    $oid_list = 'cfwConnectionStatValue.protoIp.currentInUse';
    $temp_data = snmpwalk_cache_double_oid($device, $oid_list, array(), 'CISCO-FIREWALL-MIB');
    foreach ($temp_data as $oid => $result) {
        $oid = substr(strchr($oid, '.'), 1);
        $data[$oid]['data'] = $result['cfwConnectionStatValue'];
        $asa_db = dbFetchCell('SELECT `ciscoASA_id` FROM `ciscoASA` WHERE `device_id` = ? AND `oid` = ?', array($device['device_id'], $oid));
        if (!is_numeric($asa_db)) {
            $asa_db = dbInsert(array('device_id' => $device['device_id'], 'oid' => $oid, 'data' => $result['cfwConnectionStatValue']), 'ciscoASA');
        } else {
            $asa_db = dbUpdate(array('data' => $result['cfwConnectionStatValue']), 'ciscoASA', 'device_id=?', array($device['device_id']));
        }
        $data[$oid]['db_id'] = $asa_db;
    }
    if ($data['currentInUse']) {
        $rrd_def = 'DS:connections:GAUGE:600:0:U';
        $fields = array('connections' => $data['currentInUse']['data']);
        $tags = compact('rrd_def');
        data_update($device, 'asa_conns', $tags, $fields);
        $graphs['asa_conns'] = true;
        echo ' ASA Connections';
    }
    unset($data, $rrd_def);
}
//end if
示例#14
0
$hardware = str_replace('PROCURVE', 'ProCurve', $hardware);
if (substr($hardware, 0, 3) == 'HP ') {
    $hardware = substr($hardware, 3);
}
if (substr($hardware, 0, 24) == 'Hewlett-Packard Company ') {
    $hardware = substr($hardware, 24);
}
$altversion = trim(snmp_get($device, 'hpSwitchOsVersion.0', '-Oqv', 'NETSWITCH-MIB'), '"');
if ($altversion) {
    $version = $altversion;
}
$altversion = trim(snmp_get($device, '.1.3.6.1.4.1.11.2.3.7.11.12.1.2.1.11.0', '-Oqv'), '"');
if ($altversion) {
    $version = $altversion;
}
if (preg_match('/^PROCURVE (.*) - (.*)/', $poll_device['sysDescr'], $regexp_result)) {
    $hardware = 'ProCurve ' . $regexp_result[1];
    $version = $regexp_result[2];
}
$serial = snmp_get($device, '.1.3.6.1.4.1.11.2.36.1.1.2.9.0', '-Oqv', 'SEMI-MIB');
$serial = trim(str_replace('"', '', $serial));
// FIXME maybe genericise? or do away with it if we ever walk the full dot1qTpFdbTable as we can count ourselves then ;)
$FdbAddressCount = snmp_get($device, 'hpSwitchFdbAddressCount.0', '-Ovqn', 'STATISTICS-MIB');
if (is_numeric($FdbAddressCount)) {
    $rrd_def = 'DS:value:GAUGE:600:-1:100000';
    $fields = array('value' => $FdbAddressCount);
    $tags = compact('rrd_def');
    data_update($device, 'fdb_count', $tags, $fields);
    $graphs['fdb_count'] = true;
    echo 'FDB Count ';
}
示例#15
0
if ($device['os'] != 'Snom') {
    echo ' IP';
    // These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
    $oids = array('ipForwDatagrams', 'ipInDelivers', 'ipInReceives', 'ipOutRequests', 'ipInDiscards', 'ipOutDiscards', 'ipOutNoRoutes', 'ipReasmReqds', 'ipReasmOKs', 'ipReasmFails', 'ipFragOKs', 'ipFragFails', 'ipFragCreates', 'ipInUnknownProtos', 'ipInHdrErrors', 'ipInAddrErrors');
    $rrd_def = array();
    $snmpstring = '';
    foreach ($oids as $oid) {
        $oid_ds = substr($oid, 0, 19);
        $rrd_def[] = "DS:{$oid_ds}:COUNTER:600:U:100000000000";
        $snmpstring .= ' IP-MIB::' . $oid . '.0';
    }
    $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-MIB');
    $fields = array();
    foreach ($oids as $oid) {
        if (is_numeric($data[0][$oid])) {
            $value = $data[0][$oid];
        } else {
            $value = 'U';
        }
        $fields[$oid] = $value;
    }
    if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives'])) {
        $tags = compact('rrd_def');
        data_update($device, 'netstats-ip', $tags, $fields);
        $graphs['netstat_ip'] = true;
        $graphs['netstat_ip_frag'] = true;
    }
}
//end if
unset($oids, $data, $snmpstring, $rrd_def, $fields, $tags);
示例#16
0
            unset($rrd_filename, $dbmRadio, $minRadio, $maxRadio, $avgRadio);
        }
    }
}
//AP Equipment
if (strstr($version, 'AP')) {
    $registered = str_replace('"', "", snmp_get($device, "regCount.0", "-Ovqn", "WHISP-APS-MIB"));
    $failed = str_replace('"', "", snmp_get($device, "regFailureCount.0", "-Ovqn", "WHISP-APS-MIB"));
    if (is_numeric($registered) && is_numeric($failed)) {
        $rrd_def = array('DS:regCount:GAUGE:600:0:15000', 'DS:failed:GAUGE:600:0:15000');
        $fields = array('regCount' => $registered, 'failed' => $failed);
        $tags = compact('rrd_def');
        data_update($device, 'canopy-generic-regCount', $tags, $fields);
        $graphs['canopy_generic_regCount'] = true;
        unset($rrd_filename, $registered, $failed);
    }
    $freq = str_replace('"', "", snmp_get($device, "currentRadioFreqCarrier.0", "-Ovqn", "WHISP-APS-MIB"));
    if (is_numeric($freq)) {
        $rrd_def = 'DS:freq:GAUGE:600:0:100000';
        if ($freq > 99999) {
            $freq = $freq / 100000;
        } else {
            $freq = $freq / 10000;
        }
        $fields = array('freq' => $freq);
        $tags = compact('rrd_def');
        data_update($device, 'canopy-generic-freq', $tags, $fields);
        $graphs['canopy_generic_freq'] = true;
        unset($rrd_filename, $freq);
    }
}
示例#17
0
function poll_service($service)
{
    global $config;
    $update = array();
    $old_status = $service['service_status'];
    $check_cmd = "";
    // if we have a script for this check, use it.
    $check_script = $config['install_dir'] . '/includes/services/check_' . strtolower($service['service_type']) . '.inc.php';
    if (is_file($check_script)) {
        include $check_script;
    }
    // If we do not have a cmd from the check script, build one.
    if ($check_cmd == "") {
        $check_cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
        $check_cmd .= " " . $service['service_param'];
    }
    $service_id = $service['service_id'];
    // Some debugging
    d_echo("\nNagios Service - {$service_id}\n");
    // the check_service function runs $check_cmd through escapeshellcmd, so
    // echo the command as it will be run after being escaped
    $escaped_check_cmd = escapeshellcmd($check_cmd);
    d_echo("Request:  {$escaped_check_cmd}\n");
    list($new_status, $msg, $perf) = check_service($check_cmd);
    d_echo("Response: {$msg}\n");
    // If we have performance data we will store it.
    if (count($perf) > 0) {
        // Yes, We have perf data.
        $rrd_name = array('services', $service_id);
        // Set the DS in the DB if it is blank.
        $DS = array();
        foreach ($perf as $k => $v) {
            $DS[$k] = $v['uom'];
        }
        d_echo("Service DS: " . _json_encode($DS) . "\n");
        if ($service['service_ds'] == "") {
            $update['service_ds'] = json_encode($DS);
        }
        // rrd definition
        $rrd_def = array();
        foreach ($perf as $k => $v) {
            if ($v['uom'] == 'c') {
                // This is a counter, create the DS as such
                $rrd_def[] = "DS:" . $k . ":COUNTER:600:0:U";
            } else {
                // Not a counter, must be a gauge
                $rrd_def[] = "DS:" . $k . ":GAUGE:600:0:U";
            }
        }
        // Update data
        $fields = array();
        foreach ($perf as $k => $v) {
            $fields[$k] = $v['value'];
        }
        $tags = compact('service_id', 'rrd_name', 'rrd_def');
        //TODO not sure if we have $device at this point, if we do replace faked $device
        data_update(array('hostname' => $service['hostname']), 'services', $tags, $fields);
    }
    if ($old_status != $new_status) {
        // Status has changed, update.
        $update['service_changed'] = time();
        $update['service_status'] = $new_status;
        $update['service_message'] = $msg;
    }
    if ($service['service_message'] != $msg) {
        // Message has changed, update.
        $update['service_message'] = $msg;
    }
    if (count($update) > 0) {
        edit_service($update, $service['service_id']);
    }
    return true;
}
示例#18
0
    $tags = compact('rrd_def');
    data_update($device, 'cambium-250-receivePower', $tags, $fields);
    $graphs['cambium_250_receivePower'] = true;
}
$txModulation = snmp_get($device, ".1.3.6.1.4.1.17713.250.5.9.0", "-Ovqn", "");
$rxModulation = snmp_get($device, ".1.3.6.1.4.1.17713.250.5.8.0", "-Ovqn", "");
if (is_numeric($txModulation) && is_numeric($rxModulation)) {
    $rrd_def = array('DS:txModulation:GAUGE:600:0:24', 'DS:rxModulation:GAUGE:600:0:24');
    $fields = array('txModuation' => $txModulation, 'rxModulation' => $rxModulation);
    $tags = compact('rrd_def');
    data_update($device, 'cambium-250-modulationMode', $tags, $fields);
    $graphs['cambium_250_modulationMode'] = true;
}
$receiveDataRate = snmp_get($device, "receiveDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB");
$transmitDataRate = snmp_get($device, "transmitDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB");
$aggregateDataRate = snmp_get($device, "aggregateDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB");
if (is_numeric($receiveDataRate) && is_numeric($transmitDataRate) && is_numeric($aggregateDataRate)) {
    $rrd_def = array('DS:receiveDataRate:GAUGE:600:0:10000', 'DS:transmitDataRate:GAUGE:600:0:10000', 'DS:aggregateDataRate:GAUGE:600:0:10000');
    $fields = array('receiveDataRate' => $receiveDataRate / 100, 'transmitDataRate' => $transmitDataRate / 100, 'aggregateDataRate' => $aggregateDataRate / 100);
    $tags = compact('rrd_def');
    data_update($device, 'cambium-250-dataRate', $tags, $fields);
    $graphs['cambium_250_dataRate'] = true;
}
$ssr = snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "CAMBIUM-PTP250-MIB");
if (is_numeric($ssr)) {
    $rrd_def = 'DS:ssr:GAUGE:600:-150:150';
    $fields = array('ssr' => $ssr);
    $tags = compact('rrd_def');
    data_update($device, 'cambium-250-ssr', $tags, $fields);
    $graphs['cambium_250_ssr'] = true;
}
示例#19
0
if ($device['os'] != 'Snom') {
    echo ' IP-FORWARD';
    // Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
    $oids = array('ipCidrRouteNumber');
    unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create);
    $rrd_def = array();
    $snmpstring = '';
    foreach ($oids as $oid) {
        $oid_ds = substr($oid, 0, 19);
        $rrd_create[] = "DS:{$oid_ds}:GAUGE:600:U:1000000";
        // Limit to 1MPPS?
        $snmpstring .= ' IP-FORWARD-MIB::' . $oid . '.0';
    }
    $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-FORWARD-MIB');
    $fields = array();
    foreach ($oids as $oid) {
        if (is_numeric($data[0][$oid])) {
            $value = $data[0][$oid];
        } else {
            $value = 'U';
        }
        $fields[$oid] = $value;
    }
    if (isset($data[0]['ipCidrRouteNumber'])) {
        $tags = compact('rrd_def');
        data_update($device, 'netstats-ip_forward', $tags, $fields);
        $graphs['netstat_ip_forward'] = true;
    }
}
unset($oids, $rrd_def, $data, $oid, $fields, $snmpstring, $tags);
示例#20
0
    $vp_cache = array();
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInCells', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInPackets', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInPacketOctets', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInPacketErrors', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutCells', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutPackets', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutPacketOctets', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutPacketErrors', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'] . '/mibs/junose');
    $rrd_def = array('DS:incells:DERIVE:600:0:125000000000', 'DS:outcells:DERIVE:600:0:125000000000', 'DS:inpackets:DERIVE:600:0:125000000000', 'DS:outpackets:DERIVE:600:0:125000000000', 'DS:inpacketoctets:DERIVE:600:0:125000000000', 'DS:outpacketoctets:DERIVE:600:0:125000000000', 'DS:inpacketerrors:DERIVE:600:0:125000000000', 'DS:outpacketerrors:DERIVE:600:0:125000000000');
    foreach ($vp_rows as $vp) {
        echo '.';
        $ifIndex = $vp['ifIndex'];
        $vp_id = $vp['vp_id'];
        $oid = $ifIndex . '.' . $vp_id;
        d_echo("{$oid} ");
        $t_vp = $vp_cache[$oid];
        $vp_update = $t_vp['juniAtmVpStatsInCells'] . ':' . $t_vp['juniAtmVpStatsOutCells'];
        $vp_update .= ':' . $t_vp['juniAtmVpStatsInPackets'] . ':' . $t_vp['juniAtmVpStatsOutPackets'];
        $vp_update .= ':' . $t_vp['juniAtmVpStatsInPacketOctets'] . ':' . $t_vp['juniAtmVpStatsOutPacketOctets'];
        $vp_update .= ':' . $t_vp['juniAtmVpStatsInPacketErrors'] . ':' . $t_vp['juniAtmVpStatsOutPacketErrors'];
        $rrd_name = array('vp', $ifIndex, $vp_id);
        $fields = array('incells' => $t_vp['juniAtmVpStatsInCells'], 'outcells' => $t_vp['juniAtmVpStatsOutCells'], 'inpackets' => $t_vp['juniAtmVpStatsInPackets'], 'outpackets' => $t_vp['juniAtmVpStatsOutPackets'], 'inpacketoctets' => $t_vp['juniAtmVpStatsInPacketOctets'], 'outpacketoctets' => $t_vp['juniAtmVpStatsOutPacketOctets'], 'inpacketerrors' => $t_vp['juniAtmVpStatsInPacketErrors'], 'outpacketerrors' => $t_vp['juniAtmVpStatsOutPacketErrors']);
        $tags = compact('ifIndex', 'vp_id', 'rrd_name', 'rrd_def');
        data_update($device, 'atm-vp', $tags, $fields);
    }
    //end foreach
    echo "\n";
    unset($vp_cache, $rrd_def);
}
//end if
示例#21
0
    $proxmox = preg_replace('/^.+\\n/', '', $proxmox);
    $proxmox = str_replace("<<<app-proxmox>>>\n", '', $proxmox);
}
if ($proxmox) {
    $pmxlines = explode("\n", $proxmox);
    $pmxcluster = array_shift($pmxlines);
    dbUpdate(array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $name));
    if (count($pmxlines) > 0) {
        $pmxcache = array();
        foreach ($pmxlines as $vm) {
            list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5);
            print "Proxmox ({$pmxcluster}): {$vmdesc}: {$vmpin}/{$vmpout}/{$vmport}\n";
            $rrd_proxmox_name = array('pmxcluster' => $pmxcluster, 'vmid' => $vmid, 'vmport' => $vmport);
            $rrd_def = array('DS:INOCTETS:DERIVE:600:0:12500000000', 'DS:OUTOCTETS:DERIVE:600:0:12500000000');
            $fields = array('INOCTETS' => $vmpin, 'OUTOCTETS' => $vmpout);
            $tags = compact('name', 'app_id', 'pmxcluster', 'vmid', 'vmport', 'rrd_proxmox_name', 'rrd_def');
            data_update($device, 'app', $tags, $fields);
            if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) {
                dbUpdate(array('device_id' => $device['device_id'], 'last_seen' => array('NOW()'), 'description' => $vmdesc), $name, '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster));
            } else {
                $pmxcache[$pmxcluster][$vmid] = dbInsert(array('cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, 'device_id' => $device['device_id']), $name);
            }
            if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) {
                dbUpdate(array('last_seen' => array('NOW()')), 'proxmox_ports', '`vm_id` = ? AND `port` = ?', array($pmxcache[$pmxcluster][$vmid], $vmport));
            } else {
                dbInsert(array('vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport), 'proxmox_ports');
            }
        }
    }
}
unset($pmxlines, $pmxcluster, $pmxcdir, $proxmox, $pmxcache);
示例#22
0
                    $peer['c_update']['DeniedPrefixes'] = $cbgpPeerDeniedPrefixes;
                    $peer['c_update']['PrefixAdminLimit'] = $cbgpPeerAdminLimit;
                    $peer['c_update']['PrefixThreshold'] = $cbgpPeerPrefixThreshold;
                    $peer['c_update']['PrefixClearThreshold'] = $cbgpPeerPrefixClearThreshold;
                    $peer['c_update']['AdvertisedPrefixes'] = $cbgpPeerAdvertisedPrefixes;
                    $peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes;
                    $peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes;
                    $oids = array('AcceptedPrefixes', 'DeniedPrefixes', 'AdvertisedPrefixes', 'SuppressedPrefixes', 'WithdrawnPrefixes');
                    foreach ($oids as $oid) {
                        $peer['c_update'][$oid . '_delta'] = $peer['c_update'][$oid] - $peer_afi[$oid];
                        $peer['c_update'][$oid . '_prev'] = $peer_afi[$oid];
                    }
                    dbUpdate($peer['c_update'], 'bgpPeers_cbgp', '`device_id` = ? AND bgpPeerIdentifier = ? AND afi = ? AND safi = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $afi, $safi));
                    $cbgp_rrd_name = safename('cbgp-' . $peer['bgpPeerIdentifier'] . ".{$afi}.{$safi}");
                    $cbgp_rrd_def = array('DS:AcceptedPrefixes:GAUGE:600:U:100000000000', 'DS:DeniedPrefixes:GAUGE:600:U:100000000000', 'DS:AdvertisedPrefixes:GAUGE:600:U:100000000000', 'DS:SuppressedPrefixes:GAUGE:600:U:100000000000', 'DS:WithdrawnPrefixes:GAUGE:600:U:100000000000');
                    $fields = array('AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes, 'DeniedPrefixes' => $cbgpPeerDeniedPrefixes, 'AdvertisedPrefixes' => $cbgpPeerAdvertisedPrefixes, 'SuppressedPrefixes' => $cbgpPeerSuppressedPrefixes, 'WithdrawnPrefixes' => $cbgpPeerWithdrawnPrefixes);
                    $tags = array('bgpPeerIdentifier' => $peer['bgpPeerIdentifier'], 'afi' => $afi, 'safi' => $safi, 'rrd_name' => $cbgp_rrd_name, 'rrd_def' => $cbgp_rrd_def);
                    data_update($device, 'cbgp', $tags, $fields);
                }
                //end foreach
            }
            //end if
            echo "\n";
        }
        //end foreach
    }
    //end if
}
//end if
unset(${$peer_data_tmp});
unset($j_prefixes);
示例#23
0
<?php

if ($this_port['dot3StatsIndex'] and $port['ifType'] == 'ethernetCsmacd') {
    $rrd_oldname = 'etherlike-' . $port['ifIndex'];
    // TODO: remove oldname check?
    $rrd_name = getPortRrdName($port_id, 'dot3');
    $rrd_def = array();
    $rrd_create = $config['rrd_rra'];
    foreach ($etherlike_oids as $oid) {
        $oid = truncate(str_replace('dot3Stats', '', $oid), 19, '');
        $rrd_def[] = "DS:{$oid}:COUNTER:600:U:100000000000";
    }
    $fields = array();
    foreach ($etherlike_oids as $oid) {
        $data = $this_port[$oid] + 0;
        $fields[$oid] = $data;
    }
    $tags = compact('ifName', 'rrd_name', 'rrd_def', 'rrd_oldname');
    data_update($device, 'dot3', $tags, $fields);
    echo 'EtherLike ';
}
示例#24
0
function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_graphs, &$graphs)
{
    echo "This is poll_mib_def Processing\n";
    $mib = null;
    if (stristr($mib_name_table, 'UBNT')) {
        list($mib, ) = explode(':', $mib_name_table, 2);
        $measurement_name = strtolower($mib);
    } else {
        list($mib, $file) = explode(':', $mib_name_table, 2);
        $measurement_name = strtolower($file);
    }
    $rrd_def = array();
    $oidglist = array();
    $oidnamelist = array();
    foreach ($mib_oids as $oid => $param) {
        $oidindex = $param[0];
        $oiddsname = $param[1];
        $oiddsdesc = $param[2];
        $oiddstype = $param[3];
        $oiddsopts = $param[4];
        if (strlen($oiddsname) > 19) {
            $oiddsname = substr($oiddsname, 0, 19);
        }
        if (empty($oiddsopts)) {
            $oiddsopts = '600:U:100000000000';
        }
        $rrd_def[] = 'DS:' . $oiddsname . ':' . $oiddstype . ':' . $oiddsopts;
        if ($oidindex != '') {
            $fulloid = $oid . '.' . $oidindex;
        } else {
            $fulloid = $oid;
        }
        // Add to oid GET list
        $oidglist[] = $fulloid;
        $oidnamelist[] = $oiddsname;
    }
    //end foreach
    // Implde for LibreNMS Version
    $oidilist = implode(' ', $oidglist);
    $snmpdata = snmp_get_multi($device, $oidilist, '-OQUs', $mib);
    if (isset($GLOBALS['exec_status']['exitcode']) && $GLOBALS['exec_status']['exitcode'] !== 0) {
        print_debug('  ERROR, bad snmp response');
        return false;
    }
    $oid_count = 0;
    $fields = array();
    foreach ($oidglist as $fulloid) {
        list($splitoid, $splitindex) = explode('.', $fulloid, 2);
        $val = $snmpdata[$splitindex][$splitoid];
        if (is_numeric($val)) {
            $fields[$oidnamelist[$oid_count]] = $val;
        } elseif (preg_match("/^\"(.*)\"\$/", $val, $number) && is_numeric($number[1])) {
            $fields[$oidnamelist[$oid_count]] = $number[1];
        } else {
            $fields[$oidnamelist[$oid_count]] = 'U';
        }
        $oid_count++;
    }
    $tags = compact('rrd_def');
    data_update($device, $measurement_name, $tags, $fields);
    foreach ($mib_graphs as $graphtoenable) {
        $graphs[$graphtoenable] = true;
    }
    return true;
}
示例#25
0
    }
    //end if
}
//end if
if ($device["os"] != "edgeswitch") {
    if ($snmp_uptime > $uptime && is_numeric($snmp_uptime)) {
        $uptime = $snmp_uptime;
        d_echo('hrSystemUptime or sysUpTime looks like to have rolled, using snmpEngineTime instead');
    }
}
if (is_numeric($uptime) && $config['os'][$device['os']]['bad_uptime'] !== true) {
    if ($uptime < $device['uptime']) {
        log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
    }
    $tags = array('rrd_def' => 'DS:uptime:GAUGE:600:0:U');
    data_update($device, 'uptime', $tags, $uptime);
    $graphs['uptime'] = true;
    echo 'Uptime: ' . formatUptime($uptime) . "\n";
    $update_array['uptime'] = $uptime;
}
//end if
$poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysLocation'] = trim($poll_device['sysLocation'], '\\');
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation']) && (is_array($config['location_map']) || is_array($config['location_map_regex']))) {
    $poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysContact'] = trim($poll_device['sysContact'], '\\');
示例#26
0
                 if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) {
                     $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host'];
                 }
                 // FIXME -- memcached
                 $cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop'];
                 $cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt'];
                 $cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host'];
                 $cef_stat['update']['drop_prev'] = $cef_entry['drop'];
                 $cef_stat['update']['punt_prev'] = $cef_entry['punt'];
                 $cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host'];
                 $cef_stat['update']['updated'] = $polled;
                 $cef_stat['update']['updated_prev'] = $cef_entry['updated'];
                 dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $index));
                 $fields = array('drop' => $cef_stat['cefSwitchingDrop'], 'punt' => $cef_stat['cefSwitchingPunt'], 'hostpunt' => $cef_stat['cefSwitchingPunt2Host']);
                 $tags = compact('entity', 'afi', 'index', 'rrd_name', 'rrd_def');
                 data_update($device, 'cefswitching', $tags, $fields);
                 echo "\n";
             }
             //end foreach
         }
         //end foreach
     }
     //end foreach
 }
 //end if
 // FIXME - need to delete old ones. FIXME REALLY.
 print_r($cefs_db);
 foreach ($cefs_db as $cef_switching_id) {
     dbDelete('cef_switching', '`cef_switching_id` =  ?', array($cef_switching_id));
     echo '-';
 }
    $db_oids = array($farm_id => 'farm_id', 'cesServerFarmRserverStateDescr' => 'StateDescr');
    if (!is_array($serverfarms[$farm_id])) {
        $rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $farm_id, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers');
    } else {
        foreach ($db_oids as $db_oid => $db_value) {
            $db_update[$db_value] = $serverfarm[$db_oid];
        }
        $updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']);
    }
    $rrd_name = array('rserver', $serverfarms[$farm_id]['rserver_id']);
    $rrd_def = array();
    foreach ($oids as $oid) {
        $oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, '');
        $rrd_def[] = "DS:{$oid_ds}:GAUGE:600:-1:100000000";
    }
    $fields = array();
    foreach ($oids as $oid) {
        if (is_numeric($serverfarm[$oid])) {
            $value = $serverfarm[$oid];
        } else {
            $value = '0';
        }
        $fields[$oid] = $value;
    }
    if (isset($serverfarms[$farm_id])) {
        $tags = compact('farm_id', 'rrd_name', 'rrd_def');
        data_update($device, 'rservers', $tags, $fields);
    }
}
//end foreach
unset($rrd_name, $rrd_def, $oids, $oid, $serverfarm);
示例#28
0
if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
    $ipmi['user'] = get_dev_attrib($device, 'ipmi_username');
    $ipmi['password'] = get_dev_attrib($device, 'ipmi_password');
    $ipmi['type'] = get_dev_attrib($device, 'ipmi_type');
    echo 'Fetching IPMI sensor data...';
    if ($config['own_hostname'] != $device['hostname'] || $ipmi['host'] != 'localhost') {
        $remote = ' -H ' . $ipmi['host'] . ' -U ' . $ipmi['user'] . ' -P ' . $ipmi['password'];
    }
    $results = external_exec($config['ipmitool'] . ' -I ' . $ipmi['type'] . ' -c ' . $remote . ' sdr 2>/dev/null');
    d_echo($results);
    echo " done.\n";
    foreach (explode("\n", $results) as $row) {
        list($desc, $value, $type, $status) = explode(',', $row);
        $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['value'] = $value;
        $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['unit'] = $type;
    }
    foreach ($ipmi_rows as $ipmisensors) {
        echo 'Updating IPMI sensor ' . $ipmisensors['sensor_descr'] . '... ';
        $sensor = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['value'];
        $unit = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['unit'];
        echo $sensor . " {$unit}\n";
        $rrd_name = get_sensor_rrd_name($device, $ipmisensors);
        $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000';
        $fields = array('sensor' => $sensor);
        $tags = array('sensor_class' => $sensor['sensor_class'], 'sensor_type' => $sensor['sensor_type'], 'sensor_descr' => $sensor['sensor_descr'], 'sensor_index' => $sensor['sensor_index'], 'rrd_name' => $rrd_name, 'rrd_def' => $rrd_def);
        data_update($device, 'ipmi', $tags, $fields);
        // FIXME warnings in event & mail not done here yet!
        dbUpdate(array('sensor_current' => $sensor, 'lastupdate' => array('NOW()')), 'sensors', 'poller_type = ? AND sensor_class = ? AND sensor_id = ?', array('ipmi', $ipmisensors['sensor_class'], $ipmisensors['sensor_id']));
    }
    unset($ipmi_sensor);
}
示例#29
0
    sys_msg('操作成功', 0, $link);
} elseif ($_REQUEST['act'] == 'edit') {
    $info = $db->GetRow("SELECT *  FROM " . $ecs->table('goods_tag') . " WHERE tag_id='{$_REQUEST['id']}'");
    $smarty->assign('ur_here', '编辑标签');
    $smarty->assign('action_link', array('text' => '返回', 'href' => 'goods_tag.php?act=list&goods_id=' . $goods_id));
    $smarty->assign('info', $info);
    $smarty->assign('form_action', 'updata');
    assign_query_info();
    $smarty->display('goods_tag_info.htm');
} elseif ($_REQUEST['act'] == 'updata') {
    $tag_name = trim($_POST['tag_name']);
    $is = $db->GetOne("SELECT tag_id FROM " . $ecs->table('goods_tag') . " WHERE goods_id = '{$goods_id}' AND tag_name='{$tag_name}' AND tag_id != '{$_POST['id']}'");
    if ($is > 0) {
        sys_msg("标签名称已经存在,请修改!", 1, array(), false);
    }
    $db->query("UPDATE " . $ecs->table('goods_tag') . " SET tag_name = '{$tag_name}' WHERE tag_id = '{$_POST['id']}'");
    $link[0]['text'] = '返回列表';
    $link[0]['href'] = "goods_tag.php?act=list&goods_id={$goods_id}";
    sys_msg('操作成功', 0, $link);
} elseif ($_REQUEST['act'] == 'remove') {
    $id = intval($_GET['id']);
    $db->query("delete from " . $ecs->table('goods_tag') . " where tag_id = '{$id}'");
    $url = 'goods_tag.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']);
    ecs_header("Location: {$url}\n");
    exit;
} elseif ($_REQUEST['act'] == 'edit_displayorder') {
    $id = intval($_POST['id']);
    $val = intval($_POST['val']);
    data_update("goods_tag", array('displayorder' => $val), $id, 'tag_id');
    make_json_result($val);
}
示例#30
0
<?php

echo "Polling SNOM device...\n";
// Get SNOM specific version string from silly SNOM location. Silly SNOM!
// FIXME - This needs a good cleanup...
$cmd = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.4';
$poll_device['sysDescr'] = `{$cmd}`;
$poll_device['sysDescr'] = str_replace('-', ' ', $poll_device['sysDescr']);
$poll_device['sysDescr'] = str_replace('"', '', $poll_device['sysDescr']);
list($hardware, $features, $version) = explode(' ', $poll_device['sysDescr']);
// Get data for calls and network from SNOM specific SNMP OIDs.
$cmda = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2';
$cmdb = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6';
// echo($cmda);
$snmpdata = `{$cmda}`;
$snmpdatab = `{$cmdb}`;
list($rxbytes, $rxpkts, $txbytes, $txpkts) = explode("\n", $snmpdata);
list($calls, $registrations) = explode("\n", $snmpdatab);
$txbytes = 0 - $txbytes * 8;
$rxbytes = 0 - $rxbytes * 8;
echo "{$rxbytes}, {$rxpkts}, {$txbytes}, {$txpkts}, {$calls}, {$registrations}";
$rrd_name = 'data';
$rrd_def = array('DS:INOCTETS:COUNTER:600:U:100000000000', 'DS:OUTOCTETS:COUNTER:600:U:10000000000', 'DS:INPKTS:COUNTER:600:U:10000000000', 'DS:OUTPKTS:COUNTER:600:U:10000000000', 'DS:CALLS:COUNTER:600:U:10000000000', 'DS:REGISTRATIONS:COUNTER:600:U:10000000000');
$fields = array('INOCTETS' => $rxbytes, 'OUTOCTETS' => $txbytes, 'INPKTS' => $rxpkts, 'OUTPKTS' => $rxbytes, 'CALLS' => $calls, 'REGISTRATIONS' => $registrations);
$tags = compact('rrd_name', 'rrd_def');
data_update($device, 'snom-data', $tags, $fields);