Esempio n. 1
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 ';
}
Esempio n. 2
0
function get_port_rrdfile_path($hostname, $port_id, $suffix = '')
{
    return rrd_name($hostname, getPortRrdName($port_id, $suffix));
}
Esempio n. 3
0
 }
 echo 'bps(' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ')';
 echo 'bytes(' . formatStorage($port['stats']['ifInOctets_diff']) . '/' . formatStorage($port['stats']['ifOutOctets_diff']) . ')';
 echo 'pkts(' . format_si($port['stats']['ifInUcastPkts_rate']) . 'pps/' . format_si($port['stats']['ifOutUcastPkts_rate']) . 'pps)';
 // Port utilisation % threshold alerting. // FIXME allow setting threshold per-port. probably 90% of ports we don't care about.
 if ($config['alerts']['port_util_alert'] && $port['ignore'] == '0') {
     // Check for port saturation of $config['alerts']['port_util_perc'] or higher.  Alert if we see this.
     // Check both inbound and outbound rates
     $saturation_threshold = $this_port['ifSpeed'] * ($config['alerts']['port_util_perc'] / 100);
     echo 'IN: ' . $port['stats']['ifInBits_rate'] . ' OUT: ' . $port['stats']['ifOutBits_rate'] . ' THRESH: ' . $saturation_threshold;
     if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) {
         log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates($this_port['stats']['ifSpeed']), $device, 'interface', $port['port_id']);
     }
 }
 // Update data stores
 $rrd_name = getPortRrdName($port_id);
 $rrdfile = rrd_name($device['hostname'], $rrd_name);
 $rrd_def = array('DS:INOCTETS:DERIVE:600:0:12500000000', 'DS:OUTOCTETS:DERIVE:600:0:12500000000', 'DS:INERRORS:DERIVE:600:0:12500000000', 'DS:OUTERRORS:DERIVE:600:0:12500000000', 'DS:INUCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTUCASTPKTS:DERIVE:600:0:12500000000', 'DS:INNUCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000', 'DS:INDISCARDS:DERIVE:600:0:12500000000', 'DS:OUTDISCARDS:DERIVE:600:0:12500000000', 'DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000', 'DS:INBROADCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000', 'DS:INMULTICASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000');
 $fields = array('INOCTETS' => $this_port['ifInOctets'], 'OUTOCTETS' => $this_port['ifOutOctets'], 'INERRORS' => $this_port['ifInErrors'], 'OUTERRORS' => $this_port['ifOutErrors'], 'INUCASTPKTS' => $this_port['ifInUcastPkts'], 'OUTUCASTPKTS' => $this_port['ifOutUcastPkts'], 'INNUCASTPKTS' => $this_port['ifInNUcastPkts'], 'OUTNUCASTPKTS' => $this_port['ifOutNUcastPkts'], 'INDISCARDS' => $this_port['ifInDiscards'], 'OUTDISCARDS' => $this_port['ifOutDiscards'], 'INUNKNOWNPROTOS' => $this_port['ifInUnknownProtos'], 'INBROADCASTPKTS' => $this_port['ifInBroadcastPkts'], 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'], 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'], 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts']);
 if ($tune_port === true) {
     rrdtool_tune('port', $rrdfile, $this_port['ifSpeed']);
 }
 $port_descr_type = $port['port_descr_type'];
 $ifName = $port['ifName'];
 $tags = compact('ifName', 'port_descr_type', 'rrd_name', 'rrd_def');
 rrdtool_data_update($device, 'ports', $tags, $fields);
 $fields['ifInUcastPkts_rate'] = $port['ifInUcastPkts_rate'];
 $fields['ifOutUcastPkts_rate'] = $port['ifOutUcastPkts_rate'];
 $fields['ifInErrors_rate'] = $port['ifInErrors_rate'];
 $fields['ifOutErrors_rate'] = $port['ifOutErrors_rate'];
 $fields['ifInOctets_rate'] = $port['ifInOctets_rate'];
