function custom_port_parser($port)
{
    global $debug;
    if ($debug) {
        echo $port['ifAlias'];
    }
    list($type, $descr) = preg_split("/[\\:\\[\\]\\{\\}\\(\\)]/", $port['ifAlias']);
    list(, $circuit) = preg_split("/[\\{\\}]/", $port['ifAlias']);
    list(, $notes) = preg_split("/[\\(\\)]/", $port['ifAlias']);
    list(, $speed) = preg_split("/[\\[\\]]/", $port['ifAlias']);
    $descr = trim($descr);
    $port_ifAlias = array();
    if ($type && $descr) {
        $type = strtolower($type);
        $port_ifAlias['type'] = $type;
        $port_ifAlias['descr'] = $descr;
        $port_ifAlias['circuit'] = $circuit;
        $port_ifAlias['speed'] = $speed;
        $port_ifAlias['notes'] = $notes;
    }
    if ($debug && count($port_ifAlias)) {
        print_vars($port_ifAlias);
    }
    return $port_ifAlias;
}
Ejemplo n.º 2
0
/**
 * Show the debug information
 *
 * @param txt
 * @param value
 *
*/
function api_show_debug($txt, $value)
{
    global $vars;
    if ($vars['debug']) {
        echo "<pre>\n";
        echo "DEBUG " . $txt . ":\n";
        print_vars($value);
        echo "</pre>\n";
    }
}
function print_vars($obj)
{
    $arr = get_object_vars($obj);
    while (list($prop, $val) = each($arr)) {
        if (class_exists($val)) {
            print_vars($val);
        } else {
            echo "\t {$prop} = {$val}\n<br />";
        }
    }
}
Ejemplo n.º 4
0
function print_sql($query)
{
    if ($GLOBALS['cli']) {
        print_vars($query);
    } else {
        if (class_exists('SqlFormatter')) {
            // Hide it under a "database icon" popup.
            #echo overlib_link('#', '<i class="oicon-databases"> </i>', SqlFormatter::highlight($query));
            echo '<p>', SqlFormatter::highlight($query), '</p>';
        } else {
            print_vars($query);
        }
    }
}
Ejemplo n.º 5
0
function getLastMeasurement($bill_id)
{
    $row = dbFetchRow("SELECT timestamp,delta,in_delta,out_delta FROM bill_data WHERE bill_id='" . mres($bill_id) . "' ORDER BY timestamp DESC LIMIT 0,1");
    print_vars($row);
    if (is_numeric($row['delta'])) {
        $return['delta'] = $row['delta'];
        $return['delta_in'] = $row['delta_in'];
        $return['delta_out'] = $row['delta_out'];
        $return['timestamp'] = $row['timestamp'];
        $return['state'] = "ok";
    } else {
        $return['state'] = "failed";
    }
    return $return;
}
function custom_port_parser($port)
{
    global $config;
    print_debug($port['ifAlias']);
    // Pull out Type and Description or abort
    if (!preg_match('/^([^:]+):([^\\[\\]\\(\\)\\{\\}]+)/', $port['ifAlias'], $matches)) {
        return array();
    }
    // Munge and Validate type
    $types = array('core', 'peering', 'transit', 'cust', 'server', 'l2tp');
    foreach ($config['int_groups'] as $custom_type) {
        $types[] = strtolower(trim($custom_type));
    }
    $type = strtolower(trim($matches[1], " \t\n\r\v\\/\"'"));
    if (!in_array($type, $types)) {
        return array();
    }
    # Munge and Validate description
    $descr = trim($matches[2]);
    if ($descr == '') {
        return array();
    }
    if (preg_match('/\\{(.*)\\}/', $port['ifAlias'], $matches)) {
        $circuit = $matches[1];
    }
    if (preg_match('/\\[(.*)\\]/', $port['ifAlias'], $matches)) {
        $speed = $matches[1];
    }
    if (preg_match('/\\((.*)\\)/', $port['ifAlias'], $matches)) {
        $notes = $matches[1];
    }
    $port_ifAlias = array();
    $port_ifAlias['type'] = $type;
    $port_ifAlias['descr'] = $descr;
    $port_ifAlias['circuit'] = $circuit;
    $port_ifAlias['speed'] = $speed;
    $port_ifAlias['notes'] = $notes;
    if (OBS_DEBUG > 1) {
        print_vars($port_ifAlias);
    }
    return $port_ifAlias;
}
Ejemplo n.º 7
0
function mydebug($line, $file, $vars)
{
    $debug = $GLOBALS['debug'];
    if ($debug) {
        print "<i>Debugging line {$line} of script {$file}</i>.<br>";
        $type = gettype($vars);
        switch ($type) {
            case 'array':
                foreach ($vars as $k => $v) {
                    print "{$k}: {$v}<br>";
                }
                break;
            case 'object':
                print_vars($vars);
                break;
            default:
                print $vars;
        }
    }
}
Ejemplo n.º 8
0
 * Observium
 *
 *   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, 'oaSfpDiagnosticTemperature', array(), 'OA-SFP-MIB');
