1<?php
2
3/**
4 * Observium
5 *
6 *   This file is part of Observium.
7 *
8 * @package    observium
9 * @subpackage poller
10 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
11 *
12 */
13
14// Untagged/primary port vlan
15
16$port_module = 'vlan';
17
18if (!$ports_modules[$port_module])
19{
20  // Module disabled
21  return;
22}
23
24$start = microtime(TRUE); // Module timing start
25
26//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.39 = INTEGER: 92
27//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.40 = INTEGER: 93
28//HUAWEI-L2IF-MIB::hwL2IfPortIfIndex.46 = INTEGER: 99
29//HUAWEI-L2IF-MIB::hwL2IfPVID.39 = INTEGER: 0
30//HUAWEI-L2IF-MIB::hwL2IfPVID.40 = INTEGER: 1
31//HUAWEI-L2IF-MIB::hwL2IfPVID.46 = INTEGER: 1
32//HUAWEI-L2IF-MIB::hwL2IfActivePortType.39 = INTEGER: invalid(0)
33//HUAWEI-L2IF-MIB::hwL2IfActivePortType.40 = INTEGER: trunk(1)
34//HUAWEI-L2IF-MIB::hwL2IfActivePortType.46 = INTEGER: access(2)
35
36// Base port ifIndex association
37$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPortIfIndex', array(), 'HUAWEI-L2IF-MIB');
38
39if (snmp_status())
40{
41  echo("dot1qPortVlanTable ");
42  $vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPVID',           $vlan_oids, 'HUAWEI-L2IF-MIB');
43  //$vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfActivePortType', $vlan_oids, 'HUAWEI-L2IF-MIB');
44  //if (!snmp_status())
45  //{
46    $vlan_oids = snmpwalk_cache_oid($device, 'hwL2IfPortType', $vlan_oids, 'HUAWEI-L2IF-MIB');
47  //}
48  print_debug_vars($vlan_oids);
49
50  $vlan_rows = array();
51  foreach ($vlan_oids as $index => $entry)
52  {
53    $vlan_num = $entry['hwL2IfPVID'];
54    $ifIndex  = $entry['hwL2IfPortIfIndex'];
55
56    //$port_type = (isset($entry['hwL2IfActivePortType'])) ? $entry['hwL2IfActivePortType'] : $entry['hwL2IfPortType'];
57    $port_type = $entry['hwL2IfPortType'];
58    switch ($port_type)
59    {
60      case 'trunk':
61        $trunk = 'dot1Q';
62        break;
63      case 'qinq':
64        $trunk = 'QinQ';
65        break;
66      case 'hybrid':
67      case 'fabric':
68        $trunk = $port_type;
69        break;
70      case 'invalid':
71        // Skip invalid Vlan 0
72        continue 2;
73      default:
74        $trunk = '';
75    }
76
77    $vlan_rows[] = array($ifIndex, $vlan_num, $trunk);
78
79    // Set Vlan and Trunk
80    if (isset($port_stats[$ifIndex]))
81    {
82      $port_stats[$ifIndex]['ifVlan']  = $vlan_num;
83      $port_stats[$ifIndex]['ifTrunk'] = $trunk;
84    }
85  }
86
87}
88
89$device_state['poller_ports_perf'][$port_module] += microtime(TRUE) - $start; // Module timing
90
91$headers = array('%WifIndex%n', '%WVlan%n', '%WTrunk%n');
92print_cli_table($vlan_rows, $headers);
93
94//$process_port_functions[$port_module] = $GLOBALS['snmp_status'];
95
96// Additional db fields for update
97//$process_port_db[$port_module][] = 'ifVlan';
98//$process_port_db[$port_module][] = 'ifTrunk';
99
100// EOF
101