Esempio n. 4
0
// adslAturChanCurrTxRate.1 = 512000 bps
// adslAturChanPrevTxRate.1 = 0 bps
// adslAtucPerfLofs.1 = 0
// adslAtucPerfLoss.1 = 0
// adslAtucPerfLols.1 = 0
// adslAtucPerfLprs.1 = 0
// adslAtucPerfESs.1 = 0
// adslAtucPerfInits.1 = 1
// adslAtucPerfValidIntervals.1 = 0
// adslAtucPerfInvalidIntervals.1 = 0
// adslAturPerfLoss.1 = 0 seconds
// adslAturPerfESs.1 = 0 seconds
// adslAturPerfValidIntervals.1 = 0
// adslAturPerfInvalidIntervals.1 = 0
if (isset($this_port['adslLineCoding'])) {
    $rrd_name = getPortRrdName($port_id, 'adsl');
    $rrd_def = array('DS:AtucCurrSnrMgn:GAUGE:600:0:635', 'DS:AtucCurrAtn:GAUGE:600:0:635', 'DS:AtucCurrOutputPwr:GAUGE:600:0:635', 'DS:AtucCurrAttainableR:GAUGE:600:0:U', 'DS:AtucChanCurrTxRate:GAUGE:600:0:U', 'DS:AturCurrSnrMgn:GAUGE:600:0:635', 'DS:AturCurrAtn:GAUGE:600:0:635', 'DS:AturCurrOutputPwr:GAUGE:600:0:635', 'DS:AturCurrAttainableR:GAUGE:600:0:U', 'DS:AturChanCurrTxRate:GAUGE:600:0:U', 'DS:AtucPerfLofs:COUNTER:600:U:100000000000', 'DS:AtucPerfLoss:COUNTER:600:U:100000000000', 'DS:AtucPerfLprs:COUNTER:600:U:100000000000', 'DS:AtucPerfESs:COUNTER:600:U:100000000000', 'DS:AtucPerfInits:COUNTER:600:U:100000000000', 'DS:AturPerfLofs:COUNTER:600:U:100000000000', 'DS:AturPerfLoss:COUNTER:600:U:100000000000', 'DS:AturPerfLprs:COUNTER:600:U:100000000000', 'DS:AturPerfESs:COUNTER:600:U:100000000000', 'DS:AtucChanCorrectedBl:COUNTER:600:U:100000000000', 'DS:AtucChanUncorrectBl:COUNTER:600:U:100000000000', 'DS:AturChanCorrectedBl:COUNTER:600:U:100000000000', 'DS:AturChanUncorrectBl:COUNTER:600:U:100000000000');
    $adsl_oids = array('AtucCurrSnrMgn', 'AtucCurrAtn', 'AtucCurrOutputPwr', 'AtucCurrAttainableRate', 'AtucChanCurrTxRate', 'AturCurrSnrMgn', 'AturCurrAtn', 'AturCurrOutputPwr', 'AturCurrAttainableRate', 'AturChanCurrTxRate', 'AtucPerfLofs', 'AtucPerfLoss', 'AtucPerfLprs', 'AtucPerfESs', 'AtucPerfInits', 'AturPerfLofs', 'AturPerfLoss', 'AturPerfLprs', 'AturPerfESs', 'AtucChanCorrectedBlks', 'AtucChanUncorrectBlks', 'AturChanCorrectedBlks', 'AturChanUncorrectBlks');
    $adsl_db_oids = array('adslLineCoding', 'adslLineType', 'adslAtucInvVendorID', 'adslAtucInvVersionNumber', 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAturInvSerialNumber', 'adslAturInvVendorID', 'adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate');
    $adsl_tenth_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr');
    foreach ($adsl_tenth_oids as $oid) {
        $this_port[$oid] = $this_port[$oid] / 10;
    }
    if (dbFetchCell('SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?', array($port_id)) == '0') {
        dbInsert(array('port_id' => $port_id), 'ports_adsl');
    }
    $port['adsl_update'] = array('port_adsl_updated' => array('NOW()'));
    foreach ($adsl_db_oids as $oid) {
        $data = str_replace('"', '', $this_port[$oid]);
        // FIXME - do we need this?
        $port['adsl_update'][$oid] = $data;
Esempio n. 5
0
<?php

$cpe_oids = array('cpeExtPsePortEnable', 'cpeExtPsePortDiscoverMode', 'cpeExtPsePortDeviceDetected', 'cpeExtPsePortIeeePd', 'cpeExtPsePortAdditionalStatus', 'cpeExtPsePortPwrMax', 'cpeExtPsePortPwrAllocated', 'cpeExtPsePortPwrAvailable', 'cpeExtPsePortPwrConsumption', 'cpeExtPsePortMaxPwrDrawn', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortPolicingCapable', 'cpeExtPsePortPolicingEnable', 'cpeExtPsePortPolicingAction', 'cpeExtPsePortPwrManAlloc');
$peth_oids = array('pethPsePortAdminEnable', 'pethPsePortPowerPairsControlAbility', 'pethPsePortPowerPairs', 'pethPsePortDetectionStatus', 'pethPsePortPowerPriority', 'pethPsePortMPSAbsentCounter', 'pethPsePortType', 'pethPsePortPowerClassifications', 'pethPsePortInvalidSignatureCounter', 'pethPsePortPowerDeniedCounter', 'pethPsePortOverLoadCounter', 'pethPsePortShortCounter', 'pethMainPseConsumptionPower');
if ($this_port['dot3StatsIndex'] && $port['ifType'] == 'ethernetCsmacd') {
    $rrd_name = getPortRrdName($port_id, 'poe');
    $rrd_def = array('DS:PortPwrAllocated:GAUGE:600:0:U', 'DS:PortPwrAvailable:GAUGE:600:0:U', 'DS:PortConsumption:DERIVE:600:0:U', 'DS:PortMaxPwrDrawn:GAUGE:600:0:U');
    $upd = "{$polled}:" . $port['cpeExtPsePortPwrAllocated'] . ':' . $port['cpeExtPsePortPwrAvailable'] . ':' . $port['cpeExtPsePortPwrConsumption'] . ':' . $port['cpeExtPsePortMaxPwrDrawn'];
    $fields = array('PortPwrAllocated' => $port['cpeExtPsePortPwrAllocated'], 'PortPwrAvailable' => $port['cpeExtPsePortPwrAvailable'], 'PortConsumption' => $port['cpeExtPsePortPwrConsumption'], 'PortMaxPwrDrawn' => $port['cpeExtPsePortMaxPwrDrawn']);
    $tags = compact('ifName', 'rrd_name', 'rrd_def');
    data_update($device, 'poe', $tags, $fields);
    echo 'PoE ';
}
//end if
Esempio n. 6
0
// 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) {
        $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);
    }
}
// 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;
    $ifName = $port['ifName'];
    // Get port_id according to port_association_mode used for this device
    $port_id = get_port_id($ports_mapped, $port, $port_association_mode);
    if (is_port_valid($port, $device)) {
        // Port newly discovered?
        if (!is_array($ports_db[$port_id])) {
            $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifName' => $ifName), 'ports');
            $ports[$port_id] = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port_id));