$oids = snmpwalk_cache_oid($device, 'oaSfpDiagnosticVcc', $oids, 'OA-SFP-MIB');
$oids = snmpwalk_cache_oid($device, 'oaSfpDiagnosticTxBias', $oids, 'OA-SFP-MIB');
$oids = snmpwalk_cache_oid($device, 'oaSfpDiagnosticTxPower', $oids, 'OA-SFP-MIB');
$oids = snmpwalk_cache_oid($device, 'oaSfpDiagnosticRxPower', $oids, 'OA-SFP-MIB');
if (OBS_DEBUG > 1) {
    print_vars($oids);
}
foreach ($oids as $index => $entry) {
    list($mrvslot, $mrvport) = explode('.', $index);
    $xdescr = "Slot {$mrvslot} port {$mrvport}";
    unset($mrvslot, $mrvport);
    if ($entry['oaSfpDiagnosticTemperature'] != 'empty') {
        $descr = $xdescr . ' DOM Temperature';
        $scale = 0.1;
        $oid = ".1.3.6.1.4.1.6926.1.18.1.1.3.1.3.{$index}";
        $value = intval($entry['oaSfpDiagnosticTemperature']);
        if ($value != 0) {
            discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'lambdadriver-dom-temp', $descr, $scale, $value);
        }
    }
    if ($entry['oaSfpDiagnosticVcc'] != 'empty') {
Ejemplo n.º 9
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$lldp_array = snmpwalk_cache_threepart_oid($device, "lldpRemoteSystemsData", array(), "LLDP-MIB", NULL, OBS_SNMP_ALL | OBS_SNMP_CONCAT);
if ($lldp_array) {
    if (OBS_DEBUG > 1) {
        print_vars($lldp_array);
    }
    $dot1d_array = snmpwalk_cache_oid($device, "dot1dBasePortIfIndex", array(), "BRIDGE-MIB");
    $lldp_local_array = snmpwalk_cache_oid($device, "lldpLocalSystemData", array(), "LLDP-MIB");
    foreach ($lldp_array as $key => $lldp_if_array) {
        foreach ($lldp_if_array as $entry_key => $lldp_instance) {
            if (is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex']) && $device['os'] != "junos") {
                $ifIndex = $dot1d_array[$entry_key]['dot1dBasePortIfIndex'];
            } else {
                $ifIndex = $entry_key;
            }
            // Get the port using BRIDGE-MIB
            $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", array($device['device_id'], $ifIndex));
            // If BRIDGE-MIB failed, get the port using pure LLDP-MIB
            if (!$port) {
                $ifName = $lldp_local_array[$entry_key]['lldpLocPortDesc'];
Ejemplo n.º 10
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// EMBEDDED-NGX-MIB
if (!is_array($cache_storage['embedded-ngx-mib'])) {
    $cache_storage['embedded-ngx-mib'] = snmpwalk_cache_oid($device, "swStorage", NULL, "EMBEDDED-NGX-MIB");
    if (OBS_DEBUG && count($cache_storage['embedded-ngx-mib'])) {
        print_vars($cache_storage['embedded-ngx-mib']);
    }
}
$entry = $cache_storage['embedded-ngx-mib'][$storage['storage_index']];
$storage['units'] = 1024;
$storage['size'] = $entry['swStorageConfigTotal'] * $storage['units'];
$storage['free'] = $entry['swStorageConfigFree'] * $storage['units'];
$storage['used'] = $storage['size'] - $storage['free'];
// EOF
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Note. $cache_discovery['ucd-snmp-mib'] - is cached 'UCD-SNMP-MIB::dskEntry' (see ucd-snmp-mib.inc.php in current directory)
$mib = 'HOST-RESOURCES-MIB';
if (!isset($cache_discovery['host-resources-mib'])) {
    $cache_discovery['host-resources-mib'] = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES", mib_dirs());
    if (OBS_DEBUG && count($cache_discovery['host-resources-mib'])) {
        print_vars($cache_discovery['host-resources-mib']);
    }
}
if (count($cache_discovery['host-resources-mib'])) {
    echo " {$mib} ";
    foreach ($cache_discovery['host-resources-mib'] as $index => $storage) {
        $hc = 0;
        $mib = 'HOST-RESOURCES-MIB';
        $fstype = $storage['hrStorageType'];
        $descr = $storage['hrStorageDescr'];
        $units = $storage['hrStorageAllocationUnits'];
        $deny = FALSE;
        switch ($fstype) {
            case 'hrStorageVirtualMemory':
            case 'hrStorageRam':
            case 'hrStorageOther':
            echo '<td><i class="icon-remove-sign red"></i></td>';
        }
        if (is_array($config['graph_types']['device'][$graph_entry['graph']])) {
            echo '<td><i class="icon-ok-sign green"></i></td>';
        } else {
            echo '<td><i class="icon-remove-sign red"></i></td>';
        }
        if ($graph_entry['enabled']) {
            echo '<td><i class="icon-ok-sign green"></i></td>';
        } else {
            echo '<td><i class="icon-remove-sign red"></i></td>';
        }
        echo '<td>' . print_r($config['graph_types']['device'][$graph_entry['graph']], TRUE) . '</td>';
        echo '</tr>';
    }
    ?>
        </table>
      </div>
    <div class="well info_box">
<?php 
    print_vars($device);
    ?>
    </div>
    </div>
  </div>

<?php 
} else {
    include "includes/error-no-perm.inc.php";
}
// EOF
Ejemplo n.º 13
0
    $vars['from'] = strtotime($vars['timestamp_from']);
    unset($vars['timestamp_from']);
}
if (isset($vars['timestamp_to']) && preg_match($timestamp_pattern, $vars['timestamp_to'])) {
    $vars['to'] = strtotime($vars['timestamp_to']);
    unset($vars['timestamp_to']);
}
if (!is_numeric($vars['from'])) {
    $vars['from'] = $config['time']['day'];
}
if (!is_numeric($vars['to'])) {
    $vars['to'] = $config['time']['now'];
}
preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
if (OBS_DEBUG) {
    print_vars($graphtype);
}
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
if (is_numeric($vars['device'])) {
    $device = device_by_id_cache($vars['device']);
} elseif (!empty($vars['device'])) {
    $device = device_by_name($vars['device']);
}
if (is_file($config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php")) {
    include $config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php";
}
if (!$auth) {
    print_error_permission();
    return;
}
Ejemplo n.º 14
0
if ($GLOBALS['snmp_status']) {
    $radios_snmp = snmpwalk_cache_oid($device, 'ruckusRadioStatsTable', array(), 'RUCKUS-RADIO-MIB');
    if (OBS_DEBUG > 1) {
        print_vars($radios_snmp);
    }
}
$polled = time();
// Goes through the SNMP radio data
foreach ($radios_snmp as $radio_number => $radio) {
    $radio['polled'] = $polled;
    $radio['radio_number'] = $radio_number;
    $radio['radio_ap'] = 0;
    // Hardcoded since the AP is self.
    $radio['radio_clients'] = $radio['ruckusRadioStatsNumSta'];
    if (OBS_DEBUG && count($radio)) {
        print_vars($radio);
    }
    // FIXME -- This is Ruckus only and subject to change. RRD files may be wiped as we modify this format to fit everything.
    $dses = array('assoc_fail_rate' => array('oid' => 'ruckusRadioStatsAssocFailRate', 'type' => 'gauge'), 'auth_success_rate' => array('oid' => 'ruckusRadioStatsAssocSuccessRate', 'type' => 'gauge'), 'auth_fail_rate' => array('oid' => 'ruckusRadioStatsAuthFailRate', 'type' => 'gauge'), 'max_stations' => array('oid' => 'ruckusRadioStatsMaxSta', 'type' => 'gauge'), 'assoc_fail' => array('oid' => 'ruckusRadioStatsNumAssocFail'), 'assoc_req' => array('oid' => 'ruckusRadioStatsNumAssocReq'), 'assoc_resp' => array('oid' => 'ruckusRadioStatsNumAssocResp'), 'assoc_success' => array('oid' => 'ruckusRadioStatsNumAssocSuccess'), 'auth_fail' => array('oid' => 'ruckusRadioStatsNumAuthFail'), 'auth_req' => array('oid' => 'ruckusRadioStatsNumAuthReq'), 'auth_resp' => array('oid' => 'ruckusRadioStatsNumAuthResp'), 'auth_stations' => array('oid' => 'ruckusRadioStatsNumAuthSta', 'type' => 'gauge'), 'auth_success' => array('oid' => 'ruckusRadioStatsNumAuthSuccess'), 'num_stations' => array('oid' => 'ruckusRadioStatsNumSta', 'type' => 'gauge'), 'resource_util' => array('oid' => 'ruckusRadioStatsResourceUtil', 'type' => 'gauge'), 'rx_bytes' => array('oid' => 'ruckusRadioStatsRxBytes'), 'rx_decrypt_crcerr' => array('oid' => 'ruckusRadioStatsRxDecryptCRCError'), 'rx_errors' => array('oid' => 'ruckusRadioStatsRxErrors'), 'rx_frames' => array('oid' => 'ruckusRadioStatsRxFrames'), 'rx_mic_error' => array('oid' => 'ruckusRadioStatsRxMICError'), 'rx_wep_fail' => array('oid' => 'ruckusRadioStatsRxWEPFail'), 'tx_bytes' => array('oid' => 'ruckusRadioStatsTxBytes'), 'tx_frames' => array('oid' => 'ruckusRadioStatsTxFrames'), 'total_airtime' => array('oid' => 'ruckusRadioStatsTotalAirtime'), 'total_assoc_time' => array('oid' => 'ruckusRadioStatsTotalAssocTime'), 'busy_airtime' => array('oid' => 'ruckusRadioStatsBusyAirtime'));
    $rrd_file = 'wifi-radio-' . $radio['radio_ap'] . '-' . $radio['radio_number'] . '.rrd';
    $rrd_update = 'N';
    $rrd_create = '';
    foreach ($dses as $ds => $ds_data) {
        $oid = $ds_data['oid'];
        $radio[$ds] = $radio[$oid];
        if ($ds_data['type'] == 'gauge') {
            $rrd_create .= ' DS:' . $ds . ':GAUGE:600:U:100000000000';
        } else {
            $rrd_create .= ' DS:' . $ds . ':COUNTER:600:U:100000000000';
        }
        if (is_numeric($radio[$oid])) {
Ejemplo n.º 15
0
                }
            }
            unset($processors_array, $processor, $dot_index, $descr, $i);
            // Clean up
            if (isset($entry['stop_if_found']) && $entry['stop_if_found'] && $entry['found']) {
                break;
            }
            // Stop loop if processor found
        }
    }
}
// Remove processors which weren't redetected here
foreach (dbFetchRows('SELECT * FROM `processors` WHERE `device_id` = ?', array($device['device_id'])) as $test_processor) {
    $processor_index = $test_processor['processor_index'];
    $processor_type = $test_processor['processor_type'];
    $processor_descr = $test_processor['processor_descr'];
    print_debug($processor_index . " -> " . $processor_type);
    if (!$valid['processor'][$processor_type][$processor_index]) {
        $GLOBALS['module_stats'][$module]['deleted']++;
        //echo('-');
        dbDelete('processors', '`processor_id` = ?', array($test_processor['processor_id']));
        log_event("Processor removed: type " . $processor_type . " index " . $processor_index . " descr " . $processor_descr, $device, 'processor', $test_processor['processor_id']);
    }
    unset($processor_oid);
    unset($processor_type);
}
$GLOBALS['module_stats'][$module]['status'] = count($valid['processor']);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) {
    print_vars($valid['processor']);
}
// EOF
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2015 Adam Armstrong
 *
 */
// ProxyAV devices hide their CPUs/Memory/Interfaces in here
echo " BLUECOAT-SG-USAGE-MIB ";
$av_array = snmpwalk_cache_oid($device, "deviceUsage", array(), "BLUECOAT-SG-USAGE-MIB", mib_dirs('bluecoat'));
if (OBS_DEBUG > 1) {
    print_vars($av_array);
}
if (is_array($av_array)) {
    foreach ($av_array as $index => $entry) {
        if (strpos($entry['deviceUsageName'], "Memory") !== false) {
            $descr = $entry['deviceUsageName'];
            $oid = ".1.3.6.1.4.1.3417.2.4.1.1.1.4." . $index;
            $perc = $entry['deviceUsagePercent'];
            discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, 100, $perc);
        }
    }
}
unset($av_array);
// EOF
Ejemplo n.º 17
0
/**
 * Check an entity against all relevant alerts
 *
 * @param string type
 * @param array entity
 * @param array data
 * @return NULL
 */
function check_entity($type, $entity, $data)
{
    global $config, $alert_rules, $alert_table, $device;
    echo "\nChecking alerts\n";
    if ($GLOBALS['debug']) {
        print_vars($data);
    }
    list($entity_table, $entity_id_field, $entity_name_field, $entity_ignore_field) = entity_type_translate($type);
    foreach ($alert_table[$type][$entity[$entity_id_field]] as $alert_test_id => $alert_args) {
        if ($alert_rules[$alert_test_id]['and']) {
            $alert = TRUE;
        } else {
            $alert = FALSE;
        }
        $update_array = array();
        if (is_array($alert_rules[$alert_test_id])) {
            echo "Checking alert " . $alert_test_id . " associated by " . $alert_args['alert_assocs'] . "\n";
            foreach ($alert_rules[$alert_test_id]['conditions'] as $test_key => $test) {
                if (substr($test['value'], 0, 1) == "@") {
                    $ent_val = substr($test['value'], 1);
                    $test['value'] = $entity[$ent_val];
                    echo " replaced @" . $ent_val . " with " . $test['value'] . " from entity. ";
                }
                echo "Testing: " . $test['metric'] . " " . $test['condition'] . " " . $test['value'];
                $update_array['state']['metrics'][$test['metric']] = $data[$test['metric']];
                if (isset($data[$test['metric']])) {
                    echo " (value: " . $data[$test['metric']] . ")";
                    if (test_condition($data[$test['metric']], $test['condition'], $test['value'])) {
                        // A test has failed. Set the alert variable and make a note of what failed.
                        echo " FAIL ";
                        $update_array['state']['failed'][] = $test;
                        if ($alert_rules[$alert_test_id]['and']) {
                            $alert = $alert && TRUE;
                        } else {
                            $alert = $alert || TRUE;
                        }
                    } else {
                        if ($alert_rules[$alert_test_id]['and']) {
                            $alert = $alert && FALSE;
                        } else {
                            $alert = $alert || FALSE;
                        }
                        echo " OK ";
                    }
                } else {
                    echo "  Metric is not present on entity.\n";
                    if ($alert_rules[$alert_test_id]['and']) {
                        $alert = $alert && FALSE;
                    } else {
                        $alert = $alert || FALSE;
                    }
                }
            }
            if ($alert) {
                // Check to see if this alert has been suppressed by anything
                ## FIXME -- not all of this is implemented
                // Have all alerts on the device been suppressed?
                if ($device['ignore']) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "DEV";
                }
                if (is_numeric($device['ignore_until']) && $device['ignore_until'] > time()) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "DEV_UNTIL";
                }
                // Have all alerts on the entity been suppressed?
                if ($entity[$entity_ignore_field]) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "ENTITY";
                }
                if (is_numeric($entity['ignore_until']) && $entity['ignore_until'] > time()) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "ENTITY_UNTIL";
                }
                // Have alerts from this alerter been suppressed?
                if ($alert_rules[$alert_test_id]['ignore']) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "CHECK";
                }
                if (is_numeric($alert_rules[$alert_test_id]['ignore_until']) && $alert_rules[$alert_test_id]['ignore_until'] > time()) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "CHECK_UNTIL";
                }
                // Has this specific alert been suppressed?
                if ($alert_args['ignore']) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "ENTRY";
                }
                if (is_numeric($alert_args['ignore_until']) && $alert_args['ignore_until'] > time()) {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "ENTRY_UNTIL";
                }
                if (is_numeric($alert_args['ignore_until_ok']) && $alert_args['ignore_until_ok'] == '1') {
                    $alert_suppressed = TRUE;
                    $suppressed[] = "ENTRY_UNTIL_OK";
                }
                $update_array['count'] = $alert_args['count'] + 1;
                // Check against the alert test's delay
                if ($update_array['count'] >= $alert_rules[$alert_test_id]['delay'] && $alert_suppressed) {
                    // This alert is valid, but has been suppressed.
                    echo " Checks failed. Alert suppressed (" . implode(', ', $suppressed) . ").\n";
                    $update_array['alert_status'] = '3';
                    $update_array['last_message'] = 'Checks failed (Suppressed: ' . implode(', ', $suppressed) . ')';
                    $update_array['last_checked'] = time();
                    if ($alert_args['alert_status'] != '3' || $alert_args['last_changed'] == '0') {
                        $update_array['last_changed'] = time();
                    }
                    if (!isset($alert_args['last_failed']) || $alert_args['last_failed'] == '0') {
                        $update_array['last_failed'] = time();
                    }
                } elseif ($update_array['count'] >= $alert_rules[$alert_test_id]['delay']) {
                    // This is a real alert.
                    echo " Checks failed. Generate alert.\n";
                    $update_array['alert_status'] = '0';
                    $update_array['last_message'] = 'Checks failed';
                    $update_array['last_checked'] = time();
                    if ($alert_args['alert_status'] != '0' || $alert_args['last_changed'] == '0') {
                        $update_array['last_changed'] = time();
                        $update_array['last_alerted'] = '0';
                    }
                    if (!isset($alert_args['last_failed']) || $alert_args['last_failed'] == '0') {
                        $update_array['last_failed'] = time();
                    }
                } else {
                    // This is alert needs to exist for longer.
                    echo " Checks failed. Delaying alert.\n";
                    $update_array['alert_status'] = '2';
                    $update_array['last_message'] = 'Checks failed (delayed)';
                    $update_array['last_checked'] = time();
                    if ($alert_args['alert_status'] != '2' || $alert_args['last_changed'] == '0') {
                        $update_array['last_changed'] = time();
                    }
                    if (!isset($alert_args['last_failed']) || $alert_args['last_failed'] == '0') {
                        $update_array['last_failed'] = time();
                    }
                }
            } else {
                $update_array['count'] = 0;
                // Alert conditions passed. Record that we tested it and update status and other data.
                echo " Checks OK.\n";
                $update_array['alert_status'] = '1';
                $update_array['last_message'] = 'Checks OK';
                $update_array['last_checked'] = time();
                #$update_array['count'] = 0;
                if ($alert_args['alert_status'] != '1' || $alert_args['last_changed'] == '0') {
                    $update_array['last_changed'] = time();
                }
                // Status is OK, so disable ignore_until_ok if it has been enabled
                if ($alert_args['ignore_until_ok'] != '0') {
                    $update_array['ignore_until_ok'] = '0';
                }
            }
            unset($suppressed);
            unset($alert_suppressed);
            // json_encode the state array before we put it into MySQL.
            $update_array['state'] = json_encode($update_array['state']);
            #$update_array['alert_table_id'] = $alert_args['alert_table_id'];
            /// Perhaps this is better done with SQL replace?
            #print_vars($alert_args);
            if (!$alert_args['state_entry']) {
                // State entry seems to be missing. Insert it before we update it.
                dbInsert(array('alert_table_id' => $alert_args['alert_table_id']), 'alert_table-state');
                echo "INSERTING";
            }
            dbUpdate($update_array, 'alert_table-state', '`alert_table_id` = ?', array($alert_args['alert_table_id']));
        } else {
            echo "Alert missing!";
        }
    }
}
 * @subpackage discovery
 * @copyright  (C) 2006-2015 Adam Armstrong
 *
 */
