Exemple #1
0
$polled = time();
// End Building SNMP Cache Array
d_echo($port_stats);
// By default libreNMS uses the ifIndex to associate ports on devices with ports discoverd/polled
// before and stored in the database. On Linux boxes this is a problem as ifIndexes may be
// unstable between reboots or (re)configuration of tunnel interfaces (think: GRE/OpenVPN/Tinc/...)
// The port association configuration allows to choose between association via ifIndex, ifName,
// or maybe other means in the future. The default port association mode still is ifIndex for
// compatibility reasons.
$port_association_mode = $config['default_port_association_mode'];
if ($device['port_association_mode']) {
    $port_association_mode = get_port_assoc_mode_name($device['port_association_mode']);
}
// Query known ports and mapping table in order of discovery to make sure
// the latest discoverd/polled port is in the mapping tables.
$ports_mapped = get_ports_mapped($device['device_id'], true);
$ports = $ports_mapped['ports'];
//
// Rename any old RRD files still named after the previous ifIndex based naming schema.
foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) {
    foreach (array('', '-adsl', '-dot3') as $suffix) {
        $old_rrd_name = "port-{$ifIndex}{$suffix}.rrd";
        $new_rrd_name = getPortRrdName($port_id, ltrim($suffix, '-'));
        rrd_file_rename($device, $old_rrd_name, $new_rrd_name);
    }
}
$ports_found = array();
// New interface detection
foreach ($port_stats as $ifIndex => $port) {
    // Store ifIndex in port entry and prefetch ifName as we'll need it multiple times
    $port['ifIndex'] = $ifIndex;
Exemple #2
0
$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
d_echo($port_stats);
// By default libreNMS uses the ifIndex to associate ports on devices with ports discoverd/polled
// before and stored in the database. On Linux boxes this is a problem as ifIndexes may be
// unstable between reboots or (re)configuration of tunnel interfaces (think: GRE/OpenVPN/Tinc/...)
// The port association configuration allows to choose between association via ifIndex, ifName,
// or maybe other means in the future. The default port association mode still is ifIndex for
// compatibility reasons.
$port_association_mode = $config['default_port_association_mode'];
if ($device['port_association_mode']) {
    $port_association_mode = get_port_assoc_mode_name($device['port_association_mode']);
}
// Build array of ports in the database and an ifIndex/ifName -> port_id map
$ports_mapped = get_ports_mapped($device['device_id']);
$ports_db = $ports_mapped['ports'];
//
// Rename any old RRD files still named after the previous ifIndex based naming schema.
foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) {
    foreach (array('', 'adsl', 'dot3') as $suffix) {
        $suffix_tmp = '';
        if ($suffix) {
            $suffix_tmp = "-{$suffix}";
        }
        $old_rrd_path = trim($config['rrd_dir']) . '/' . $device['hostname'] . "/port-{$ifIndex}{$suffix_tmp}.rrd";
        $new_rrd_path = get_port_rrdfile_path($device['hostname'], $port_id, $suffix);
        if (is_file($old_rrd_path)) {
            rename($old_rrd_path, $new_rrd_path);
        }
    }