initial commit; version 22.5.12042

This commit is contained in:
2022-12-12 23:28:25 -05:00
commit af1b03d79f
17653 changed files with 22692970 additions and 0 deletions

View File

@ -0,0 +1,37 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// ADSL-LINE-MIB stats
$port_module = 'adsl';
if ($ports_modules[$port_module] && $port_stats_count &&
dbExist('ports', '`device_id` = ? AND `ifType` IN (?, ?, ?)', [ $device['device_id'], 'adsl', 'vdsl', 'vdsl2' ])) {
echo("ADSL ");
$adsl_oids = [ 'adslAtucPhysEntry', 'adslAturPhysEntry', 'adslAtucChanEntry',
'adslAturChanEntry', 'adslAtucPerfDataEntry', 'adslAturPerfDataEntry' ];
$port_stats = snmpwalk_cache_oid($device, 'adslLineEntry', $port_stats, "ADSL-LINE-MIB");
$process_port_functions[$port_module] = snmp_status();
if (snmp_status()) {
foreach ($adsl_oids as $oid) {
$port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "ADSL-LINE-MIB");
}
}
print_debug_vars($port_stats);
// VDSL2-LINE-MIB
} else {
return FALSE; // False for do not collect stats
}
// EOF

View File

@ -0,0 +1,139 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// ADSL-LINE-MIB functions
// Example snmpwalk with units
// "Interval" oids have been filtered out
# adslLineCoding.1 = dmt
# adslLineType.1 = fastOrInterleaved
# adslLineSpecific.1 = zeroDotZero
# adslLineConfProfile.1 = "qwer"
# adslAtucInvSerialNumber.1 = "IES-1000 AAM1008-61"
# adslAtucInvVendorID.1 = "4"
# adslAtucInvVersionNumber.1 = "0"
# adslAtucCurrSnrMgn.1 = 150 tenth dB
# adslAtucCurrAtn.1 = 20 tenth dB
# adslAtucCurrStatus.1 = "00 00 "
# adslAtucCurrOutputPwr.1 = 100 tenth dBm
# adslAtucCurrAttainableRate.1 = 10272000 bps
# adslAturInvVendorID.1 = "0"
# adslAturInvVersionNumber.1 = "0"
# adslAturCurrSnrMgn.1 = 210 tenth dB
# adslAturCurrAtn.1 = 20 tenth dB
# adslAturCurrStatus.1 = "00 00 "
# adslAturCurrOutputPwr.1 = 0 tenth dBm
# adslAturCurrAttainableRate.1 = 1056000 bps
# adslAtucChanInterleaveDelay.1 = 6 milli-seconds
# adslAtucChanCurrTxRate.1 = 8064000 bps
# adslAtucChanPrevTxRate.1 = 0 bps
# adslAturChanInterleaveDelay.1 = 9 milli-seconds
# 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
function process_port_adsl(&$this_port, $device, $port) {
// Check to make sure Port data is cached.
if (!isset($this_port['adslLineCoding'])) { return; }
// Used below for StatsD only
$adsl_oids = [
'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAtucChanCurrTxRate',
'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate', 'adslAturChanCurrTxRate',
'adslAtucPerfLofs', 'adslAtucPerfLoss', 'adslAtucPerfLprs', 'adslAtucPerfESs', 'adslAtucPerfInits',
'adslAturPerfLofs', 'adslAturPerfLoss', 'adslAturPerfLprs', 'adslAturPerfESs',
'adslAtucChanCorrectedBlks', 'adslAtucChanUncorrectBlks',
'adslAturChanCorrectedBlks', 'adslAturChanUncorrectBlks'
];
$adsl_db_oids = [
'adslLineCoding', 'adslLineType',
'adslAtucInvVendorID', 'adslAtucInvVersionNumber', 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate',
'adslAturInvSerialNumber', 'adslAturInvVendorID', 'adslAturInvVersionNumber',
'adslAtucChanCurrTxRate', 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate'
];
$adsl_tenth_oids = [ 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr' ];
foreach ($adsl_tenth_oids as $oid) {
if (isset($this_port[$oid])) {
$this_port[$oid] = $this_port[$oid] / 10;
}
}
if (!dbExist('ports_adsl', '`port_id` = ?', array($port['port_id']))) {
dbInsert([ 'device_id' => $device['device_id'], 'port_id' => $port['port_id'] ], 'ports_adsl');
}
$adsl_port = dbFetchRow('SELECT * FROM `ports_adsl` WHERE `port_id` = ?', [ $port['port_id'] ]);
$adsl_update = [];
foreach ($adsl_db_oids as $oid) {
if ($adsl_port[$oid] != $this_port[$oid]) {
$adsl_update[$oid] = $this_port[$oid];
}
}
if (count($adsl_update)) {
$adsl_update['port_adsl_updated'] = [ 'NOW()' ];
dbUpdate($adsl_update, 'ports_adsl', '`port_id` = ?', [ $port['port_id'] ]);
}
if ($this_port['adslAtucCurrSnrMgn'] > "1280") { $this_port['adslAtucCurrSnrMgn'] = "U"; }
if ($this_port['adslAturCurrSnrMgn'] > "1280") { $this_port['adslAturCurrSnrMgn'] = "U"; }
rrdtool_update_ng($device, 'port-adsl', array(
'AtucCurrSnrMgn' => $this_port['adslAtucCurrSnrMgn'],
'AtucCurrAtn' => $this_port['adslAtucCurrAtn'],
'AtucCurrOutputPwr' => $this_port['adslAtucCurrOutputPwr'],
'AtucCurrAttainableR' => $this_port['adslAtucCurrAttainableR'],
'AtucChanCurrTxRate' => $this_port['adslAtucChanCurrTxRate'],
'AturCurrSnrMgn' => $this_port['adslAturCurrSnrMgn'],
'AturCurrAtn' => $this_port['adslAturCurrAtn'],
'AturCurrOutputPwr' => $this_port['adslAturCurrOutputPwr'],
'AturCurrAttainableR' => $this_port['adslAturCurrAttainableR'],
'AturChanCurrTxRate' => $this_port['adslAturChanCurrTxRate'],
'AtucPerfLofs' => $this_port['adslAtucPerfLofs'],
'AtucPerfLoss' => $this_port['adslAtucPerfLoss'],
'AtucPerfLprs' => $this_port['adslAtucPerfLprs'],
'AtucPerfESs' => $this_port['adslAtucPerfESs'],
'AtucPerfInits' => $this_port['adslAtucPerfInits'],
'AturPerfLofs' => $this_port['adslAturPerfLofs'],
'AturPerfLoss' => $this_port['adslAturPerfLoss'],
'AturPerfLprs' => $this_port['adslAturPerfLprs'],
'AturPerfESs' => $this_port['adslAturPerfESs'],
'AtucChanCorrectedBl' => $this_port['adslAtucChanCorrectedBl'],
'AtucChanUncorrectBl' => $this_port['adslAtucChanUncorrectBl'],
'AturChanCorrectedBl' => $this_port['adslAturChanCorrectedBl'],
'AturChanUncorrectBl' => $this_port['adslAturChanUncorrectBl'],
), get_port_rrdindex($port));
if ($GLOBALS['config']['statsd']['enable']) {
foreach ($adsl_oids as $oid) {
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'port'.'.'.$port['ifIndex'].'.'.$oid, $this_port[$oid]);
}
}
//echo("ADSL (".$this_port['adslLineCoding']."/".formatRates($this_port['adslAtucChanCurrTxRate'])."/".formatRates($this_port['adslAturChanCurrTxRate']).")");
}
// EOF

View File

@ -0,0 +1,15 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
include('atistackswitch9424-mib.inc.php');
// EOF

View File