// Force10 E-Series
// FIXME. Need snmpwalk for total size: F10-CHASSIS-MIB::chSysProcessorMemSize
#F10-CHASSIS-MIB::chRpmMemUsageUtil.1 = 5
#F10-CHASSIS-MIB::chRpmMemUsageUtil.2 = 36
#F10-CHASSIS-MIB::chRpmMemUsageUtil.3 = 9
$mib = 'F10-CHASSIS-MIB';
echo " {$mib} ";
$mempool_array = snmpwalk_cache_oid($device, "chRpmMemUsageUtil", NULL, $mib, mib_dirs('force10'));
if (is_array($mempool_array)) {
    $total_array = snmpwalk_cache_oid($device, "chSysProcessorMemSize.1", NULL, $mib, mib_dirs('force10'));
    if (OBS_DEBUG > 1 && count($total_array)) {
        print_vars($total_array);
    }
    foreach ($mempool_array as $index => $entry) {
        if (is_numeric($entry['chRpmMemUsageUtil'])) {
            if (is_numeric($total_array['1.' . $index]['chSysProcessorMemSize'])) {
                $precision = 1024 * 1024;
                $total = $total_array['1.' . $index]['chSysProcessorMemSize'];
                // FTOS display memory in MB
                $total *= $precision;
            } else {
                $precision = 1;
                $total = 1090519040;
                // Hardcoded total. See FIXME above.
            }
            $percent = $entry['chRpmMemUsageUtil'];
            $used = $total * $percent / 100;
Ejemplo n.º 19
0
    var_dump($GLOBALS['cache']['discovery-protocols']);
}
$table_rows = array();
$neighbours_db = dbFetchRows('SELECT * FROM `neighbours` LEFT JOIN `ports` USING(`port_id`) WHERE `device_id` = ?', array($device['device_id']));
foreach ($neighbours_db as $neighbour) {
    $local_port_id = $neighbour['port_id'];
    $remote_hostname = $neighbour['remote_hostname'];
    $remote_port = $neighbour['remote_port'];
    print_debug("{$local_port_id} -> {$remote_hostname} -> {$remote_port}");
    if (!$valid['neighbours'][$local_port_id][$remote_hostname][$remote_port]) {
        dbDelete('neighbours', '`neighbour_id` = ?', array($neighbour['neighbour_id']));
        $GLOBALS['module_stats'][$module]['deleted']++;
    } else {
        $port = get_port_by_id_cache($local_port_id);
        if (is_numeric($neighbour['remote_port_id'])) {
            $remote_port_array = get_port_by_id_cache($neighbour['remote_port_id']);
            $remote_port = $remote_port_array['port_label'];
        }
        $table_rows[] = array(nicecase($neighbour['protocol']), $port['port_label'], $remote_hostname, $remote_port, truncate($neighbour['remote_platform'], 20), truncate($neighbour['remote_version'], 40));
    }
}
echo PHP_EOL;
$table_headers = array('%WProtocol%n', '%WifName%n', '%WRemote: hostname%n', '%Wport%n', '%Wplatform%n', '%Wversion%n');
print_cli_table($table_rows, $table_headers);
$GLOBALS['module_stats'][$module]['status'] = count($valid[$module]);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) {
    print_vars($valid[$module]);
}
unset($valid['neighbours']);
echo PHP_EOL;
// EOF
Ejemplo n.º 20
0
     }
     # Vendors
 } else {
     echo "No BGP on host";
     if (is_numeric($device['bgpLocalAs'])) {
         log_event('BGP ASN removed: AS' . $device['bgpLocalAs'], $device, 'bgp');
         dbUpdate(array('bgpLocalAs' => array('NULL')), 'devices', 'device_id = ?', array($device['device_id']));
         print_message('Removed ASN (' . $device['bgpLocalAs'] . ')');
     }
     # End if
 }
 # End if
 // Process discovered peers
 $table_rows = array();
 if (OBS_DEBUG > 1) {
     print_vars($peerlist);
 }
 if (isset($peerlist)) {
     // Walk vendor oids
     if ($vendor_mib) {
         if (!isset($vendor_use_index[$vendor_PeerRemoteAddrType])) {
             $vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerRemoteAddrType, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
         }
         if ($vendor_PeerIndex && !isset($vendor_use_index[$vendor_PeerIndex])) {
             $vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerIndex, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
         }
         $vendor_counters = snmpwalk_cache_oid($device, $vendor_PrefixCountersSafi, array(), $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
     }
     echo PHP_EOL;
     foreach ($peerlist as $peer) {
         $astext = get_astext($peer['as']);
Ejemplo n.º 21
0
<?php

echo "Ports : ";
// Build SNMP Cache Array
$port_stats = array();
$port_stats = snmpwalk_cache_oid($device, "ifDescr", $port_stats, "IF-MIB");
$port_stats = snmpwalk_cache_oid($device, "ifAlias", $port_stats, "IF-MIB");
$port_stats = snmpwalk_cache_oid($device, "ifName", $port_stats, "IF-MIB");
$port_stats = snmpwalk_cache_oid($device, "ifType", $port_stats, "IF-MIB");
// End Building SNMP Cache Array
if ($debug) {
    print_vars($port_stats);
}
// Build array of ports in the database
// FIXME -- this stuff is a little messy, looping the array to make an array just seems wrong. :>
//       -- i can make it a function, so that you don't know what it's doing.
//       -- $ports_db = adamasMagicFunction($ports_db); ?
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port) {
    $ports_db[$port['ifIndex']] = $port;
    $ports_db_l[$port['ifIndex']] = $port['port_id'];
}
// New interface detection
foreach ($port_stats as $ifIndex => $port) {
    // Check the port against our filters.
    if (is_port_valid($port, $device)) {
        if (!is_array($ports_db[$ifIndex])) {
            $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifAlias' => $port['ifAlias'], 'ifDescr' => $port['ifDescr'], 'ifName' => $port['ifName'], 'ifType' => $port['ifType']), 'ports');
            $ports_db[$ifIndex] = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
            echo " " . $port['ifName'] . "(" . $ifIndex . ")[" . $ports_db[$ifIndex]['port_id'] . "]";
        } elseif ($ports_db[$ifIndex]['deleted'] == "1") {
            dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports_db[$ifIndex]['port_id']));
Ejemplo n.º 22
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Plugins
if (!empty($agent_data['munin'])) {
    echo "Munin Plugins:";
    if ($debug) {
        print_vars($agent_data['munin']);
    }
    // Build cache of plugins we already know about
    foreach (dbFetchRows('SELECT * FROM `munin_plugins` WHERE `device_id` = ?', array($device['device_id'])) as $plugin) {
        $plugins[$plugin['mplug_type']] = $plugin;
    }
    // Build cache of plugin datasources we already know about
    foreach (dbFetchRows('SELECT * FROM `munin_plugins_ds` AS D, `munin_plugins` AS P WHERE P.`mplug_id` = D.`mplug_id` AND P.`device_id` = ?', array($device['device_id'])) as $plugin_ds) {
        $plugins_ds[$plugin_ds['mplug_id']][$plugin_ds['ds_name']] = $plugin_ds;
    }
    $old_plugins_rrd_dir = $host_rrd . "/plugins";
    $plugins_rrd_dir = $host_rrd . "/munin";
    if (is_dir($old_plugins_rrd_dir) && !is_dir($plugins_rrd_dir)) {
        rename($old_plugins_dir, $plugins_dir);
    }
    // CLEANME Remove rename in r6000
Ejemplo n.º 23
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo " FOUNDRY-SN-AGENT-MIB ";
$processors_array = snmpwalk_cache_triple_oid($device, "snAgentCpuUtilEntry", $processors_array, "FOUNDRY-SN-AGENT-MIB", mib_dirs('foundry'));
if ($debug) {
    print_vars($processors_array);
}
foreach ($processors_array as $index => $entry) {
    if ((isset($entry['snAgentCpuUtilValue']) || isset($entry['snAgentCpuUtil100thPercent'])) && $entry['snAgentCpuUtilInterval'] == "300") {
        #$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
        if ($entry['snAgentCpuUtil100thPercent']) {
            $usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.6." . $index;
            $usage = $entry['snAgentCpuUtil100thPercent'];
            $precision = 100;
        } elseif ($entry['snAgentCpuUtilValue']) {
            $usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.4." . $index;
            $usage = $entry['snAgentCpuUtilValue'];
            $precision = 100;
        }
        list($slot, $instance, $interval) = explode(".", $index);
        $descr_oid = "snAgentConfigModuleDescription." . $entry['snAgentCpuUtilSlotNum'];
Ejemplo n.º 24
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage discovery
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$mtxrSerialNumber = snmp_get($device, 'mtxrSerialNumber.0', '-Oqvn', 'MIKROTIK-MIB');
$system_index = 1;
if ($mtxrSerialNumber) {
    $inventory[$system_index] = array('entPhysicalDescr' => 'MikroTik RouterBoard', 'entPhysicalClass' => 'chassis', 'entPhysicalName' => '', 'entPhysicalSerialNum' => $mtxrSerialNumber, 'entPhysicalAssetID' => '', 'entPhysicalIsFRU' => 'false', 'entPhysicalContainedIn' => 0, 'entPhysicalParentRelPos' => 0, 'entPhysicalMfgName' => 'MikroTik');
    discover_inventory($valid['inventory'], $device, $system_index, $inventory[$system_index], "MIKROTIK-MIB");
    if (OBS_DEBUG > 1 && count($inventory)) {
        print_vars($inventory);
    }
}
// EOF
Ejemplo n.º 25
0
 *
 */
// mtxrNeighborIpAddress.1 = IpAddress: 192.168.4.27
// mtxrNeighborMacAddress.1 = STRING: 0:23:ac:53:3:28
// mtxrNeighborVersion.1 = STRING: Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(1)SE2, RELEASE SOFTWARE (fc3)
// Technical Support: http://www.cisco.com/techsupport
// Copyright (c) 1986-2011 by Cisco Systems, Inc.
// Compiled Thu 22-Dec-11 00:46 by prod_rel_team
// mtxrNeighborPlatform.1 = STRING: cisco WS-C2960G-48TC-L
// mtxrNeighborIdentity.1 = STRING: switch.example.com
// mtxrNeighborSoftwareID.1 = STRING:
// mtxrNeighborInterfaceID.1 = INTEGER: 2
$mtxr_array = snmpwalk_cache_oid($device, "mtxrNeighbor", array(), "MIKROTIK-MIB", NULL, OBS_SNMP_ALL | OBS_SNMP_CONCAT);
if ($mtxr_array) {
    if (OBS_DEBUG > 1) {
        print_vars($mtxr_array);
    }
    foreach ($mtxr_array as $key => $entry) {
        // Need to straighten out the MAC first for use later. Mikrotik does not pad the numbers! (i.e. 0:12:23:3:5c:6b)
        // FIXME move this to a smarter function?
        list($a, $b, $c, $d, $e, $f) = explode(':', $entry['mtxrNeighborMacAddress'], 6);
        $entry['mtxrNeighborMacAddress'] = zeropad($a) . ':' . zeropad($b) . ':' . zeropad($c) . ':' . zeropad($d) . ':' . zeropad($e) . ':' . zeropad($f);
        $ifIndex = $entry['mtxrNeighborInterfaceID'];
        // Get the port using BRIDGE-MIB
        $port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", array($device['device_id'], $ifIndex));
        $remote_device_id = FALSE;
        $remote_port_id = 0;
        if (is_valid_hostname($entry['mtxrNeighborIdentity'])) {
            if (isset($GLOBALS['cache']['discovery-protocols'][$entry['mtxrNeighborIdentity']])) {
                // This hostname already checked, skip discover
                $remote_device_id = $GLOBALS['cache']['discovery-protocols'][$entry['mtxrNeighborIdentity']];
Ejemplo n.º 26
0
/// FIXME. From this uses only check_valid_sensors(), maybe need move to global functions or copy to polling. --mike
include_once "includes/discovery/functions.inc.php";
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['port'] = get_dev_attrib($device, 'ipmi_port');
    $ipmi['interface'] = get_dev_attrib($device, 'ipmi_interface');
    $ipmi['userlevel'] = get_dev_attrib($device, 'ipmi_userlevel');
    if (!is_numeric($ipmi['port'])) {
        $ipmi['port'] = 623;
    }
    if ($ipmi['userlevel'] == '') {
        $ipmi['userlevel'] = 'USER';
    }
    if (array_search($ipmi['interface'], array_keys($config['ipmi']['interfaces'])) === FALSE) {
        $ipmi['interface'] = 'lan';
    }
    // Also triggers on empty value
    if ($config['own_hostname'] != $device['hostname'] || $ipmi['host'] != 'localhost') {
        $remote = " -I " . escapeshellarg($ipmi['interface']) . " -p " . $ipmi['port'] . " -H " . escapeshellarg($ipmi['host']) . " -L " . escapeshellarg($ipmi['userlevel']) . " -U " . escapeshellarg($ipmi['user']) . " -P " . escapeshellarg($ipmi['password']);
    }
    $results = external_exec($config['ipmitool'] . $remote . " sensor 2>/dev/null");
    $ipmi_sensors = parse_ipmitool_sensor($device, $results);
}
if (OBS_DEBUG) {
    print_vars($ipmi_sensors);
}
foreach ($config['ipmi_unit'] as $type) {
    check_valid_sensors($device, $type, $ipmi_sensors, 'ipmi');
}
// EOF
Ejemplo n.º 27
0
// Only run this on Cisco kit.
// Seems this MIB supported only in IOS Catalyst 6k/7k. See ftp://ftp.cisco.com/pub/mibs/supportlists/
// IOS 3560:  ftp://ftp.cisco.com/pub/mibs/supportlists/cat3560/cat3560-supportlist.html
// IOS 6k/7k: ftp://ftp.cisco.com/pub/mibs/supportlists/cisco7606/cisco7606-supportlist.html
// IOS-XE:    ftp://ftp.cisco.com/pub/mibs/supportlists/cat4000/cat4000-supportlist.html
//            ftp://ftp.cisco.com/pub/mibs/supportlists/asr1000/asr1000-supportlist.html
// IOS-XR:    ftp://ftp.cisco.com/pub/mibs/supportlists/asr9000/asr9000-supportlist.html
// ASA:       ftp://ftp.cisco.com/pub/mibs/supportlists/asa/asa-supportlist.html
if (is_device_mib($device, 'CISCO-EIGRP-MIB')) {
    $port_db_q = dbFetchRows('SELECT * FROM `eigrp_ports` WHERE `device_id` = ?', array($device['device_id']));
    $port_db = array();
    foreach ($port_db_q as $db_port) {
        $port_db[$db_port['eigrp_vpn'] . '-' . $db_port['eigrp_as'] . '-' . $db_port['eigrp_ifIndex']] = $db_port;
    }
    if (OBS_DEBUG && count($port_db)) {
        print_vars($port_db);
    }
    $device_context = $device;
    if (!count($port_db) && !preg_match('/[a-z](60|65|76)\\d{2}/i', $device['hardware'])) {
        // Since I'm not sure that this MIB supported on other platforms, set retry to 0 for speedup
        $device_context['snmp_retries'] = 0;
    }
    $ports_poll = snmpwalk_cache_oid($device_context, 'CEigrpInterfaceEntry', array(), 'CISCO-EIGRP-MIB');
    unset($device_context);
    foreach ($ports_poll as $id => $eigrp_port) {
        list($vpn, $as, $ifIndex) = explode('.', $id);
        echo "{$vpn} {$as} {$ifIndex}" . PHP_EOL;
        $port = get_port_by_index_cache($device['device_id'], $ifIndex);
        if (is_array($port_db[$vpn . '-' . $as . '-' . $ifIndex])) {
            $eigrp_update = NULL;
            if ($port['port_id'] != $port_db[$vpn . '-' . $as . '-' . $ifIndex]['port_id']) {
Ejemplo n.º 28
0
        $limits = array('limit_high' => $entry['npRelHumSafeRangeHigh'], 'limit_low' => $entry['npRelHumSafeRangeLow']);
        discover_sensor($valid['sensor'], 'humidity', $device, $oid, "npRelHumValue.{$index}", 'dskf-mib', $descr, 1, $value, $limits);
    }
}
$cache_discovery['DKSF-50-11-X-X-X']['thermo'] = snmpwalk_cache_multi_oid($device, 'npThermoTable', array(), 'DKSF-50-11-X-X-X');
foreach ($cache_discovery['DKSF-50-11-X-X-X']['thermo'] as $index => $entry) {
    // Temperature
    $descr = $entry['npThermoMemo'] ? $entry['npThermoMemo'] : 'Thermo ' . $index;
    $value = $entry['npThermoValue'];
    if ($value && $entry['npThermoStatus'] != 'failed') {
        $oid = '.1.3.6.1.4.1.25728.8800.1.1.2.' . $index;
        $limits = array('limit_high' => $entry['npThermoHigh'], 'limit_low' => $entry['npThermoLow']);
        discover_sensor($valid['sensor'], 'temperature', $device, $oid, "npThermoValue.{$index}", 'dskf-mib', $descr, 1, $value, $limits);
    }
}
$cache_discovery['DKSF-50-11-X-X-X']['io'] = snmpwalk_cache_multi_oid($device, 'npIoTable', array(), 'DKSF-50-11-X-X-X');
foreach ($cache_discovery['DKSF-50-11-X-X-X']['io'] as $index => $entry) {
    if ($entry['npIoLevelIn'] == '0') {
        continue;
    }
    $descr = $entry['npIoMemo'] ? $entry['npIoMemo'] : 'Pulse Counter ' . $index;
    $descr .= ' (' . $entry['npIoSinglePulseDuration'] . 'ms)';
    $value = $entry['npIoPulseCounter'];
    $oid = '.1.3.6.1.4.1.25728.8900.1.1.9.' . $index;
    discover_sensor($valid['sensor'], 'counter', $device, $oid, "npIoPulseCounter.{$index}", 'dskf-mib', $descr, 1, $value);
}
if (OBS_DEBUG > 1 && count($cache_discovery['DKSF-50-11-X-X-X'])) {
    print_vars($cache_discovery['DKSF-50-11-X-X-X']);
}
unset($cache_discovery['DKSF-50-11-X-X-X']);
// EOF
Ejemplo n.º 29
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$rrd_filename = get_rrd_path($device, "juniperive_users.rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Cluster";
$rrd_list[0]['ds'] = "clusterusers";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Local";
$rrd_list[1]['ds'] = "iveusers";
if ($_GET['debug']) {
    print_vars($rrd_list);
}
$colours = "juniperive";
$nototal = 1;
$unit_text = "Users";
$scale_min = "0";
include "includes/graphs/generic_multi_line.inc.php";
Ejemplo n.º 30
0
 if ($GLOBALS['snmp_status']) {
     $cef_pfxs = snmpwalk_cache_twopart_oid($device, 'cefFIBSummaryEntry', array(), 'CISCO-CEF-MIB');
     if (!is_array($entity_array)) {
         echo 'Caching OIDs: ';
         $entity_array = array();
         echo ' entPhysicalDescr';
         $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalDescr', $entity_array, 'ENTITY-MIB');
         echo ' entPhysicalName';
         $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalName', $entity_array, 'ENTITY-MIB');
         echo ' entPhysicalModelName';
         $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalModelName', $entity_array, 'ENTITY-MIB');
     }
     $polled = time();
 }
 if (OBS_DEBUG > 1 && count($cefs)) {
     print_vars($cefs);
 }
 foreach ($cefs as $entity => $afis) {
     $entity_name = $entity_array[$entity]['entPhysicalName'] . ' - ' . $entity_array[$entity]['entPhysicalModelName'];
     echo "\n{$entity} {$entity_name}\n";
     foreach ($afis as $afi => $paths) {
         echo " |- {$afi} ";
         // Do Per-AFI entity summary
         // FIXME -- memory tables
         if (!isset($cef_pfxs_db[$entity][$afi])) {
             dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi), 'cef_prefix');
             echo '+';
         }
         unset($cef_pfxs_db[$entity][$afi]);
         $cef_pfx['update']['cef_pfx'] = $cef_pfxs[$entity][$afi]['cefFIBSummaryFwdPrefixes'];
         dbUpdate($cef_pfx['update'], 'cef_prefix', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ?', array($device['device_id'], $entity, $afi));