@ -0,0 +1,70 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlans
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
$start = microtime(TRUE); // Module timing start
/*
AtiStackSwitch9424-MIB::atiStkSwVlanTaggedPortListModule1.10 = STRING:
AtiStackSwitch9424-MIB::atiStkSwVlanUntaggedPortListModule1.10 = STRING: 1-2,4
*/
echo("atiStkSwVlanTaggedPortListModule1 atiStkSwVlanUntaggedPortListModule1 ");
$entries = snmpwalk_cache_oid($device, 'atiStkSwVlanTaggedPortListModule1', [], $mib);
$entries = snmpwalk_cache_oid($device, 'atiStkSwVlanUntaggedPortListModule1', $entries, $mib);
print_debug_vars($entries);
$ports_vlans = [];
foreach ($entries as $vlan_num => $vlan)
{
foreach (list_to_range($vlan['atiStkSwVlanTaggedPortListModule1']) as $ifIndex)
{
$ports_vlans[$ifIndex]['tagged'][] = $vlan_num;
}
foreach (list_to_range($vlan['atiStkSwVlanUntaggedPortListModule1']) as $ifIndex)
{
$ports_vlans[$ifIndex]['untagged'][] = $vlan_num;
}
}
$vlan_rows = array();
foreach ($ports_vlans as $ifIndex => $vlan)
{
$trunk = '';
if (isset($vlan['tagged']))
{
$trunk = 'dot1Q';
}
foreach ($vlan['untagged'] as $vlan_num)
{
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
}
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
// EOF

View File

@ -0,0 +1,66 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*
* CISCO-LWAPP-AP-MIB
*
* Discovery SysObjectID has to start either with 1.3.6.1.4.1.14179. or 1.3.6.1.4.1.9. and SysDescription contains the string "Cisco Controller".
*
* Controller ciscoLwappAp 1.3.6.1.4.1.9.9.513
* Controller cLApEthernetIfEntry 1.3.6.1.4.1.9.9.513.1.2.2.1
*
* Thin AP ports Table 1.3.6.1.4.1.9.9.513.1.2.2 enterprises.cisco.ciscoMgmt.ciscoLwappApMIB.ciscoLwappApMIBObjects.ciscoLwappApIf.cLApEthernetIfTable.cLApEthernetIfEntry
* cLApSysMacAddress 1.3.6.1.4.1.9.9.513.1.1.1.1.1 This object represents the radio MAC address common to the dot11 interfaces of the AP and uniquely identifies an entry in this table.
* port_label_base cLApName + cLApEthernetIfName 1.3.6.1.4.1.9.9.513.1.1.1.1.5 This object represents the administrative name assigned to the AP by the user.
* port_label_num cLApEthernetIfSlotId 1.3.6.1.4.1.9.9.513.1.2.2.1.1 This object represents the slot ID of an Ethernet interface on an AP. The slot ID for a particular Ethernet interface as represented by this object ranges from 0 to cLApMaxNumberOfEthernetSlots - 1.
* cLApEthernetIfName 1.3.6.1.4.1.9.9.513.1.2.2.1.2 This object represents the name of the Ethernet interface. SnmpAdminString ( SIZE ( 0 .. 32))
* ifPhysAddress cLApEthernetIfMacAddress 1.3.6.1.4.1.9.9.513.1.2.2.1.3 This object represents MAC address of the Ethernet interface in the slot represented by cLApEthernetIfSlotId.
* ifAdminStatus cLApEthernetIfAdminStatus 1.3.6.1.4.1.9.9.513.1.2.2.1.4 This object represents the admin state of the physical Ethernet interface on the AP. INTEGER { up ( 1), down ( 2) }
* ifOperStatus cLApEthernetIfOperStatus 1.3.6.1.4.1.9.9.513.1.2.2.1.5 This object represents the operational state of the physical Ethernet interface on the AP. INTEGER { up ( 1), down ( 2) }
* ifInUcastPkts cLApEthernetIfRxUcastPkts 1.3.6.1.4.1.9.9.513.1.2.2.1.6 This object represents total number of unicast packets received on the interface. Counter32
* ifInNUcastPkts cLApEthernetIfRxNUcastPkts 1.3.6.1.4.1.9.9.513.1.2.2.1.7 This object represents total number of non-unicast or multicast packets received on the interface. Counter32
* ifOutUcastPkts cLApEthernetIfTxUcastPkts 1.3.6.1.4.1.9.9.513.1.2.2.1.8 This object represents total number of unicast packets transmitted on the interface. Counter32
* ifOutNUcastPkts cLApEthernetIfTxNUcastPkts 1.3.6.1.4.1.9.9.513.1.2.2.1.9 This object represents total number of non-unicast or multicast packets transmitted on the interface Counter32
* ifDuplex cLApEthernetIfDuplex 1.3.6.1.4.1.9.9.513.1.2.2.1.10 This object represents interface's duplex mode. INTEGER { unknown ( 1), halfduplex ( 2), fullduplex ( 3), auto ( 4) }
* ifSpeed cLApEthernetIfLinkSpeed 1.3.6.1.4.1.9.9.513.1.2.2.1.11 Speed of the interface in units of 1,000,000 bits per second. Gauge32
* ifType ?? cLApEthernetIfPOEPower 1.3.6.1.4.1.9.9.513.1.2.2.1.12 This object represents whether this interface supports Power Over Ethernet (POE) none - POE is not supported drawn - This interface supports POE, and power is being drawn notdrawn - POE power is not drawn INTEGER { none ( 1), drawn ( 2), notdrawn ( 3) }
* ifInOctets cLApEthernetIfRxTotalBytes 1.3.6.1.4.1.9.9.513.1.2.2.1.13 This object represents total number of bytes in the error-free packets received on the interface. Counter32
* ifOutOctets cLApEthernetIfTxTotalBytes 1.3.6.1.4.1.9.9.513.1.2.2.1.14 This object represents total number of bytes in the error-free packets transmitted on the interface. Counter32
* cLApEthernetIfInputCrc 1.3.6.1.4.1.9.9.513.1.2.2.1.15 This object represents total number of CRC error in packets received on the interface. Counter32
* cLApEthernetIfInputAborts 1.3.6.1.4.1.9.9.513.1.2.2.1.16 This object represents total number of packet aborted while receiving on the interface. Counter32
* ifInErrors cLApEthernetIfInputErrors 1.3.6.1.4.1.9.9.513.1.2.2.1.17 This object represents sum of all errors in the packets while receiving on the interface. Counter32
* cLApEthernetIfInputFrames 1.3.6.1.4.1.9.9.513.1.2.2.1.18 This object represents total number of packet received incorrectly having a CRC error and a noninteger number of octets on the interface. Counter32
* cLApEthernetIfInputOverrun 1.3.6.1.4.1.9.9.513.1.2.2.1.19 This object represents the number of times the receiver hardware was incapable of handing received data to a hardware buffer because the input rate exceeded the receiver's capability to handle the data. Counter32
* ifInDiscards cLApEthernetIfInputDrops 1.3.6.1.4.1.9.9.513.1.2.2.1.20 This object represents total number of packets dropped while receiving on the interface because the queue was full. Counter32
* cLApEthernetIfInputResource 1.3.6.1.4.1.9.9.513.1.2.2.1.21 This object represents total number of resource errors in packets received on the interface. Counter32
* cLApEthernetIfUnknownProtocol 1.3.6.1.4.1.9.9.513.1.2.2.1.22 This object represents total number of packet discarded on the interface due to unknown protocol.
* cLApEthernetIfRunts 1.3.6.1.4.1.9.9.513.1.2.2.1.23 This object represents number of packets that are discarded because they are smaller than the medium's minimum packet size. Counter32
* cLApEthernetIfGiants 1.3.6.1.4.1.9.9.513.1.2.2.1.24 This object represents number of packets that are discarded because they exceed the medium's maximum packet size. Counter32
* cLApEthernetIfThrottle 1.3.6.1.4.1.9.9.513.1.2.2.1.25 This object represents total number of times the interface advised a sending NIC that it was overwhelmed by packets being sent and to slow the pace of delivery. Counter32
* cLApEthernetIfResets 1.3.6.1.4.1.9.9.513.1.2.2.1.26 This object represents number of times that an interface has been completely reset. Counter32
* cLApEthernetIfOutputCollision 1.3.6.1.4.1.9.9.513.1.2.2.1.27 This object represents total number of packet retransmitted due to an Ethernet collision. Counter32
* cLApEthernetIfOutputNoBuffer 1.3.6.1.4.1.9.9.513.1.2.2.1.28 This object represents total number of packets discarded because there was no buffer space. Counter32
* cLApEthernetIfOutputResource 1.3.6.1.4.1.9.9.513.1.2.2.1.29 This object represents total number of resource errors in packets transmitted on the interface. Counter32
* cLApEthernetIfOutputUnderrun 1.3.6.1.4.1.9.9.513.1.2.2.1.30 This object represents the number of times the transmitter has been running faster than the router can handle. Counter32
* ifOutErrors cLApEthernetIfOutputErrors 1.3.6.1.4.1.9.9.513.1.2.2.1.31 This object represents sum of all errors that prevented the final transmission of packets out of the interface. Counter32
* ifOutDiscards cLApEthernetIfOutputTotalDrops 1.3.6.1.4.1.9.9.513.1.2.2.1.32 This object represents total number of packets dropped while transmitting from the interface because the queue was full. Counter32
* cLApEthernetIfCdpEnabled 1.3.6.1.4.1.9.9.513.1.2.2.1.33 This object indicates the status of Cisco Discovery Protocol(CDP) in this interface represented by cLApEthernetIfSlotId of the AP represented by cLApSysMacAddress. A value of 'true' indicates that CDP is enabled in this interface. A value of 'false' indicates that CDP is disabled in this interface.
*
*/
echo('CISCO-LWAPP-AP-MIB' . PHP_EOL);
//Thin AP Get Interfaces
print_cli_data("Collecting", "CISCO-LWAPP-AP-MIB Ports", 3);
// EOF

View File

@ -0,0 +1,49 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// CISCO-STACK-MIB
$port_stack = snmpwalk_cache_oid($device, "portIfIndex", array(), "CISCO-STACK-MIB");
if (!$GLOBALS['snmp_status']) { return; } // Break walk if not exist data from CISCO-STACK-MIB
$port_stack = snmpwalk_cache_oid($device, "portName", $port_stack, "CISCO-STACK-MIB");
$port_stack = snmpwalk_cache_oid($device, "portDuplex", $port_stack, "CISCO-STACK-MIB");
foreach($port_stack as $key => $data)
{
if (!isset($port_stats[$data['portIfIndex']])) { continue; } // Unknown ifIndex
if (empty($port_stats[$data['portIfIndex']]['ifAlias']))
{
$port_stats[$data['portIfIndex']]['ifAlias'] = $data['portName'];
}
if (empty($port_stats[$data['portIfIndex']]['ifDuplex']))
{
// Use same duplex values as in EtherLike-MIB::dot3StatsDuplexStatus
switch ($data['portDuplex'])
{
case 'half':
$port_stats[$data['portIfIndex']]['ifDuplex'] = 'halfDuplex';
break;
case 'full':
$port_stats[$data['portIfIndex']]['ifDuplex'] = 'fullDuplex';
break;
default:
$port_stats[$data['portIfIndex']]['ifDuplex'] = 'unknown';
}
}
}
unset($port_stack);
// EOF

View File

@ -0,0 +1,32 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Cisco TrustSec OIDs
// CISCO-TRUSTSEC-INTERFACE-MIB::ctsiIfControllerState.27 = INTEGER: open(6)
// Get TrustSec port status
$trustsec_statuses = snmpwalk_cache_oid($device, "ctsiIfControllerState", array(), "CISCO-TRUSTSEC-INTERFACE-MIB");
// print_r($trustsec_statuses);
foreach ($trustsec_statuses as $ts_index => $ts)
{
if ($ts['ctsiIfControllerState'] === 'open' && isset($port_stats[$ts_index]))
{
// set port at encrypted
$port_stats[$ts_index]['encrypted'] = '1';
}
}
unset($trustsec_statuses, $ts, $ts_index);
// EOF

View File

@ -0,0 +1,64 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/routed port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
return FALSE; // False for do not collect stats
}
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.1.8 = INTEGER: 8
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.200.8 = INTEGER: 11
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.201.8 = INTEGER: 13
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.202.8 = INTEGER: 14
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.210.8 = INTEGER: 16
//CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB::cviRoutedVlanIfIndex.222.8 = INTEGER: 24
$vlan_oids = snmpwalk_cache_oid($device, "cviRoutedVlanIfIndex", array(), "CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB"); // Routed ports only
if (snmp_status())
{
echo("cviRoutedVlanIfIndex ");
print_debug_vars($vlan_oids);
$vlan_rows = array();
foreach ($vlan_oids as $index => $entry)
{
list($vlan_num, $phyifIndex) = explode('.', $index);
$ifIndex = $entry['cviRoutedVlanIfIndex'];
$trunk = 'routed';
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex]) && !is_numeric($port_stats[$ifIndex]['ifVlan']))
{
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,78 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
return FALSE; // False for do not collect stats
}
//CISCO-VLAN-MEMBERSHIP-MIB::vmVlan.35 = INTEGER: 15
//CISCO-VLAN-MEMBERSHIP-MIB::vmVlan.37 = INTEGER: 15
//CISCO-VTP-MIB::vlanTrunkPortEncapsulationOperType.35 = INTEGER: notApplicable(6)
//CISCO-VTP-MIB::vlanTrunkPortEncapsulationOperType.36 = INTEGER: dot1Q(4)
//CISCO-VTP-MIB::vlanTrunkPortEncapsulationOperType.37 = INTEGER: notApplicable(6)
//CISCO-VTP-MIB::vlanTrunkPortNativeVlan.35 = INTEGER: 15
//CISCO-VTP-MIB::vlanTrunkPortNativeVlan.36 = INTEGER: 1
//CISCO-VTP-MIB::vlanTrunkPortNativeVlan.37 = INTEGER: 15
$vlan_oids = snmpwalk_cache_oid($device, "vmVlan", array(), "CISCO-VLAN-MEMBERSHIP-MIB"); // Non trunk ports only
if (snmp_status()) {
echo("vmVlan ");
$vlan_oids = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $vlan_oids, "CISCO-VTP-MIB");
$vlan_oids = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $vlan_oids, "CISCO-VTP-MIB"); // Trunk ports only
print_debug_vars($vlan_oids);
$vlan_rows = array();
foreach ($vlan_oids as $ifIndex => $entry)
{
$trunk = '';
if (isset($entry['vlanTrunkPortEncapsulationOperType']) && $entry['vlanTrunkPortEncapsulationOperType'] != "notApplicable")
{
$trunk = $entry['vlanTrunkPortEncapsulationOperType'];
if (isset($entry['vlanTrunkPortNativeVlan']))
{
$vlan_num = $entry['vlanTrunkPortNativeVlan'];
}
}
if (isset($entry['vmVlan']))
{
$vlan_num = $entry['vmVlan'];
}
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex]))
{
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,15 @@
<?php
/*
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
include __DIR__ . '/radlan-vlan-mib.inc.php';
// EOF

View File

@ -0,0 +1,61 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlans
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
/*
DCN-MIB::portMode.1 = INTEGER: access(1)
DCN-MIB::portMode.2 = INTEGER: trunk(2)
DCN-MIB::portMode.3 = INTEGER: access(1)
DCN-MIB::pvid.1 = INTEGER: 1
DCN-MIB::pvid.2 = INTEGER: 1
DCN-MIB::pvid.3 = INTEGER: 1
*/
echo("portMode pvid ");
$entries = snmpwalk_cache_oid($device, 'portMode', [], 'DCN-MIB');
$entries = snmpwalk_cache_oid($device, 'pvid', $entries, 'DCN-MIB');
print_debug_vars($entries);
$vlan_rows = array();
foreach ($entries as $ifIndex => $vlan)
{
$vlan_num = $vlan['pvid'];
$trunk = '';
if ($vlan['portMode'] == 'trunk')
{
$trunk = 'dot1Q';
}
elseif ($vlan['portMode'] == 'hybrid')
{
$trunk = 'hybrid';
}
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
// EOF

View File

@ -0,0 +1,77 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (!$has_ifEntry) { return FALSE; }
// Ports Duplex, Secure
echo("portOperDuplex ");
$entries = snmpwalk_cache_oid($device, 'portOperDuplex', [], 'Es2952-MIB');
if (!snmp_status()) { return; }
//$entries = snmpwalk_cache_oid($device, 'portSecurity', $entries, 'Es2952-MIB');
foreach ($entries as $ifIndex => $entry)
{
// Set ifDuplex
switch ($entry['portOperDuplex'])
{
case 'full':
$port_stats[$ifIndex]['ifDuplex'] = 'fullDuplex';
break;
case 'half':
$port_stats[$ifIndex]['ifDuplex'] = 'halfDuplex';
break;
default:
$port_stats[$ifIndex]['ifDuplex'] = 'unknown';
}
}
// Untagged/primary port vlans
$port_module = 'vlan';
if (!$ports_modules[$port_module])
{
// Module disabled
return;
}
/*
Es2952-MIB::portPvid.12 = INTEGER: 1
Es2952-MIB::portPvid.13 = INTEGER: 500
Es2952-MIB::isPortInTrunk.12 = INTEGER: false(2)
Es2952-MIB::isPortInTrunk.13 = INTEGER: false(2)
*/
echo("portPvid isPortInTrunk ");
$entries = snmpwalk_cache_oid($device, 'portPvid', [], 'Es2952-MIB');
$entries = snmpwalk_cache_oid($device, 'isPortInTrunk', $entries, 'Es2952-MIB');
print_debug_vars($ports_vlans_oids);
$vlan_rows = array();
foreach ($entries as $ifIndex => $vlan)
{
$vlan_num = $vlan['portPvid'];
$trunk = $vlan['isPortInTrunk'] == 'true' ? 'dot1Q' : '';
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
// EOF

View File

@ -0,0 +1,31 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// EtherLike-MIB stats
$port_module = 'etherlike';
// If etherlike extended error statistics are enabled, walk dot3StatsEntry else only dot3StatsDuplexStatus.
if ($ports_modules[$port_module]) {
echo("dot3Stats ");
$port_stats = snmpwalk_cache_oid($device, "dot3StatsEntry", $port_stats, "EtherLike-MIB");
$process_port_functions[$port_module] = snmp_status();
} elseif ($has_ifEntry) {
echo("dot3StatsDuplexStatus ");
$port_stats = snmpwalk_cache_oid($device, "dot3StatsDuplexStatus", $port_stats, "EtherLike-MIB");
$process_port_functions[$port_module] = snmp_status();
}
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifDuplex'; // this field used in main data fields
// EOF

View File

@ -0,0 +1,75 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// EtherLike-MIB functions
// Process in main ports loop
function process_port_etherlike(&$this_port, $device, $port) {
// Used to loop below for StatsD
$etherlike_oids = [
'dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames',
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
'dot3StatsSymbolErrors'
];
// Overwrite ifDuplex with dot3StatsDuplexStatus if it exists
if (isset($this_port['dot3StatsDuplexStatus'])) {
// echo("dot3Duplex, ");
// FIX for issue when device report incorrect type:
// EtherLike-MIB::dot3StatsDuplexStatus.1 = Wrong Type (should be INTEGER): Counter32: 2
switch ($this_port['dot3StatsDuplexStatus']) {
case '1':
$this_port['ifDuplex'] = 'unknown';
break;
case '2':
$this_port['ifDuplex'] = 'halfDuplex';
break;
case '3':
$this_port['ifDuplex'] = 'fullDuplex';
break;
default:
$this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus'];
}
}
if ($this_port['ifType'] === "ethernetCsmacd" && isset($this_port['dot3StatsIndex'])) {
// Check to make sure Port data is cached.
rrdtool_update_ng($device, 'port-dot3', [
'AlignmentErrors' => $this_port['dot3StatsAlignmentErrors'],
'FCSErrors' => $this_port['dot3StatsFCSErrors'],
'SingleCollisionFram' => $this_port['dot3StatsSingleCollisionFrames'],
'MultipleCollisionFr' => $this_port['dot3StatsMultipleCollisionFrames'],
'SQETestErrors' => $this_port['dot3StatsSQETestErrors'],
'DeferredTransmissio' => $this_port['dot3StatsDeferredTransmissions'],
'LateCollisions' => $this_port['dot3StatsLateCollisions'],
'ExcessiveCollisions' => $this_port['dot3StatsExcessiveCollisions'],
'InternalMacTransmit' => $this_port['dot3StatsInternalMacTransmitErrors'],
'CarrierSenseErrors' => $this_port['dot3StatsCarrierSenseErrors'],
'FrameTooLongs' => $this_port['dot3StatsFrameTooLongs'],
'InternalMacReceiveE' => $this_port['dot3StatsInternalMacReceiveErrors'],
'SymbolErrors' => $this_port['dot3StatsSymbolErrors'],
], get_port_rrdindex($port));
if ($GLOBALS['config']['statsd']['enable'] == TRUE) {
foreach ($etherlike_oids as $oid) {
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'port'.'.'.$this_port['ifIndex'].'.'.$oid, $this_port[$oid]);
}
}
}
}
// EOF

View File

@ -0,0 +1,93 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
//EXTREME-VLAN-MIB::extremeVlanIfVlanId.1000004 = INTEGER: 1
//EXTREME-VLAN-MIB::extremeVlanIfVlanId.1000005 = INTEGER: 4095
//EXTREME-VLAN-MIB::extremeVlanOpaqueUntaggedPorts.1000005.1 = Hex-STRING: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
//EXTREME-VLAN-MIB::extremeVlanOpaqueUntaggedPorts.1000008.1 = Hex-STRING: FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
//EXTREME-VLAN-MIB::extremeVlanOpaqueUntaggedPorts.1000008.2 = Hex-STRING: FF FF FF FF FF 18 00 00 00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
//EXTREME-VLAN-MIB::extremeVlanOpaqueUntaggedPorts.1000008.3 = Hex-STRING: FF FE 80 00 00 00 00 00 00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
// Base vlan IDs
$vlan_oids = snmpwalk_cache_oid($device, 'extremeVlanIfVlanId', array(), 'EXTREME-VLAN-MIB');
if (snmp_status())
{
echo("extremeVlanOpaqueUntaggedPorts ");
$ports_vlans_oids = snmpwalk_cache_twopart_oid($device, 'extremeVlanOpaqueUntaggedPorts', array(), 'EXTREME-VLAN-MIB', NULL, OBS_SNMP_ALL_MULTILINE | OBS_SNMP_HEX);
print_debug_vars($ports_vlans_oids);
$vlan_rows = array();
foreach ($ports_vlans_oids as $index => $tmp)
{
$vlan_num = $vlan_oids[$index]['extremeVlanIfVlanId'];
foreach ($tmp as $slot => $vlan)
{
$binary = hex2binmap($vlan['extremeVlanOpaqueUntaggedPorts']);
// Assign binary vlans map to ports
$length = strlen($binary);
for ($i = 0; $i < $length; $i++)
{
if ($binary[$i] && $i > 0)
{
$trunk = 'dot1Q'; // Hardcode all detected ports as trunk, since no way for detect it correctly
$port_map = $slot.':'.($i + 1);
//$ifIndex = dbFetchCell("SELECT `ifIndex` FROM `ports` WHERE `device_id` = ? AND (`ifDescr` LIKE ? OR `ifName` = ?) AND `deleted` = ? LIMIT 1", array($device['device_id'], '% '.$port_map, $port_map, 0));
foreach ($port_stats as $ifIndex => $entry)
{
if ($entry['ifName'] == $port_map || str_ends($entry['ifDescr'], ' '.$port_map))
{
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
break; // Stop ports loop
}
}
}
}
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,62 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// F5-BIGIP-SYSTEM-MIB
/*
$mib = 'F5-BIGIP-SYSTEM-MIB';
if (count($port_stats) && $has_ifXEntry === FALSE)
{
//$port_module = 'f5';
// Add F5 own table so we can get 64-bit values. They are checked later on.
//$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
$f5_stats = snmpwalk_cache_oid($device, 'sysIfxStat', array(), $mib);
$has_ifXEntry = $GLOBALS['snmp_status'] && isset($f5_stats[0]['sysIfxStatNumber']) && $f5_stats[0]['sysIfxStatNumber'] > 0; // Needed for additional check HC counters
if (OBS_DEBUG > 1 && count($f5_stats)) { print_vars($f5_stats); }
if ($has_ifXEntry)
{
$mib_config = &$config['mibs'][$mib]['ports']['oids']; // Attach MIB options/translations
// Convert F5 specific table to common port table
foreach ($port_stats as $ifIndex => $port)
{
if (isset($f5_stats[$port['ifDescr']]))
{
$f5_port = $f5_stats[$port['ifDescr']];
foreach ($mib_config as $oid => $entry)
{
$f5_oid = $entry['oid'];
if (isset($f5_port[$f5_oid]))
{
if (isset($entry['rewrite'][$f5_port[$f5_oid]]))
{
// Translate to standard IF-MIB values
$f5_port[$f5_oid] = $entry['rewrite'][$f5_port[$f5_oid]];
}
$port_stats[$ifIndex][$oid] = $f5_port[$f5_oid];
}
}
//$port_stats[$ifIndex] = array_merge($port_stats[$ifIndex], $f5_stats[$ifDescr]);
}
}
}
//$process_port_functions[$port_module] = $has_ifXEntry; // Additionally process port with function
// Clean
unset($f5_stats, $f5_port, $f5_oid, $flags, $ifIndex, $mib_config);
}
*/
// EOF

View File

@ -0,0 +1,42 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Get stack ports
$stackports = snmpwalk_cache_oid($device, 'agentInventoryStackPortTable', array(), 'FASTPATH-INVENTORY-MIB', mib_dirs(array('dell','broadcom')));
// [agentInventoryStackPortUnit] => 1
// [agentInventoryStackPortTag] => 0/17
// [agentInventoryStackPortConfiguredStackMode] => stack
// [agentInventoryStackPortRunningStackMode] => stack
// [agentInventoryStackPortLinkStatus] => up
// [agentInventoryStackPortLinkSpeed] => 10
// [agentInventoryStackPortDataRate] => 11
// [agentInventoryStackPortErrorRate] => 0
// [agentInventoryStackPortTotalErrors] => 94
//print_r($stackports);
foreach ($stackports as $index => $port)
{
if ($port['agentInventoryStackPortRunningStackMode'] !== "stack") { continue; }
$port_stats[$index]['ifName'] = 'Te'.$port['agentInventoryStackPortUnit'].'/'.$port['agentInventoryStackPortTag'];
$port_stats[$index]['ifDescr'] = 'Stack Port';
$port_stats[$index]['ifType'] = 'propVirtual';
$port_stats[$index]['ifSpeed'] = intval($port['agentInventoryStackPortLinkSpeed']) * 1000000000;
$port_stats[$index]['ifOperStatus'] = $port['agentInventoryStackPortLinkStatus'];
$port_stats[$index]['ifAdminStatus'] = 'up';
$port_stats[$index]['ifInErrors'] = $port['agentInventoryStackPortTotalErrors'];
}
unset($stackports, $port, $index);
// EOF

View File

@ -0,0 +1,95 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module])
{
// Module disabled
return FALSE; // False for do not collect stats
}
//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.39 = INTEGER: 92
//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.40 = INTEGER: 93
//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.46 = INTEGER: 99
//HUAWEI-L2IF-MIB::hwL2IfPVID.39 = INTEGER: 0
//HUAWEI-L2IF-MIB::hwL2IfPVID.40 = INTEGER: 1
//HUAWEI-L2IF-MIB::hwL2IfPVID.46 = INTEGER: 1
//HUAWEI-L2IF-MIB::hwL2IfActivePortType.39 = INTEGER: invalid(0)
//HUAWEI-L2IF-MIB::hwL2IfActivePortType.40 = INTEGER: trunk(1)
//HUAWEI-L2IF-MIB::hwL2IfActivePortType.46 = INTEGER: access(2)
// Base port ifIndex association
$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPortIfIndex', array(), 'HUAWEI-L2IF-MIB');
if (snmp_status())
{
echo("dot1qPortVlanTable ");
$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPVID', $vlan_oids, 'HUAWEI-L2IF-MIB');
//$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfActivePortType', $vlan_oids, 'HUAWEI-L2IF-MIB');
//if (!snmp_status())
//{
$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPortType', $vlan_oids, 'HUAWEI-L2IF-MIB');
//}
print_debug_vars($vlan_oids);
$vlan_rows = array();
foreach ($vlan_oids as $index => $entry)
{
$vlan_num = $entry['hwL2IfPVID'];
$ifIndex = $entry['hwL2IfPortIfIndex'];
//$port_type = (isset($entry['hwL2IfActivePortType'])) ? $entry['hwL2IfActivePortType'] : $entry['hwL2IfPortType'];
$port_type = $entry['hwL2IfPortType'];
switch ($port_type)
{
case 'trunk':
$trunk = 'dot1Q';
break;
case 'qinq':
$trunk = 'QinQ';
break;
case 'hybrid':
case 'fabric':
$trunk = $port_type;
break;
case 'invalid':
// Skip invalid Vlan 0
continue 2;
default:
$trunk = '';
}
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex]))
{
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,164 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
$vlan_rows = [];
// Base port ifIndex association
$dot1d_baseports = snmpwalk_cache_oid($device, 'dot1dBasePortIfIndex', [], 'BRIDGE-MIB');
$use_baseports = safe_count($dot1d_baseports) > 0;
$use_aruba = FALSE;
if (is_device_mib($device, 'ARUBAWIRED-PORTVLAN-MIB')) {
echo("arubaWiredPortVlanMemberMode ");
$ports_mode = snmpwalk_cache_oid($device, 'arubaWiredPortVlanMemberMode', [], 'ARUBAWIRED-PORTVLAN-MIB');
$use_aruba = safe_count($ports_mode) > 0;
}
// Faster (and easy) way for get untagged/primary vlans
$dot1q_ports = snmpwalk_cache_twopart_oid($device, 'ieee8021QBridgePvid', [], 'IEEE8021-Q-BRIDGE-MIB');
if (snmp_status() && $use_baseports) {
if (!$use_aruba) {
echo("ieee8021QBridgePortVlanTable ");
$dot1q_ports = snmpwalk_cache_twopart_oid($device, 'ieee8021QBridgePortAcceptableFrameTypes', $dot1q_ports, 'IEEE8021-Q-BRIDGE-MIB');
$dot1q_ports = snmpwalk_cache_twopart_oid($device, 'ieee8021QBridgePortIngressFiltering', $dot1q_ports, 'IEEE8021-Q-BRIDGE-MIB');
// Collect trunk port ids and vlans
//$trunk_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `ports_vlans` WHERE `device_id` = ?', [ $device['device_id'] ]);
$trunk_ports = [];
foreach (dbFetchRows('SELECT `port_id`, `vlan` FROM `ports_vlans` WHERE `device_id` = ?', [ $device['device_id'] ]) as $entry) {
$trunk_ports[$entry['port_id']][] = $entry['vlan'];
}
print_debug_vars($trunk_ports);
}
print_debug_vars($dot1q_ports);
foreach ($dot1q_ports as $domain_index => $vlans) {
foreach ($vlans as $index => $entry) {
$vlan_num = $entry['ieee8021QBridgePvid'];
$ifIndex = $dot1d_baseports[$index]['dot1dBasePortIfIndex'];
if ($use_aruba && isset($ports_mode[$ifIndex])) {
$trunk = $ports_mode[$ifIndex]['arubaWiredPortVlanMemberMode'] === 'trunk' ? 'dot1Q' : '';
} elseif (isset($entry['ieee8021QBridgePortAcceptableFrameTypes']) && $entry['ieee8021QBridgePortAcceptableFrameTypes'] === 'admitTagged') {
$trunk = 'dot1Q';
} elseif ((isset($entry['ieee8021QBridgePortIngressFiltering']) && $entry['ieee8021QBridgePortIngressFiltering'] === 'true')) {
// Additionally, check if port have trunk ports
$port = get_port_by_index_cache($device, $ifIndex);
print_debug("CHECK. ifIndex: $ifIndex, port_id: " . $port['port_id']);
if (isset($trunk_ports[$port['port_id']]) && (safe_count($trunk_ports[$port['port_id']]) > 1 || $trunk_ports[$port['port_id']][0] != $vlan_num)) {
$trunk = 'dot1Q';
} else {
$trunk = ''; // access
}
} else {
$trunk = ''; // access
}
$vlan_rows[] = [ $ifIndex, $vlan_num, $trunk ];
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex])) {
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
} else {
// Common ieee8021QBridgeVlanStaticUntaggedPorts
$oid_name = 'ieee8021QBridgeVlanStaticUntaggedPorts';
$dot1q_ports = snmpwalk_cache_twopart_oid($device, 'ieee8021QBridgeVlanStaticUntaggedPorts', $dot1q_ports, 'IEEE8021-Q-BRIDGE-MIB', NULL, OBS_SNMP_ALL_MULTILINE | OBS_SNMP_HEX);
// This is very slow (on some devices and with many ports), very hard to detect correct ports
echo("$oid_name ");
// Detect min ifIndex for vlan base ports
// Why, see here: http://jira.observium.org/browse/OBS-963
/*
if ($use_baseports)
{
$vlan_ifindex_min = $dot1d_baseports[key($dot1d_baseports)]['dot1dBasePortIfIndex']; // First element
foreach ($dot1d_baseports as $entry)
{
// But min ifIndex can be in any entry
$vlan_ifindex_min = min($vlan_ifindex_min, $entry['dot1dBasePortIfIndex']);
}
} else {
$vlan_ifindex_min = 0;
}
*/
foreach ($dot1q_ports as $domain_index => $vlans) {
foreach ($vlans as $index => $entry) {
$index_array = explode('.', $index);
$vlan_num = end($index_array); // need explode for dot1qVlanCurrentUntaggedPorts.0
// Convert hex to binary map
$binary = hex2binmap($entry[$oid_name]);
$trunk = ''; // unknown
// Assign binary vlans map to ports
$length = strlen($binary);
for ($i = 0; $i < $length; $i++) {
if ($binary[$i]) {
//$ifIndex = $i + $vlan_ifindex_min; // This is incorrect ifIndex association!
if ($use_baseports) {
$ifIndex = $dot1d_baseports[$i + 1]['dot1dBasePortIfIndex'];
} else {
$ifIndex = $i;
}
if ($use_aruba && isset($ports_mode[$ifIndex])) {
$trunk = $ports_mode[$ifIndex]['arubaWiredPortVlanMemberMode'] === 'trunk' ? 'dot1Q' : '';
}
$vlan_rows[] = [ $ifIndex, $vlan_num, $trunk ];
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex])) {
if (isset($port_stats[$ifIndex]['ifVlan'])) {
print_debug("WARNING. Oid dot1qVlanStaticUntaggedPorts pass incorrect vlan data.");
}
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
if (safe_count($vlan_rows)) {
// Disable poll by other MIBs (ie Q-BRIDGE-MIB)
$ports_modules[$port_module] = FALSE;
}
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,35 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
function process_port_ipifstats(&$this_port, $device)
{
if (isset($this_port['ipIfStats']))
{ // Check to make sure Port data is cached.
foreach ($this_port['ipIfStats'] AS $af => $af_stats)
{
if ($af == "ipv6") // Only store IPv6 stuff for now.
{
rrdtool_update_ng($device, 'port-af-octets', array(
'InOctets' => $af_stats['ipIfStatsHCInOctets'],
'OutOctets' => $af_stats['ipIfStatsHCOutOctets'],
), array('index' => get_port_rrdindex($this_port), 'af' => $af));
// FIXME - come up with a real way to signal this stuff.
set_entity_attrib('port', $this_port['port_id'], 'ipv6-octets', 1);
}
}
}
}

View File

@ -0,0 +1,114 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
/*
* Low-capacity
IP-MIB::ipIfStatsInReceives.ipv6.49 = Counter32: 2714776
IP-MIB::ipIfStatsInOctets.ipv6.49 = Counter32: 215781800
IP-MIB::ipIfStatsInForwDatagrams.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInDelivers.ipv6.49 = Counter32: 2716785
IP-MIB::ipIfStatsOutRequests.ipv6.49 = Counter32: 92891507
IP-MIB::ipIfStatsOutForwDatagrams.ipv6.49 = Counter32: 48740534
IP-MIB::ipIfStatsOutOctets.ipv6.49 = Counter32: 1301522241
IP-MIB::ipIfStatsInMcastPkts.ipv6.49 = Counter32: 545375
IP-MIB::ipIfStatsInMcastOctets.ipv6.49 = Counter32: 56715392
IP-MIB::ipIfStatsOutMcastPkts.ipv6.49 = Counter32: 10887710
IP-MIB::ipIfStatsOutMcastOctets.ipv6.49 = Counter32: 843158624
IP-MIB::ipIfStatsInBcastPkts.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsOutBcastPkts.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsOutTransmits.ipv6.49 = Counter32: 92911664
* High-capacity
IP-MIB::ipIfStatsHCInOctets.ipv6.49 = Counter64: 215781800
IP-MIB::ipIfStatsHCOutOctets.ipv6.49 = Counter64: 18481391425
IP-MIB::ipIfStatsHCInMcastPkts.ipv6.49 = Counter64: 545375
IP-MIB::ipIfStatsHCInMcastOctets.ipv6.49 = Counter64: 56715392
IP-MIB::ipIfStatsHCOutMcastPkts.ipv6.49 = Counter64: 10887710
IP-MIB::ipIfStatsHCOutMcastOctets.ipv6.49 = Counter64: 843158624
IP-MIB::ipIfStatsHCInBcastPkts.ipv6.49 = Counter64: 0
IP-MIB::ipIfStatsHCOutBcastPkts.ipv6.49 = Counter64: 0
IP-MIB::ipIfStatsHCInReceives.ipv6.49 = Counter64: 2714776
IP-MIB::ipIfStatsHCInForwDatagrams.ipv6.49 = Counter64: 0
IP-MIB::ipIfStatsHCInDelivers.ipv6.49 = Counter64: 2716785
IP-MIB::ipIfStatsHCOutRequests.ipv6.49 = Counter64: 92891507
IP-MIB::ipIfStatsHCOutForwDatagrams.ipv6.49 = Counter64: 48740534
IP-MIB::ipIfStatsHCOutTransmits.ipv6.49 = Counter64: 92911664
IP-MIB::ipIfStatsDiscontinuityTime.ipv6.49 = Timeticks: (0) 0:00:00.00
* Low-capacity ONLY
IP-MIB::ipIfStatsInHdrErrors.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInNoRoutes.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInAddrErrors.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInUnknownProtos.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInTruncatedPkts.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsReasmReqds.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsReasmOKs.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsReasmFails.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsInDiscards.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsOutDiscards.ipv6.49 = Counter32: 21576
IP-MIB::ipIfStatsOutFragReqds.ipv6.49 = Counter32: 20062
IP-MIB::ipIfStatsOutFragOKs.ipv6.49 = Counter32: 20062
IP-MIB::ipIfStatsOutFragFails.ipv6.49 = Counter32: 0
IP-MIB::ipIfStatsOutFragCreates.ipv6.49 = Counter32: 40124
*/
// IP-MIB ipIfStats
$port_module = 'ipifstats';
if ($ports_modules[$port_module])
{
echo("IP-MIB ipIfStats ");
$oids = array('ipIfStatsHCInOctets', 'ipIfStatsHCOutOctets'); // Bits
if(FALSE) { $oids = array_merge($oids, array('ipIfStatsHCOutTransmits', 'ipIfStatsHCInReceives')); } // Pkts
if(FALSE) { $oids = array_merge($oids, array('ipIfStatsHCInMcastPkts', 'ipIfStatsHCInMcastOctets', 'ipIfStatsHCOutMcastPkts', 'ipIfStatsHCOutMcastOctets', 'ipIfStatsHCInBcastPkts',
'ipIfStatsHCOutBcastPkts', 'ipIfStatsHCInForwDatagrams', 'ipIfStatsHCInDelivers', 'ipIfStatsHCOutRequests',
'ipIfStatsHCOutForwDatagrams' )); } // Stats
$ipIfStats = array();
foreach($oids as $oid)
{
$ipIfStats = snmpwalk_cache_twopart_oid($device, $oid, $ipIfStats, "IP-MIB", NULL, OBS_SNMP_ALL_TABLE);
if ($oid == 'ipIfStatsHCInOctets' && !snmp_status())
{
break;
}
}
foreach ($ipIfStats as $af => $af_ports)
{
foreach($af_ports as $af_port_id => $af_port)
{
$port_stats[$af_port_id]['ipIfStats'][$af] = $af_port;
}
}
//print_r($port_stats);
$process_port_functions[$port_module] = snmp_status();
}

View File

@ -0,0 +1,234 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// Derp devices....... exist ifXEntry (without ifEntry)
if (!$has_ifEntry && $has_ifXEntry) {
// Ethernet ports:
// IPE-SYSTEM-MIB::ipeCfgPortEtherEnable.31 = INTEGER: enabled(1)
// IPE-SYSTEM-MIB::ipeCfgPortEtherAutoNeg.31 = INTEGER: enabled(1)
// IPE-SYSTEM-MIB::ipeCfgPortEtherSpecialFilter.31 = INTEGER: false(2)
// IPE-SYSTEM-MIB::ipeCfgPortEtherLldpMode.31 = INTEGER: standardMode(1)
// IPE-SYSTEM-MIB::ipeCfgPortEtherEntry.7.31 = INTEGER: 1
// IPE-SYSTEM-MIB::ipeStsPortEtherLinkUp.31 = INTEGER: 1
// IPE-SYSTEM-MIB::ipeStsPortEtherSpeed.31 = INTEGER: 100
// IPE-SYSTEM-MIB::ipeStsPortEtherDuplex.31 = INTEGER: 2
// IPE-SYSTEM-MIB::ipeStsPortEtherFlowControl.31 = INTEGER: 0
// IPE-COMMON-MIB::invMacAddress.31 = STRING: 74:3a:65:5d:b6:c0
// ODU ports:
// IPE-COMMON-MIB::lof.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::frameID.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::highBERAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::lowBERAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::earlyWarningAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::modAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::ifCableShortAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::atpcPowerMode.16842752 = INTEGER: active(2)
// IPE-COMMON-MIB::inPhaseStatus.16842752 = INTEGER: outphase(2)
// IPE-COMMON-MIB::amrRangeMismatch.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::txModulation.16842752 = INTEGER: qpsk(1)
// IPE-COMMON-MIB::rxModulation.16842752 = INTEGER: qpsk(1)
// IPE-COMMON-MIB::l2SyncLossAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::rdiAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::uaeAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::unlocked.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::tempAlarm.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::tdmRangeMismatch.16842752 = INTEGER: cleared(1)
// IPE-COMMON-MIB::modemPsOff.16842752 = INTEGER: on(2)
// SFP ports
// IPE-COMMON-MIB::asETHPortInterfaceType.142802944 = INTEGER: invalid(0)
// IPE-COMMON-MIB::asETHPortSpeedDuplex.142802944 = INTEGER: invalid(0)
// IPE-COMMON-MIB::asETHPortFlowControl.142802944 = INTEGER: disable(1)
// IPE-COMMON-MIB::asETHPortMDIMDIX.142802944 = INTEGER: invalid(0)
// IPE-COMMON-MIB::asETHPortLinkStatus.142802944 = INTEGER: cleared(1)
// IPE-COMMON-MIB::asETHPortAdminStatus.142802944 = INTEGER: normal(1)
// IPE-COMMON-MIB::asETHPortSFPEquip.142802944 = INTEGER: cleared(1)
// IPE-COMMON-MIB::asETHPortSFPLos.142802944 = INTEGER: cleared(1)
// IPE-COMMON-MIB::asETHPortSFPTxError.142802944 = INTEGER: cleared(1)
// IPE-COMMON-MIB::asETHPortSFPTypeMismatch.142802944 = INTEGER: cleared(1)
// IPE-COMMON-MIB::asETHPortOperStatus.142802944 = INTEGER: linkDown(1)
// IPE-COMMON-MIB::asETHPortLlfOamReceived.142802944 = INTEGER: normal(1)
$entries = [];
$entries = snmpwalk_cache_oid($device, 'ipeCfgPortEtherEnable', $entries, 'IPE-SYSTEM-MIB');
$entries = snmpwalk_cache_oid($device, 'ipeCfgPortModemEnable', $entries, 'IPE-SYSTEM-MIB');
$entries = snmpwalk_cache_oid($device, 'ipeStsPortEtherLinkUp', $entries, 'IPE-SYSTEM-MIB');
$entries = snmpwalk_cache_oid($device, 'ipeStsPortEtherDuplex', $entries, 'IPE-SYSTEM-MIB');
$entries = snmpwalk_cache_oid($device, 'invMacAddress', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'atpcPowerMode', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'modemPsOff', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'asETHPortInterfaceType', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'asETHPortSpeedDuplex', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'asETHPortAdminStatus', $entries, 'IPE-COMMON-MIB');
$entries = snmpwalk_cache_oid($device, 'asETHPortOperStatus', $entries, 'IPE-COMMON-MIB');
print_debug_vars($entries);
foreach ($port_stats as $ifIndex => $port)
{
$entry = isset($entries[$ifIndex]) ? $entries[$ifIndex] : [];
// ifType
if (isset($entry['ipeStsPortEtherLinkUp'], $entry['invMacAddress']) ||
str_starts($port['ifName'], [ 'eth', 'bcm' ])) {
$port_stats[$ifIndex]['ifType'] = 'ethernetCsmacd';
} elseif (isset($entry['asETHPortInterfaceType'])) {
switch ($entry['ipeStsPortEtherDuplex']) {
case 'fiber':
$port_stats[$ifIndex]['ifType'] = 'opticalChannel'; // ??
break;
case 'copper':
$port_stats[$ifIndex]['ifType'] = 'ethernetCsmacd';
break;
default:
$port_stats[$ifIndex]['ifType'] = 'other';
}
} elseif (str_starts($port['ifName'], 'lo')) {
$port_stats[$ifIndex]['ifType'] = 'softwareLoopback';
} elseif (isset($entry['atpcPowerMode'])) {
$port_stats[$ifIndex]['ifType'] = 'otnOdu'; // ??
} elseif (!str_starts($port['ifName'], 'lldp')) {
$port_stats[$ifIndex]['ifType'] = 'other';
} else {
// ignore all other
continue;
}
// ifAdminStatus
if (isset($entry['ipeCfgPortEtherEnable'])) {
switch ($entry['ipeCfgPortEtherEnable']) {
case 'enabled':
case '1':
$port_stats[$ifIndex]['ifAdminStatus'] = 'up';
break;
case 'disabled':
case '2':
$port_stats[$ifIndex]['ifAdminStatus'] = 'down';
break;
default:
$port_stats[$ifIndex]['ifAdminStatus'] = 'testing';
}
} elseif (isset($entry['asETHPortAdminStatus'])) {
switch ($entry['asETHPortAdminStatus']) {
case 'normal':
case 'oamSend':
$port_stats[$ifIndex]['ifAdminStatus'] = 'up';
break;
case 'force':
$port_stats[$ifIndex]['ifAdminStatus'] = 'down'; // ??
break;
default:
$port_stats[$ifIndex]['ifAdminStatus'] = 'testing';
}
} elseif (isset($entry['ipeCfgPortModemEnable'])) {
$port_stats[$ifIndex]['ifAdminStatus'] = $entry['ipeCfgPortModemEnable'] === 'enabled' ? 'up' : 'down';
} elseif (str_starts($port['ifName'], 'lo')) {
$port_stats[$ifIndex]['ifAdminStatus'] = 'up';
} elseif (isset($entry['modemPsOff'])) {
$port_stats[$ifIndex]['ifAdminStatus'] = $entry['modemPsOff'] === 'on' ? 'up' : 'down';
} else {
// Force up
$port_stats[$ifIndex]['ifAdminStatus'] = 'up';
}
// ifOperStatus
if (isset($entry['ipeStsPortEtherLinkUp'])) {
switch ($entry['ipeStsPortEtherLinkUp']) {
case '1':
$port_stats[$ifIndex]['ifOperStatus'] = 'up';
break;
case '2':
$port_stats[$ifIndex]['ifOperStatus'] = 'down';
break;
default:
$port_stats[$ifIndex]['ifOperStatus'] = 'unknown';
}
} elseif (isset($entry['asETHPortOperStatus'])) {
switch ($entry['asETHPortOperStatus']) {
case 'linkDown':
case '1':
$port_stats[$ifIndex]['ifOperStatus'] = 'down';
break;
case 'linkUp':
case '2':
$port_stats[$ifIndex]['ifOperStatus'] = 'up';
break;
default:
$port_stats[$ifIndex]['ifOperStatus'] = 'unknown';
}
} elseif (isset($entry['ipeCfgPortModemEnable'])) {
$port_stats[$ifIndex]['ifOperStatus'] = $entry['ipeCfgPortModemEnable'] === 'enabled' ? 'up' : 'down';
} elseif (str_starts($port['ifName'], 'lo')) {
$port_stats[$ifIndex]['ifOperStatus'] = 'up';
} elseif (isset($entry['atpcPowerMode'])) {
$port_stats[$ifIndex]['ifOperStatus'] = $entry['atpcPowerMode'] === 'active' ? 'up' : 'down';
} else {
// Force unknown
$port_stats[$ifIndex]['ifOperStatus'] = 'unknown';
}
// ifDuplex
if (isset($entry['ipeStsPortEtherDuplex'])) {
switch ($entry['ipeStsPortEtherDuplex']) {
case '1':
$port_stats[$ifIndex]['ifDuplex'] = 'halfDuplex';
break;
case '2':
$port_stats[$ifIndex]['ifDuplex'] = 'fullDuplex';
break;
default:
$port_stats[$ifIndex]['ifDuplex'] = 'unknown';
}
} elseif (isset($entry['asETHPortSpeedDuplex'])) {
switch ($entry['asETHPortSpeedDuplex']) {
case 's10M-HALF':
case 's100M-HALF':
$port_stats[$ifIndex]['ifDuplex'] = 'halfDuplex';
break;
case 's10M-FULL':
case 's100M-FULL':
case 's1000M-FULL':
$port_stats[$ifIndex]['ifDuplex'] = 'fullDuplex';
break;
default:
$port_stats[$ifIndex]['ifDuplex'] = 'unknown';
}
}
// ifPhysAddress
if (isset($entry['invMacAddress'])) {
$port_stats[$ifIndex]['ifPhysAddress'] = $entry['invMacAddress'];
}
}
}
// EOF

View File

@ -0,0 +1,72 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// JUNIPER-COS-MIB Queue Stats
$port_module = 'jnx_cos_qstat';
if ($ports_modules[$port_module] && $port_stats_count)
{
echo("JUNIPER-COS-MIB Queue Stats ");
$qstat_oids = array('jnxCosQstatQedPkts', 'jnxCosQstatQedBytes', 'jnxCosQstatTxedPkts', 'jnxCosQstatTxedBytes', 'jnxCosQstatTailDropPkts', 'jnxCosQstatTotalRedDropPkts', 'jnxCosQstatTotalRedDropBytes');
$q_names = snmpwalk_cache_oid($device, 'jnxCosFcIdToFcName', array(), "JUNIPER-COS-MIB");
$q_numbers = snmpwalk_cache_oid($device, 'jnxCosFcQueueNr', array(), "JUNIPER-COS-MIB");
//$qstats = snmpwalk_cache_oid($device, array_shift($qstat_oids), array(), "JUNIPER-COS-MIB");
$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
if ($GLOBALS['snmp_status'])
{
$q_names = snmpwalk_cache_oid($device, 'jnxCosFcFabricPriority', $q_names, "JUNIPER-COS-MIB");
$queues = array();
foreach($q_names AS $index => $data)
{
$queues[$index]['queue'] = $q_numbers[$data['jnxCosFcIdToFcName']]['jnxCosFcQueueNr'];
if(isset($data['jnxCosFcIdToFcName'])) { $queues[$index]['name'] = $data['jnxCosFcIdToFcName']; }
if(isset($data['jnxCosFcFabricPriority'])) { $queues[$index]['prio'] = $data['jnxCosFcFabricPriority']; }
}
set_entity_attrib('device', $device['device_id'], 'jnx_cos_queues', json_encode($queues));
foreach ($qstat_oids as $oid)
{
$qstats = snmpwalk_cache_oid($device, $oid, $qstats, "JUNIPER-COS-MIB");
}
foreach($qstats as $qstat_index => $qstat)
{
list($qstat_ifindex, $qstat_queue) = explode('.', $qstat_index);
$port_stats[$qstat_ifindex]['jnx_cos_qstat'][$qstat_queue] = $qstat;
}
unset($qstats);
unset($queues);
}
//print_vars($port_stats);
}
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifDuplex'; // this field used in main data fields
// EOF

View File

@ -0,0 +1,112 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// JUNIPER-COS-MIB functions
// Per-port COS Queue Statistics
/*
JUNIPER-COS-MIB::jnxCosQstatQedPkts[526][0] = Counter64: 17940450
JUNIPER-COS-MIB::jnxCosQstatQedPktRate[526][0] = Counter64: 2
JUNIPER-COS-MIB::jnxCosQstatQedBytes[526][0] = Counter64: 2960949944
JUNIPER-COS-MIB::jnxCosQstatQedByteRate[526][0] = Counter64: 192
JUNIPER-COS-MIB::jnxCosQstatTxedPkts[526][0] = Counter64: 17940458
JUNIPER-COS-MIB::jnxCosQstatTxedPktRate[526][0] = Counter64: 2
JUNIPER-COS-MIB::jnxCosQstatTxedBytes[526][0] = Counter64: 2960950728
JUNIPER-COS-MIB::jnxCosQstatTxedByteRate[526][0] = Counter64: 800
JUNIPER-COS-MIB::jnxCosQstatTailDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatTailDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatTotalRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatTotalRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpNonTcpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpNonTcpRDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpTcpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpTcpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpNonTcpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpNonTcpRDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpTcpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpTcpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatTotalRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatTotalRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpNonTcpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpNonTcpRDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpTcpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpTcpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpNonTcpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpNonTcpRDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpTcpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpTcpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMLpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMLpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMHpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMHpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpRedDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpRedDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatLpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMLpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMLpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMHpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatMHpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpRedDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatHpRedDropByteRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatRateLimitDropPkts[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatRateLimitDropPktRate[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatRateLimitDropBytes[526][0] = Counter64: 0
JUNIPER-COS-MIB::jnxCosQstatRateLimitDropByteRate[526][0] = Counter64: 0
*/
function process_port_jnx_cos_qstat(&$this_port, $device, $port)
{
if(isset($this_port['jnx_cos_qstat']) && count($this_port['jnx_cos_qstat']))
{
$queues = array();
foreach($this_port['jnx_cos_qstat'] as $q_index => $q_stats)
{
rrdtool_update_ng($device, 'port-jnx_cos_qstat', array(
'QedPkts' => $q_stats['jnxCosQstatQedPkts'],
'QedBytes' => $q_stats['jnxCosQstatQedBytes'],
'TxedPkts' => $q_stats['jnxCosQstatTxedPkts'],
'TxedBytes' => $q_stats['jnxCosQstatTxedBytes'],
'TailDropPkts' => $q_stats['jnxCosQstatTailDropPkts'],
'TotalRedDropPkts' => $q_stats['jnxCosQstatTotalRedDropPkts'],
'TotalRedDropBytes' => $q_stats['jnxCosQstatTotalRedDropBytes'],
), get_port_rrdindex($port).'-'.$q_index);
$queues[] = $q_index;
/*
if ($GLOBALS['config']['statsd']['enable'])
{
foreach ($adsl_oids as $oid)
{
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'port'.'.'.$port['ifIndex'].'.'.$oid, $this_port[$oid]);
}
} */
}
set_entity_attrib('port', $port['port_id'], 'jnx_cos_queues', json_encode($queues));
}
// FIXME -- remove attrib if it doesn't exist.
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
/*
JUNIPER-IPv6-MIB::jnxIpv6IfInOctets.509 = Counter64: 277025128777865
JUNIPER-IPv6-MIB::jnxIpv6IfOutOctets.509 = Counter64: 46668220396161
*/
// JUNIPER-IPv6-MIB
$port_module = 'jnxIpv6IfStats';
if ($ports_modules[$port_module] || TRUE)
{
echo("JUNIPER-IPv6-MIB jnxIpv6IfStats ");
$port_stats = snmpwalk_cache_oid($device, 'jnxIpv6IfStatsTable', $port_stats, "JUNIPER-IPv6-MIB", NULL, OBS_SNMP_ALL_TABLE);
$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
function process_port_jnxIpv6IfStats(&$this_port, $device, $port)
{
if (isset($this_port['jnxIpv6IfInOctets']) && isset($this_port['jnxIpv6IfOutOctets'])
&& ($this_port['jnxIpv6IfInOctets'] != 0 || $this_port['jnxIpv6IfOutOctets'] != 0))
{ // Only run if both stats exist and are non-zero (don't spam on ports/devices with no v6)
rrdtool_update_ng($device, 'port-af-octets', array(
'InOctets' => $this_port['jnxIpv6IfInOctets'],
'OutOctets' => $this_port['jnxIpv6IfOutOctets'],
), array('index' => get_port_rrdindex($port), 'af' => 'ipv6'));
// FIXME - come up with a real way to signal this stuff.
set_entity_attrib('port', $this_port['port_id'], 'ipv6-octets', 1);
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
if (!$port_stats_count) { return; }
echo("JUNIPER-VIRTUALCHASSIS-MIB ");
$jnxVirtualChassisMember = snmp_cache_table($device, 'jnxVirtualChassisMemberRole', [], 'JUNIPER-VIRTUALCHASSIS-MIB');
if (!snmp_status() ||
(count($jnxVirtualChassisMember) === 1 && $jnxVirtualChassisMember[0]['jnxVirtualChassisMemberRole'] === 'master')) // Skip only master
{
return;
}
$jnxVirtualChassisMember = snmpwalk_cache_oid($device, 'jnxVirtualChassisMemberMacAddBase', $jnxVirtualChassisMember, 'JUNIPER-VIRTUALCHASSIS-MIB');
print_debug_vars($jnxVirtualChassisMember);
$jnx_oids = [
'jnxVirtualChassisPortAdminStatus', 'jnxVirtualChassisPortOperStatus',
'jnxVirtualChassisPortInOctets', 'jnxVirtualChassisPortOutOctets',
'jnxVirtualChassisPortInPkts', 'jnxVirtualChassisPortOutPkts',
'jnxVirtualChassisPortInMcasts', 'jnxVirtualChassisPortOutMcasts',
// ifErrors
'jnxVirtualChassisPortCarrierTrans', 'jnxVirtualChassisPortInCRCAlignErrors',
'jnxVirtualChassisPortUndersizePkts', 'jnxVirtualChassisPortCollisions',
];
foreach ($jnxVirtualChassisMember as $member => $chassis)
{
if ($chassis['jnxVirtualChassisMemberRole'] === 'master')
{
// Skip master chassis (which already polled by IF-MIB)
print_debug("Skip JUNIPER-VIRTUALCHASSIS-MIB::jnxVirtualChassisPortTable for master");
continue;
}
$jnxVirtualChassisPort = [];
foreach ($jnx_oids as $oid)
{
$jnxVirtualChassisPort = snmpwalk_cache_twopart_oid($device, $oid . '.' . $member, $jnxVirtualChassisPort, 'JUNIPER-VIRTUALCHASSIS-MIB', NULL, OBS_SNMP_ALL_MULTILINE);
}
print_debug_vars($jnxVirtualChassisPort[$member]);
foreach ($jnxVirtualChassisPort[$member] as $jnxVirtualChassisPortName => $port)
{
$ifDescr = $jnxVirtualChassisPortName . ":vc$member";
// Generate numeric ifIndex based on port name
$ifIndex = string_to_id($ifDescr);
// Append member options
$port = array_merge($port, $chassis);
$port_stats[$ifIndex]['ifDescr'] = $ifDescr;
$port_stats[$ifIndex]['ifName'] = $ifDescr;
$port_stats[$ifIndex]['ifAdminStatus'] = $port['jnxVirtualChassisPortAdminStatus'];
$port_stats[$ifIndex]['ifOperStatus'] = $port['jnxVirtualChassisPortOperStatus'];
$port_stats[$ifIndex]['ifPhysAddress'] = $port['jnxVirtualChassisMemberMacAddBase'];
$port_stats[$ifIndex]['ifType'] = str_contains($ifDescr, '.') ? 'propVirtual' : 'other';
// Stats
$port_stats[$ifIndex]['ifHCInOctets'] = $port['jnxVirtualChassisPortInOctets'];
$port_stats[$ifIndex]['ifHCOutOctets'] = $port['jnxVirtualChassisPortOutOctets'];
$port_stats[$ifIndex]['ifHCInUcastPkts'] = $port['jnxVirtualChassisPortInPkts'];
$port_stats[$ifIndex]['ifHCOutUcastPkts'] = $port['jnxVirtualChassisPortOutPkts'];
$port_stats[$ifIndex]['ifHCInMulticastPkts'] = $port['jnxVirtualChassisPortInMcasts'];
$port_stats[$ifIndex]['ifHCOutMulticastPkts'] = $port['jnxVirtualChassisPortOutMcasts'];
/// FIXME. I not sure about error Oids
$port_stats[$ifIndex]['ifInErrors'] = $port['jnxVirtualChassisPortInCRCAlignErrors'];
$port_stats[$ifIndex]['ifInErrors'] = int_add($port_stats[$ifIndex]['ifInErrors'], $port['jnxVirtualChassisPortUndersizePkts']);
$port_stats[$ifIndex]['ifInErrors'] = int_add($port_stats[$ifIndex]['ifInErrors'], $port['jnxVirtualChassisPortCollisions']);
$port_stats[$ifIndex]['ifOutErrors'] = $port['jnxVirtualChassisPortCarrierTrans'];
}
}
// EOF

View File

@ -0,0 +1,47 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$port_module = 'etherlike';
// If etherlike extended error statistics are enabled, walk mtxrInterfaceStatsEntry.
if ($ports_modules[$port_module]) {
echo("mtxrInterfaceStats ");
$mikrotik_stats_oids = [
'dot3StatsAlignmentErrors' => 'mtxrInterfaceStatsRxAlignError',
'dot3StatsFCSErrors' => 'mtxrInterfaceStatsRxFCSError',
'dot3StatsSingleCollisionFrames' => 'mtxrInterfaceStatsTxSingleCollision',
'dot3StatsMultipleCollisionFrames' => 'mtxrInterfaceStatsTxMultipleCollision',
//'dot3StatsSQETestErrors',
'dot3StatsDeferredTransmissions' => 'mtxrInterfaceStatsTxDeferred',
'dot3StatsLateCollisions' => 'mtxrInterfaceStatsTxLateCollision',
'dot3StatsExcessiveCollisions' => 'mtxrInterfaceStatsTxExcessiveCollision',
//'dot3StatsInternalMacTransmitErrors',
'dot3StatsCarrierSenseErrors' => 'mtxrInterfaceStatsRxCarrierError',
'dot3StatsFrameTooLongs' => 'mtxrInterfaceStatsRxTooLong',
//'dot3StatsInternalMacReceiveErrors',
//'dot3StatsSymbolErrors'
];
//$port_stats = snmpwalk_cache_oid($device, "mtxrInterfaceStatsEntry", $port_stats, "MIKROTIK-MIB");
foreach ($mikrotik_stats_oids as $oid) {
$port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "MIKROTIK-MIB");
if ($oid === 'dot3StatsAlignmentErrors') {
// First Oid
if (!snmp_status()) {
break;
}
$process_port_functions['mikrotik'] = TRUE;
}
}
}
// EOF

View File

@ -0,0 +1,68 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Process in main ports loop
function process_port_mikrotik(&$this_port, $device, $port) {
// Used to loop below for StatsD
$etherlike_oids = [
'dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames',
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
'dot3StatsSymbolErrors'
];
$mikrotik_stats_oids = [
'dot3StatsAlignmentErrors' => 'mtxrInterfaceStatsRxAlignError',
'dot3StatsFCSErrors' => 'mtxrInterfaceStatsRxFCSError',
'dot3StatsSingleCollisionFrames' => 'mtxrInterfaceStatsTxSingleCollision',
'dot3StatsMultipleCollisionFrames' => 'mtxrInterfaceStatsTxMultipleCollision',
//'dot3StatsSQETestErrors',
'dot3StatsDeferredTransmissions' => 'mtxrInterfaceStatsTxDeferred',
'dot3StatsLateCollisions' => 'mtxrInterfaceStatsTxLateCollision',
'dot3StatsExcessiveCollisions' => 'mtxrInterfaceStatsTxExcessiveCollision',
//'dot3StatsInternalMacTransmitErrors',
'dot3StatsCarrierSenseErrors' => 'mtxrInterfaceStatsRxCarrierError',
'dot3StatsFrameTooLongs' => 'mtxrInterfaceStatsRxTooLong',
//'dot3StatsInternalMacReceiveErrors',
//'dot3StatsSymbolErrors'
];
if ($this_port['ifType'] === "ethernetCsmacd" && isset($this_port['mtxrInterfaceStatsRxAlignError'])) {
// Check to make sure Port data is cached.
rrdtool_update_ng($device, 'port-dot3', [
'AlignmentErrors' => $this_port['mtxrInterfaceStatsRxAlignError'],
'FCSErrors' => $this_port['mtxrInterfaceStatsRxFCSError'],
'SingleCollisionFram' => $this_port['mtxrInterfaceStatsTxSingleCollision'],
'MultipleCollisionFr' => $this_port['mtxrInterfaceStatsTxMultipleCollision'],
'SQETestErrors' => 0,
'DeferredTransmissio' => $this_port['mtxrInterfaceStatsTxDeferred'],
'LateCollisions' => $this_port['mtxrInterfaceStatsTxLateCollision'],
'ExcessiveCollisions' => $this_port['mtxrInterfaceStatsTxExcessiveCollision'],
'InternalMacTransmit' => 0,
'CarrierSenseErrors' => $this_port['mtxrInterfaceStatsRxCarrierError'],
'FrameTooLongs' => $this_port['mtxrInterfaceStatsRxTooLong'],
'InternalMacReceiveE' => 0,
'SymbolErrors' => 0,
], get_port_rrdindex($port));
if ($GLOBALS['config']['statsd']['enable'] == TRUE) {
foreach ($etherlike_oids as $oid) {
$value = isset($mikrotik_stats_oids[$oid]) ? $this_port[$mikrotik_stats_oids[$oid]] : 0;
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'port'.'.'.$this_port['ifIndex'].'.'.$oid, $value);
}
}
}
}
// EOF

View File

@ -0,0 +1,121 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// NETAPP-MIB
$mib = 'NETAPP-MIB';
$port_module = 'netapp';
if ($port_stats_count) {
// Check if we're dealing with a retarded ass-backwards OS which feels
// the need to dump standardized variables in its own MIB, apparently just for shits.
// Add NetApp's own table so we can get 64-bit values. They are checked later on.
$port_stats = snmpwalk_cache_oid($device, 'netifEntry', $port_stats, $mib);
$has_ifXEntry = $GLOBALS['snmp_status']; // Needed for additional check HC counters
$process_port_functions[$port_module] = $GLOBALS['snmp_status']; // Additionally, process port with function
} elseif ($has_ifEntry_error_code === OBS_SNMP_ERROR_FAILED_RESPONSE) {
// if not exist ifEntry on device, collect and translate netapp specific tables
print_cli($mib.'::NetIfEntry ');
$netif_stat = snmpwalk_cache_oid($device, 'netifEntry', array(), $mib);
if (safe_count($netif_stat)) {
$has_ifXEntry = $GLOBALS['snmp_status']; // Needed for additional check HC counters
print_debug_vars($netif_stat);
$mib_def = &$config['mibs'][$mib]['ports']['oids']; // Attach MIB options/translations
//print_vars($mib_def);
/*
$data_oids_ifEntry = array(
// ifEntry
'ifDescr', 'ifType', 'ifMtu', 'ifSpeed', 'ifPhysAddress', 'ifAdminStatus', 'ifOperStatus', 'ifLastChange',
);
$data_oids_ifXEntry = array(
// ifXEntry
'ifName', 'ifAlias', 'ifHighSpeed', 'ifPromiscuousMode', 'ifConnectorPresent',
);
*/
$data_oids_netport = [ 'ifType', 'ifMtu', 'ifAdminStatus', 'ifOperStatus',
'ifHighSpeed', 'ifDuplex', 'ifVlan' ];
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
$netport_stat = array();
foreach ($data_oids_netport as $oid) {
$netport_oid = $mib_def[$oid]['oid'];
print_cli($mib.'::'.$netport_oid.' ');
$netport_stat = snmpwalk_cache_twopart_oid($device, $netport_oid, $netport_stat, $mib, NULL, $flags);
}
// disable hex to string conversion for ifPhysAddress
$flags = $flags | OBS_SNMP_HEX;
$netport_oid = $mib_def['ifPhysAddress']['oid'];
print_cli($mib.'::'.$netport_oid.' ');
$netport_stat = snmpwalk_cache_twopart_oid($device, $netport_oid, $netport_stat, $mib, NULL, $flags);
print_debug_vars($netport_stat);
}
// Now rewrite to standard IF-MIB array
foreach ($netif_stat as $ifIndex => $port) {
if (str_contains($port['netifDescr'], ':')) {
list($port['netportNode'], $port['netportPort']) = explode(':', $port['netifDescr'], 2);
} else {
$port['netportNode'] = '';
$port['netportPort'] = $port['netifDescr'];
}
$port['netportPort'] = str_ireplace('MGMT_PORT_ONLY ', '', $port['netportPort']);
if (isset($netport_stat[$port['netportNode']][$port['netportPort']])) {
// ifDescr
$oid = 'ifDescr';
$port[$oid] = $port[$mib_def[$oid]['oid']];
$port_stats[$ifIndex][$oid] = $port[$oid];
// ifName, ifAlias
$port_stats[$ifIndex]['ifName'] = strlen($port['netportNode']) ? $port['netportNode'].':'.$port['netportPort'] : $port['netportPort'];
$port_stats[$ifIndex]['ifAlias'] = ''; // FIXME, I not found
$netport = &$netport_stat[$port['netportNode']][$port['netportPort']];
// ifPhysAddress
$oid = 'ifPhysAddress';
$port[$oid] = strtolower($netport[$mib_def[$oid]['oid']]);
$port[$oid] = str_replace(' ', '', $port[$oid]);
$port_stats[$ifIndex][$oid] = $port[$oid];
// All other data fields
foreach ($data_oids_netport as $oid) {
$port[$oid] = $netport[$mib_def[$oid]['oid']];
if (isset($mib_def[$oid]['transform'])) {
// Translate to standard IF-MIB values
$port[$oid] = string_transform($port[$oid], $mib_def[$oid]['transform']);
}
if ($oid === 'ifVlan' && $port[$oid] < 0) {
$port[$oid] = '';
}
$port_stats[$ifIndex][$oid] = $port[$oid];
}
// ifEntry fields
foreach ($stat_oids_ifEntry as $oid) {
$oid = substr($oid, 2); // remove "if"
// Use only HC counters
$port_stats[$ifIndex]['ifHC'.$oid] = $port['if64'.$oid];
$port_stats[$ifIndex]['if'.$oid] = $port['if64'.$oid];
}
}
}
// Clean
unset($netif_stat, $netport_stat, $netport, $netport_oid, $flags, $ifIndex, $port, $data_oids_netport, $oid);
}
// EOF

View File

@ -0,0 +1,32 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// NETAPP-MIB functions
// Process in main ports loop
function process_port_netapp(&$this_port, $device)
{
$hc_prefix = '64';
// Convert NetApp specific 64-bit values to IF-MIB standard:
// if64InOctets -> ifHCInOctets
foreach (array('Octets', 'UcastPkts', 'BroadcastPkts', 'MulticastPkts') as $oid)
{
$hc_in = 'if' . $hc_prefix . 'In' . $oid;
$hc_out = 'if' . $hc_prefix . 'Out' . $oid;
$this_port['ifHCIn' . $oid] = $this_port[$hc_in];
$this_port['ifHCOut' . $oid] = $this_port[$hc_out];
}
}
// EOF

View File

@ -0,0 +1,254 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module] || is_device_mib($device, 'CISCO-VTP-MIB')) {
// Module disabled, or Cisco device
// Q-BRIDGE-MIB is default mib, need excludes
return FALSE; // False for do not collect stats
}
// Vendor specific
$is_juniper = is_device_mib($device, 'JUNIPER-VLAN-MIB');
//$is_hpe = $device['os'] == 'hh3c';
//BRIDGE-MIB::dot1dBaseNumPorts.0 = INTEGER: 9 ports
//BRIDGE-MIB::dot1dBaseType.0 = INTEGER: transparent-only(2)
//BRIDGE-MIB::dot1dBasePortIfIndex.1 = INTEGER: 1
//BRIDGE-MIB::dot1dBasePortIfIndex.2 = INTEGER: 2
//BRIDGE-MIB::dot1dBasePortIfIndex.3 = INTEGER: 3
//Q-BRIDGE-MIB::dot1qVlanVersionNumber.0 = INTEGER: version1(1)
//Q-BRIDGE-MIB::dot1qMaxVlanId.0 = INTEGER: 4094
//Q-BRIDGE-MIB::dot1qMaxSupportedVlans.0 = Gauge32: 4094
//Q-BRIDGE-MIB::dot1qNumVlans.0 = Gauge32: 1
//Q-BRIDGE-MIB::dot1qVlanStaticName.1 = STRING: VLAN 0001
//Q-BRIDGE-MIB::dot1qVlanStaticEgressPorts.1 = Hex-STRING: 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanForbiddenEgressPorts.1 = Hex-STRING: 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.1 = Hex-STRING: 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanStaticRowStatus.1 = INTEGER: active(1)
// Base port ifIndex association
$dot1d_baseports = snmpwalk_cache_oid($device, 'dot1dBasePortIfIndex', array(), 'BRIDGE-MIB');
$use_baseports = count($dot1d_baseports) > 0;
// Faster (and easy) way for get untagged/primary vlans
//$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qPortVlanTable', array(), 'Q-BRIDGE-MIB');
$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qPvid', array(), 'Q-BRIDGE-MIB');
if (snmp_status() && $use_baseports)
{
echo("dot1qPortVlanTable ");
if ($is_juniper) // EX switches. Unsure if other Juniper platforms "affected"
{
//JUNIPER-VLAN-MIB::jnxExVlanPortAccessMode.22.549 = INTEGER: access(1)
//JUNIPER-VLAN-MIB::jnxExVlanPortAccessMode.25.3 = INTEGER: trunk(2)
//JUNIPER-VLAN-MIB::jnxExVlanPortAccessMode.25.513 = INTEGER: access(1)
foreach (snmpwalk_cache_oid($device, 'jnxExVlanPortAccessMode', array(), 'JUNIPER-VLAN-MIB') as $index => $entry)
{
list(, $index) = explode('.', $index);
$dot1q_ports[$index]['jnxExVlanPortAccessMode'] = $entry['jnxExVlanPortAccessMode'];
}
} else {
$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qPortAcceptableFrameTypes', $dot1q_ports, 'Q-BRIDGE-MIB');
$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qPortIngressFiltering', $dot1q_ports, 'Q-BRIDGE-MIB');
}
print_debug_vars($dot1q_ports);
// Collect trunk port ids and vlans
//$trunk_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `ports_vlans` WHERE `device_id` = ?', [ $device['device_id'] ]);
$trunk_ports = [];
foreach (dbFetchRows('SELECT `port_id`, `vlan` FROM `ports_vlans` WHERE `device_id` = ?', [ $device['device_id'] ]) as $entry) {
$trunk_ports[$entry['port_id']][] = $entry['vlan'];
}
print_debug_vars($trunk_ports);
$vlan_rows = [];
foreach ($dot1q_ports as $index => $entry) {
$vlan_num = $entry['dot1qPvid'];
$ifIndex = $dot1d_baseports[$index]['dot1dBasePortIfIndex'];
if (isset($entry['jnxExVlanPortAccessMode']) && $entry['jnxExVlanPortAccessMode'] === 'trunk') {
$trunk = 'dot1Q';
} elseif (isset($entry['dot1qPortAcceptableFrameTypes']) && $entry['dot1qPortAcceptableFrameTypes'] === 'admitOnlyVlanTagged') {
$trunk = 'dot1Q';
} elseif ((isset($entry['dot1qPortIngressFiltering']) && $entry['dot1qPortIngressFiltering'] === 'true')) {
// Additionally, check if port have trunk ports
$port = get_port_by_index_cache($device, $ifIndex);
print_debug("CHECK. ifIndex: $ifIndex, port_id: ".$port['port_id']);
if (isset($trunk_ports[$port['port_id']]) && (count($trunk_ports[$port['port_id']]) > 1 || $trunk_ports[$port['port_id']][0] != $vlan_num)) {
$trunk = 'dot1Q';
} else {
$trunk = ''; // access
}
} else {
$trunk = ''; // access
}
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex]))
{
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
elseif ($is_juniper)
{
// For juniper Q-BRIDGE is derp, but still required for trunk ports
// skipped here, use only dot1qPvid
} else {
if ($device['os'] == 'zyxeles')
{
// On this devices dot1qVlanStaticUntaggedPorts store incorrect vlan data, ie;
// Note, dot1qVlanStaticEgressPorts - fine!
//Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.609 = Hex-STRING: FF FF FF FF FF FF C0 00 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.862 = Hex-STRING: FF FF FF FF FF FF C0 00 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.917 = Hex-STRING: FF FF FF FF FF FF F0 00 00 00 00 00 00 00 00 00
// Use dot1qVlanCurrentUntaggedPorts instead
//Q-BRIDGE-MIB::dot1qVlanCurrentUntaggedPorts.0.609 = Hex-STRING: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanCurrentUntaggedPorts.0.862 = Hex-STRING: 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00
//Q-BRIDGE-MIB::dot1qVlanCurrentUntaggedPorts.0.917 = Hex-STRING: 00 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00
$oid_name = 'dot1qVlanCurrentUntaggedPorts';
$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qVlanCurrentUntaggedPorts.0', $dot1q_ports, 'Q-BRIDGE-MIB', NULL, OBS_SNMP_ALL_MULTILINE | OBS_SNMP_HEX);
} else {
// Common dot1qVlanStaticUntaggedPorts
$oid_name = 'dot1qVlanStaticUntaggedPorts';
$dot1q_ports = snmpwalk_cache_oid($device, 'dot1qVlanStaticUntaggedPorts', $dot1q_ports, 'Q-BRIDGE-MIB', NULL, OBS_SNMP_ALL_MULTILINE | OBS_SNMP_HEX);
}
if ($is_juniper) // EX switches. Unsure if other Juniper platforms "affected"
{
// Fetch Juniper VLAN table for correct tag
$dot1q_ports = snmpwalk_cache_oid($device, 'jnxExVlanTag', $dot1q_ports, 'JUNIPER-VLAN-MIB');
}
// This is very slow (on some devices and with many ports), very hard to detect correct ports
echo("$oid_name ");
// Detect min ifIndex for vlan base ports
// Why, see here: http://jira.observium.org/browse/OBS-963
/*
if ($use_baseports)
{
$vlan_ifindex_min = $dot1d_baseports[key($dot1d_baseports)]['dot1dBasePortIfIndex']; // First element
foreach ($dot1d_baseports as $entry)
{
// But min ifIndex can be in any entry
$vlan_ifindex_min = min($vlan_ifindex_min, $entry['dot1dBasePortIfIndex']);
}
} else {
$vlan_ifindex_min = 0;
}
*/
foreach ($dot1q_ports as $index => $entry)
{
if (is_device_mib($device, 'JUNIPER-VLAN-MIB')) {
$vlan_num = $entry['jnxExVlanTag'];
} else {
$index_array = explode('.', $index);
$vlan_num = end($index_array); // need explode for dot1qVlanCurrentUntaggedPorts.0
}
// Convert hex to binary map
$binary = hex2binmap($entry[$oid_name]);
$trunk = ''; // unknown
if ($device['os'] === 'ftos') { // FTOS specific
// FTOS devices use harder way for detect VLANs and associate ports
// See: https://www.force10networks.com/CSPortal20/TechTips/0041B_displaying_vlan_ports.aspx
// Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.1107787777, where 1107787777 is ifIndex for Vlan interface
// Port associations based on slot/port, each 12 hex pair (96 bin) is slot
//IF-MIB::ifDescr.1107787777 = STRING: Vlan 1
//IF-MIB::ifDescr.1107787998 = STRING: Vlan 222
list(, $vlan_num) = explode(' ', $port_stats[$index]['ifDescr']);
if (!is_numeric($vlan_num)) { continue; } // Skip unknown
foreach (str_split($binary, 96) as $slot => $binary_map)
{
$length = strlen($binary_map);
for ($i = 0; $i < $length; $i++)
{
if ($binary_map[$i])
{
// Now find slot/port from ifDescr
$port_map = ' '.$slot.'/'.($i + 1);
foreach ($port_stats as $ifIndex => $entry)
{
if (str_ends($entry['ifDescr'], $port_map))
{
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
break; // Stop ports loop
}
}
}
}
}
} else { // All other
// Assign binary vlans map to ports
$length = strlen($binary);
for ($i = 0; $i < $length; $i++)
{
if ($binary[$i])
{
//$ifIndex = $i + $vlan_ifindex_min; // This is incorrect ifIndex association!
if ($use_baseports)
{
$ifIndex = $dot1d_baseports[$i + 1]['dot1dBasePortIfIndex'];
} else {
$ifIndex = $i;
}
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
if (isset($port_stats[$ifIndex]))
{
if (isset($port_stats[$ifIndex]['ifVlan']))
{
print_debug("WARNING. Oid dot1qVlanStaticUntaggedPorts pass incorrect vlan data.");
}
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
}
}
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,145 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// This can use for any RADLAN mib, just tested with cisco sb
// CISCOSB-vlan-MIB
// Dell-vlan-MIB
// DLINK-3100-vlan-MIB
// EDGECORE-vlan-MIB
// NETGEAR-RADLAN-vlan-MIB
// RADLAN-vlan-MIB
// Untagged/primary port vlan
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
/* start polling vlans */
$vlan_ports = snmpwalk_cache_oid($device, 'vlanPortModeState', [], $mib);
if (!snmp_status()) { return; }
// disable other vlan polling (by Q-BRIDGE-MIB)
$ports_modules[$port_module] = FALSE;
// get max vlan number
$vlan_max = get_entity_attrib('device', $device, 'radlan_vlan_max');
if (safe_empty($vlan_max)) {
$vlan_max = 1;
// vlans not discovered
force_discovery($device, 'vlans');
}
/*
if (isset($attribs['radlan_vlan_max'])) {
$vlan_max = $attribs['radlan_vlan_max'];
} else {
$vlan_max = 1;
// vlans not discovered
force_discovery($device, 'vlans');
}
*/
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticEgressList1to1024', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticUntaggedEgressList1to1024', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticForbiddenList1to1024', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
if ($vlan_max > 1024) {
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticEgressList1025to2048', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticUntaggedEgressList1025to2048', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticForbiddenList1025to2048', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
}
if ($vlan_max > 2048) {
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticEgressList2049to3072', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticUntaggedEgressList2049to3072', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticForbiddenList2049to3072', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
}
if ($vlan_max > 3072) {
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticEgressList3073to4094', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticUntaggedEgressList3073to4094', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
//$vlan_ports = snmpwalk_cache_oid($device, 'rldot1qPortVlanStaticForbiddenList3073to4094', $vlan_ports, $mib, NULL, OBS_SNMP_ALL_HEX);
}
print_debug_vars($vlan_ports);
$vlan_oids = [
1 => 'rldot1qPortVlanStaticUntaggedEgressList1to1024',
1025 => 'rldot1qPortVlanStaticUntaggedEgressList1025to2048',
2049 => 'rldot1qPortVlanStaticUntaggedEgressList2049to3072',
3073 => 'rldot1qPortVlanStaticUntaggedEgressList3073to4094',
];
foreach ($vlan_ports as $ifIndex => $entry) {
// vlanPortModeState:
// general(1), access(2), trunk(3), customer QinQ(7)
// 11 ?
switch ($entry['vlanPortModeState']) {
case '1':
case '11': // general is mostly same as 'trunk', only radlan type
case '3':
case '13':
$trunk = 'dot1Q';
break;
case '7':
case '17':
$trunk = 'qinq';
break;
default:
$trunk = '';
}
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
// Untagged vlans
foreach ($vlan_oids as $vlan_start => $oid) {
if (isset($entry[$oid]) && preg_match('/[1-9a-f]/i', $entry[$oid])) {
// not default
$binmap = hex2binmap($entry[$oid]);
$vlan_len = strlen($binmap);
$vlan_end = $vlan_start + $vlan_len - 1;
$vlan_count = substr_count($binmap, '1');
for ($i = 0; $i < $vlan_len; $i++) {
$vlan_num = $vlan_start + $i;
if ($binmap[$i]) {
// Set Vlan
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
//$port_stats[$ifIndex]['ifTrunk'] = $trunk;
$vlan_rows[] = [ $ifIndex, $vlan_num, $trunk ];
// decrease significant vlans and break if all found
$vlan_count--;
if ($vlan_count === 0) {
break;
}
}
}
print_debug("ifIndex $ifIndex Untagged ($vlan_start-$vlan_end): " . $binmap);
}
}
// all unknown ports by default in Vlan 1
if (!isset($port_stats[$ifIndex]['ifVlan'])) {
$port_stats[$ifIndex]['ifVlan'] = '1';
$vlan_rows[] = [ $ifIndex, $port_stats[$ifIndex]['ifVlan'], $trunk ];
}
}
/* end polling vlans */
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,97 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Ports Duplex, Secure
$entries = snmpwalk_cache_oid($device, 'rcPortOperDuplex', array(), 'RAPID-CITY');
//$entries = snmpwalk_cache_oid($device, 'rcPortHighSecureEnable', $entries, 'RAPID-CITY');
foreach ($entries as $ifIndex => $entry)
{
// Set ifDuplex
$port_stats[$ifIndex]['ifDuplex'] = $entry['rcPortOperDuplex'];
}
/*
// Nortel/Avaya have "hidden" ifIndexes for Vlans, which required for discovery IP addresses
$ports_vlans = snmpwalk_cache_oid($device, 'rcVlanIfIndex', array(), 'RAPID-CITY');
$ports_vlans = snmpwalk_cache_oid($device, 'rcVlanName', $ports_vlans, 'RAPID-CITY');
$ports_vlans = snmpwalk_cache_oid($device, 'rcVlanMacAddress', $ports_vlans, 'RAPID-CITY');
foreach ($ports_vlans as $vlan_num => $entry)
{
$ifIndex = $entry['rcVlanIfIndex'];
if (!isset($port_stats[$ifIndex]))
{
// Add hidden/ignored Vlan port
$port_stats[$ifIndex] = array('ifIndex' => $ifIndex,
'ifDescr' => $entry['rcVlanName'],
'ifType' => 'l2vlan',
'ifAlias' => '',
'ifPhysAddress' => $entry['rcVlanMacAddress'],
'ifOperStatus' => 'unknown', // Hardcode Oper status
'ifAdminStatus' => 'up', // Hardcode Admin status
'ignore' => '1', // Set this ports ignored and disabled
'disabled' => '1');
}
}
*/
// Untagged/primary port vlans
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return;
}
/*
RAPID-CITY::rcVlanPortType.513 = INTEGER: access(1)
RAPID-CITY::rcVlanPortType.514 = INTEGER: access(1)
RAPID-CITY::rcVlanPortDefaultVlanId.513 = INTEGER: 8
RAPID-CITY::rcVlanPortDefaultVlanId.514 = INTEGER: 6
*/
// Base vlan IDs
$ports_vlans_oids = snmpwalk_cache_oid($device, 'rcVlanPortDefaultVlanId', array(), 'RAPID-CITY');
if (snmp_status()) {
echo("rcVlanPortDefaultVlanId ");
$ports_vlans_oids = snmpwalk_cache_oid($device, 'rcVlanPortType', $ports_vlans_oids, 'RAPID-CITY');
print_debug_vars($ports_vlans_oids);
$vlan_rows = array();
foreach ($ports_vlans_oids as $ifIndex => $vlan)
{
$vlan_num = $vlan['rcVlanPortDefaultVlanId'];
$trunk = $vlan['rcVlanPortType'] != 'access' ? 'dot1Q' : $vlan['rcVlanPortType'];
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifVlan';
//$process_port_db[$port_module][] = 'ifTrunk';
// EOF

View File

@ -0,0 +1,78 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
/// This is hack for Redback SeOS, while this only os have interfaces in VRF specific SNMP contexts,
/// but only informational fields (without stats)
// Try Ports in VRF SNMP contexts
if (safe_empty($device['snmp_context']) && // Device not already with context
isset($config['os'][$device['os']]['snmp']['virtual']) && $config['os'][$device['os']]['snmp']['virtual'] && // Context permitted for os
$vrf_contexts = safe_json_decode(get_entity_attrib('device', $device, 'vrf_contexts'))) { // SNMP VRF context discovered for device
// Keep original device array
$device_original = $device;
$vrf_ports = [];
$data_oids_vrf = [
// ifEntry
//'ifDescr',
'ifType', 'ifMtu', 'ifSpeed', 'ifPhysAddress',
'ifAdminStatus', 'ifOperStatus', 'ifLastChange',
// ifXEntry
'ifName', 'ifAlias', 'ifHighSpeed', 'ifPromiscuousMode', 'ifConnectorPresent',
//'ifHCInOctets', 'ifInOctets' /// DEVEL
];
foreach ($vrf_contexts as $vrf_name => $snmp_context)
{
print_message("Ports in VRF: $vrf_name...");
$device['snmp_context'] = $snmp_context;
// Get ifDescr and validate if has unique ifIndexes
$port_stats_vrf = snmpwalk_cache_oid($device, 'ifDescr', [], "IF-MIB");
$has_unique_ports = FALSE;
foreach ($port_stats_vrf as $ifIndex => $entry)
{
if (!isset($port_stats[$ifIndex])) {
$has_unique_ports = TRUE;
break;
}
}
// Walk all other data Oids and merge with main stats
if ($has_unique_ports) {
foreach ($data_oids_vrf as $oid) {
$port_stats_vrf = snmpwalk_cache_oid($device, $oid, $port_stats_vrf, "IF-MIB");
}
foreach ($port_stats_vrf as $ifIndex => $entry)
{
// Merge stats
if (!isset($port_stats[$ifIndex])) {
$entry['vrf_name'] = $vrf_name;
$port_stats[$ifIndex] = $entry;
$vrf_ports[$vrf_name][$ifIndex] = $entry;
}
}
}
}
print_debug_vars($vrf_ports);
// Clean
$device = $device_original;
unset($device_original, $vrf_ports, $port_stats_vrf);
} else {
print_debug_vars(get_entity_attrib('device', $device, 'vrf_contexts'));
}
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// SMON-MIB
// Get monitoring ([e|r]span) ports
$smon_statuses = snmpwalk_cache_oid($device, "portCopyStatus", array(), "SMON-MIB");
foreach ($smon_statuses as $smon_index => $smon)
{
list(,$smon_index) = explode('.', $smon_index); // ifIndex
if ($smon['portCopyStatus'] == 'active' && isset($port_stats[$smon_index]))
{
// rewrite the ifOperStatus (for active monitoring destinations)
$port_stats[$smon_index]['ifOperStatus'] = 'monitoring';
}
}
unset($smon, $smon_statuses, $smon_index);
// EOF

View File

@ -0,0 +1,48 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// SW-MIB
// See: http://jira.observium.org/browse/OBSERVIUM-1043
// http://jira.observium.org/browse/OBSERVIUM-854
$port_sw = snmpwalk_cache_oid($device, "swFCPortSpecifier", array(), "SW-MIB");
if (!$GLOBALS['snmp_status']) { return; } // Break walk if not exist data from SW-MIB
$port_sw = snmpwalk_cache_oid($device, "swFCPortName", $port_sw, "SW-MIB");
foreach($port_stats as $ifIndex => $port)
{
foreach($port_sw as $key => $data)
{
$port_fc = $data['swFCPortSpecifier'];
$found_fc = ($port['ifName'] == $port_fc) || preg_match('!^FC\w* port '.$port_fc.'$!', $port['ifDescr']);
if (!$found_fc && is_numeric($port_fc))
{
// non-bladed
$port_fc = '0/' . $port_fc;
$found_fc = ($port['ifName'] == $port_fc) || preg_match('!^FC\w* port '.$port_fc.'$!', $port['ifDescr']);
}
if ($found_fc)
{
print_debug("FOUND FC ifIndex: $ifIndex, Specifier: '$port_fc', ifName: '".$port['ifName']."', ifDescr: '".$port['ifDescr']."', ifAlias: '".$data['swFCPortName']."'");
$port_stats[$ifIndex]['ifAlias'] = $data['swFCPortName'];
unset($port_sw[$key]);
break;
}
}
}
unset($port_sw, $port_fc, $found_fc);
// EOF

View File

@ -0,0 +1,109 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// TIMETRA-PORT-MIB Engress Queue Stats
$port_module = 'sros_egress_qstat';
//print_r($ports_modules);
if ($ports_modules[$port_module] && $port_stats_count)
{
echo("TIMETRA-PORT-MIB Egress Queue Stats ");
$qstat_oids = array('tmnxPortNetEgressFwdInProfPkts',
'tmnxPortNetEgressFwdOutProfPkts',
'tmnxPortNetEgressFwdInProfOcts',
'tmnxPortNetEgressFwdOutProfOcts',
'tmnxPortNetEgressDroInProfPkts',
'tmnxPortNetEgressDroOutProfPkts',
'tmnxPortNetEgressDroInProfOcts',
'tmnxPortNetEgressDroOutProfOcts');
$qstats = snmpwalk_cache_oid($device, array_shift($qstat_oids), array(), "TIMETRA-PORT-MIB");
$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
if ($GLOBALS['snmp_status'])
{
foreach ($qstat_oids as $oid)
{
$qstats = snmpwalk_cache_oid($device, $oid, $qstats, "TIMETRA-PORT-MIB");
}
foreach($qstats as $qstat_index => $qstat)
{
list($qstat_chassis, $qstat_ifindex, $qstat_queue) = explode('.', $qstat_index);
$port_stats[$qstat_ifindex]['sros_egress_qstat'][$qstat_queue] = $qstat;
}
unset($qstats);
}
//print_vars($port_stats);
}
// TIMETRA-PORT-MIB Ingress Queue Stats
$port_module = 'sros_ingress_qstat';
//print_r($ports_modules);
if ($ports_modules[$port_module] && $port_stats_count)
{
echo("TIMETRA-PORT-MIB Ingress Queue Stats ");
$qstat_oids = array('tmnxPortNetIngressFwdInProfPkts',
'tmnxPortNetIngressFwdOutProfPkts',
'tmnxPortNetIngressFwdInProfOcts',
'tmnxPortNetIngressFwdOutProfOcts',
'tmnxPortNetIngressDroInProfPkts',
'tmnxPortNetIngressDroOutProfPkts',
'tmnxPortNetIngressDroInProfOcts',
'tmnxPortNetIngressDroOutProfOcts');
$qstats = snmpwalk_cache_oid($device, array_shift($qstat_oids), array(), "TIMETRA-PORT-MIB");
$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
if ($GLOBALS['snmp_status'])
{
foreach ($qstat_oids as $oid)
{
$qstats = snmpwalk_cache_oid($device, $oid, $qstats, "TIMETRA-PORT-MIB");
}
foreach($qstats as $qstat_index => $qstat)
{
list($qstat_chassis, $qstat_ifindex, $qstat_queue) = explode('.', $qstat_index);
$port_stats[$qstat_ifindex]['sros_ingress_qstat'][$qstat_queue] = $qstat;
}
unset($qstats);
}
//print_vars($port_stats);
}
// Additional db fields for update
//$process_port_db[$port_module][] = 'ifDuplex'; // this field used in main data fields
// EOF

View File

@ -0,0 +1,83 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// TIMETRA-MIB-MIB functions
// Per-port Egress Queue Statistics
function process_port_sros_egress_qstat(&$this_port, $device, $port)
{
if(isset($this_port['sros_egress_qstat']) && count($this_port['sros_egress_qstat']))
{
$queues = array();
foreach($this_port['sros_egress_qstat'] as $q_index => $q_stats)
{
rrdtool_update_ng($device, 'port-sros_egress_qstat', array(
'FwdInProfPkts' => $q_stats['tmnxPortNetEgressFwdInProfPkts'],
'FwdOutProfPkts' => $q_stats['tmnxPortNetEgressFwdOutProfPkts'],
'FwdInProfOcts' => $q_stats['tmnxPortNetEgressFwdInProfOcts'],
'FwdOutProfOcts' => $q_stats['tmnxPortNetEgressFwdOutProfOcts'],
'DroInProfPkts' => $q_stats['tmnxPortNetEgressDroInProfPkts'],
'DroOutProfPkts' => $q_stats['tmnxPortNetEgressDroOutProfPkts'],
'DroInProfOcts' => $q_stats['tmnxPortNetEgressDroInProfOcts'],
'DroOutProfOcts' => $q_stats['tmnxPortNetEgressDroOutProfOcts'],
), get_port_rrdindex($port).'-'.$q_index);
$queues[] = $q_index;
}
set_entity_attrib('port', $port['port_id'], 'sros_egress_queues', json_encode($queues));
}
// FIXME -- remove attrib if it doesn't exist.
}
// Per-port Ingress Queue Statistics
function process_port_sros_ingress_qstat(&$this_port, $device, $port)
{
if(isset($this_port['sros_ingress_qstat']) && count($this_port['sros_ingress_qstat']))
{
$queues = array();
foreach($this_port['sros_ingress_qstat'] as $q_index => $q_stats)
{
rrdtool_update_ng($device, 'port-sros_ingress_qstat', array(
'FwdInProfPkts' => $q_stats['tmnxPortNetIngressFwdInProfPkts'],
'FwdOutProfPkts' => $q_stats['tmnxPortNetIngressFwdOutProfPkts'],
'FwdInProfOcts' => $q_stats['tmnxPortNetIngressFwdInProfOcts'],
'FwdOutProfOcts' => $q_stats['tmnxPortNetIngressFwdOutProfOcts'],
'DroInProfPkts' => $q_stats['tmnxPortNetIngressDroInProfPkts'],
'DroOutProfPkts' => $q_stats['tmnxPortNetIngressDroOutProfPkts'],
'DroInProfOcts' => $q_stats['tmnxPortNetIngressDroInProfOcts'],
'DroOutProfOcts' => $q_stats['tmnxPortNetIngressDroOutProfOcts'],
), get_port_rrdindex($port).'-'.$q_index);
$queues[] = $q_index;
}
set_entity_attrib('port', $port['port_id'], 'sros_ingress_queues', json_encode($queues));
}
// FIXME -- remove attrib if it doesn't exist.
}

View File

@ -0,0 +1,125 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Untagged/primary port vlans
$port_module = 'vlan';
if (!$ports_modules[$port_module]) {
// Module disabled
return FALSE; // False for do not collect stats
}
/*
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49154 = INTEGER: 999
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49155 = INTEGER: 744
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49156 = INTEGER: 2616
*/
// Base vlan IDs
$ports_vlans_oids = snmpwalk_cache_oid($device, 'vlanPortPvid', [], 'TPLINK-DOT1Q-VLAN-MIB');
print_debug_vars($ports_vlans_oids);
if (snmp_status()) {
echo("vlanPortPvid ");
// TPLINK-DOT1Q-VLAN-MIB::vlanPortNumber.49154 = STRING: "1/0/2"
$port_descr = [];
foreach(snmpwalk_cache_oid($device, 'vlanPortNumber', [], 'TPLINK-DOT1Q-VLAN-MIB') as $index => $entry) {
$port_descr[$entry['vlanPortNumber']] = $index;
}
// TPLINK-DOT1Q-VLAN-MIB::vlanTagPortMemberAdd.8 = ""
// TPLINK-DOT1Q-VLAN-MIB::vlanTagPortMemberAdd.10 = STRING: "1/0/4,1/0/11,1/0/13,1/0/15,1/0/19-20"
$port_trunks = [];
foreach (snmpwalk_cache_oid($device, 'vlanTagPortMemberAdd', [], 'TPLINK-DOT1Q-VLAN-MIB') as $vlan_num => $vlan) {
if (safe_empty($vlan['vlanTagPortMemberAdd'])) { continue; }
// See: https://jira.observium.org/browse/OBS-3827
// TPLINK-DOT1Q-VLAN-MIB::vlanTagPortMemberAdd.10 = STRING: "1/0/4,1/0/11,1/0/13,1/0/15,1/0/19-20"
// TPLINK-DOT1Q-VLAN-MIB::vlanTagPortMemberAdd.2 = STRING: "Gi1/0/3-24,Te1/0/27-28,Gi2/0/3-24,Te2/0/27-28,Po1-3,7,11,13-14"
$members = [];
$i = -1;
foreach (explode(',', $vlan['vlanTagPortMemberAdd']) as $member) {
if (!preg_match('/^\d+(\-\d+)?$/', $member)) {
$i++;
$members[$i] = $member;
} else {
// append to previous
$members[$i] .= ',' . $member;
}
}
$member_base = '';
foreach ($members as $member) {
if (isset($port_descr[$member])) {
$ifIndex = $port_descr[$member];
$port_trunks[$ifIndex][$vlan_num] = $vlan_num;
continue;
}
if (preg_match('/^([^\d]+)(.+)$/', $member, $matches)) {
$member_base = $matches[1];
}
if (str_contains_array($member, [ '-', ',' ])) {
// Expand list to individual ports
if (str_contains($member, '/')) {
// 1/0/19-20,30
// Te2/0/27-28,30
$split_char = '/';
$member_array = explode($split_char, $member);
} elseif (preg_match('/^([^\d]+)(.+)$/', $member, $matches)) {
// Po1-3,7,11,13-14
$split_char = '';
$member_array = [ $matches[1], $matches[2] ];
}
$numbers = array_pop($member_array);
foreach (list_to_range($numbers) as $number) {
$member_new = $member_array;
$member_new[] = $number;
$member_name = implode($split_char, $member_new);
if (isset($port_descr[$member_name])) {
$ifIndex = $port_descr[$member_name];
$port_trunks[$ifIndex][$vlan_num] = $vlan_num;
continue;
}
if (isset($port_descr[$member_base.$member_name])) {
$ifIndex = $port_descr[$member_base.$member_name];
$discovery_ports_vlans[$ifIndex][$vlan_num] = [ 'vlan' => $vlan_num ];
continue;
}
}
} elseif (isset($port_descr[$member_base.$member])) {
$ifIndex = $port_descr[$member_base.$member];
$discovery_ports_vlans[$ifIndex][$vlan_num] = [ 'vlan' => $vlan_num ];
continue;
}
print_debug("Unknown port name for Tagged Vlans: $member");
}
}
$vlan_rows = array();
foreach ($ports_vlans_oids as $ifIndex => $vlan) {
$vlan_num = $vlan['vlanPortPvid'];
$trunk = isset($port_trunks[$ifIndex]) ? 'dot1Q' : 'access';
$vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
// Set Vlan and Trunk
$port_stats[$ifIndex]['ifVlan'] = $vlan_num;
$port_stats[$ifIndex]['ifTrunk'] = $trunk;
}
}
$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
print_cli_table($vlan_rows, $headers);
// EOF