diff --git a/OSS_SNMP/MIBS/Bridge.php b/OSS_SNMP/MIBS/Bridge.php index 354d6c8ee..f0c67bd67 100644 --- a/OSS_SNMP/MIBS/Bridge.php +++ b/OSS_SNMP/MIBS/Bridge.php @@ -41,23 +41,62 @@ * @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland * @author Barry O'Donovan */ -class Bridge extends \OSS_SNMP\MIB -{ - const OID_BRIDGE_BASE_PORT_IF_INDEX = '.1.3.6.1.2.1.17.1.4.1.2'; +class Bridge extends \OSS_SNMP\MIB { + + const OID_BRIDGE_BASE_PORT_IF_INDEX = '.1.3.6.1.2.1.17.1.4.1.2'; + const OID_BRIDGE_MAC_ADDRESS = '.1.3.6.1.2.1.17.4.3.1.1'; + const OID_BRIDGE_MAC_ADDRESS_BASE_PORT = '.1.3.6.1.2.1.17.4.3.1.2'; /** * Returns an associate array of STP port IDs (key) to interface IDs (value) * * e.g. [22] => 10122 * - * - * @return array Associate array of STP port IDs (key) to interface IDs (value) + * @param $baseport int base port to ask for + * @return array Associate array of STP port IDs (key) to interface IDs (value) or only for $baseport if supplied */ - public function basePortIfIndexes() + public function basePortIfIndexes($baseport = null) { - return $this->getSNMP()->walk1d( self::OID_BRIDGE_BASE_PORT_IF_INDEX ); + $oid = self::OID_BRIDGE_BASE_PORT_IF_INDEX; + if ($baseport) { + $oid .= "." . $baseport; + } + return $this->getSNMP()->subOidWalk($oid, 12); } -} + /** + * Returns array Associative MAC ADDRESSES (value) to unique index (key) + * NOTE: unique index (key) is the decimal macaddress + * (ex. 0.0.136.54.152.12 is 00:00:88:36:98:0C + * + * e.g. [0.0.136.54.152.12] => 00008836980C + * + * @return array Associative MAC ADDRESSES (value) to unique index (key) + */ + public function macAddressList() { + return $this->getSNMP()->subOidWalk(self::OID_BRIDGE_MAC_ADDRESS, 12, -1); + } + /** + * Returns array Associative of BasePort (value) to unique index (key) + * for mac address listed in self::macAddressList() + * Use basePortIfIndexes to obtain interface + * NOTE: unique index (key) is the decimal macaddress + * (ex. 0.0.136.54.152.12 is 00:00:88:36:98:0C + * + * e.g. [0.0.136.54.152.12] => 2 + * + * + * @param $decimalmac string macaddress in decimal format (see NOTE) to search for + * @return array Associative of BasePort (value) to unique index (key) + * for mac address listed in self::macAddressList() or only for $decimalmac if supplied + */ + public function macAddressBasePort($decimalmac = null) { + $oid = self::OID_BRIDGE_MAC_ADDRESS_BASE_PORT; + if ($decimalmac) { + $oid .= "." . $decimalmac; + } + return $this->getSNMP()->subOidWalk($oid, 12, -1); + } +} diff --git a/OSS_SNMP/MIBS/Cisco/PAGP.php b/OSS_SNMP/MIBS/Cisco/PAGP.php new file mode 100644 index 000000000..738fb6844 --- /dev/null +++ b/OSS_SNMP/MIBS/Cisco/PAGP.php @@ -0,0 +1,81 @@ + + */ +class PAGP extends \OSS_SNMP\MIBS\Cisco +{ + + const OID_PAGP_GROUPIFINDEX = '1.3.6.1.4.1.9.9.98.1.1.1.1.8'; + + /** + * + * @return associative array with the physic interface index (key) and the agregation port ifindex (value) + * if key == value OR value == 0 not agregation + */ + public function groupIfIndex() { + return $this->getSNMP()->subOidWalk( self::OID_PAGP_GROUPIFINDEX, 15 ); + } + + /** + * Gets an associate array of PAGP ports with the [id] => name of it's constituent ports + * + * E.g.: + * [5048] => Array + * ( + * [10111] => GigabitEthernet1/0/11 + * [10112] => GigabitEthernet1/0/12 + * ) + * + * @return array Associate array of LAG ports with the [id] => name of it's constituent ports + */ + public function getPAGPPorts() + { + $ports = array(); + + foreach( $this->groupIfIndex() as $portId => $aggPortId ) + if( $aggPortId != 0 && $portId != $aggPortId) + $ports[ $aggPortId ][$portId] = $this->getSNMP()->useIface()->names()[$portId]; + + return $ports; + } + +} diff --git a/OSS_SNMP/MIBS/Cisco/VlanMembership.php b/OSS_SNMP/MIBS/Cisco/VlanMembership.php new file mode 100644 index 000000000..b95acfa59 --- /dev/null +++ b/OSS_SNMP/MIBS/Cisco/VlanMembership.php @@ -0,0 +1,184 @@ + + */ +class VlanMembership extends \OSS_SNMP\MIBS\Cisco +{ + const OID_VLAN_MEMBERSHIP_VLAN_TYPE = '.1.3.6.1.4.1.9.9.68.1.2.2.1.1'; + const OID_VLAN_MEMBERSHIP_VLAN = '.1.3.6.1.4.1.9.9.68.1.2.2.1.2'; + const OID_VLAN_MEMBERSHIP_PORT_STATUS = '.1.3.6.1.4.1.9.9.68.1.2.2.1.3'; + + /** + * Constant for possible value of interface vlan type. + * + * @see vlanTypes() + */ + const VLAN_MEMBERSHIP_VLAN_TYPE_STATIC = 1; + + /** + * Constant for possible value of interface vlan type. + * + * @see vlanTypes() + */ + const VLAN_MEMBERSHIP_VLAN_TYPE_DYNAMIC = 2; + + /** + * Constant for possible value of interface vlan type. + * + * @see vlanTypes() + */ + const VLAN_MEMBERSHIP_VLAN_TYPE_MULTI_VLAN = 3; + + /** + * Text representation of interface vlan type. + * + * @see vlanTypes() + * + * @var array Text representations of interface vlan type. + */ + public static $VLAN_MEMBERSHIP_VLAN_TYPES = [ + self::VLAN_MEMBERSHIP_VLAN_TYPE_STATIC => 'static', + self::VLAN_MEMBERSHIP_VLAN_TYPE_DYNAMIC => 'dynamic', + self::VLAN_MEMBERSHIP_VLAN_TYPE_MULTI_VLAN => 'multiVlan', + ]; + + /** + * Get an array of the type of VLAN membership of each device port. + * + * E.g. the follow SNMP output yields the shown array: + * + * .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: static(1) + * .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: dynamic(2) + * ... + * + * [10128] => 1 + * [10129] => 2 + * + * @return array + */ + public function vlanTypes($translate = false) + { + $states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN_TYPE); + + if (!$translate) { + return $states; + } + + return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_VLAN_TYPES); + } + + /** + * Get an array of the VLAN id of each device port in access mode. + * + * E.g. the follow SNMP output yields the shown array: + * + * .1.3.6.1.4.1.9.9.68.1.2.2.1.2.10128 = INTEGER: 1 + * .1.3.6.1.4.1.9.9.68.1.2.2.1.2.10129 = INTEGER: 10 + * ... + * + * [10128] => 1 + * [10129] => 10 + */ + public function vlans() + { + return $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN); + } + + /** + * Constant for possible value of the current VLAN status of the port. + * + * @see portStatus() + */ + const VLAN_MEMBERSHIP_PORT_STATUS_INACTIVE = 1; + + /** + * Constant for possible value of the current VLAN status of the port. + * + * @see portStatus() + */ + const VLAN_MEMBERSHIP_PORT_STATUS_ACTIVE = 2; + + /** + * Constant for possible value of the current VLAN status of the port. + * + * @see portStatus() + */ + const VLAN_MEMBERSHIP_PORT_STATUS_SHUTDOWN = 3; + + /** + * Text representation of VLAN status of the port. + * + * @see vlanTypes() + * + * @var array Text representations of interface vlan type. + */ + public static $VLAN_MEMBERSHIP_PORT_STATUS = [ + self::VLAN_MEMBERSHIP_PORT_STATUS_INACTIVE => 'inactive', + self::VLAN_MEMBERSHIP_PORT_STATUS_ACTIVE => 'active', + self::VLAN_MEMBERSHIP_PORT_STATUS_SHUTDOWN => 'shutdown', + ]; + + /** + * Get an array of the current status of VLAN in each device port. + * + * .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: inactive(1) + * .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: active(2) + * ... + * + * [10128] => 1 + * [10129] => 2 + * + * @param bool $translate If true, return the string representation. + * + * @return array An array with the current VLAN status of ports. + */ + public function portStatus($translate = false) + { + $states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_PORT_STATUS); + + if (!$translate) { + return $states; + } + + return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_PORT_STATUS); + } +} diff --git a/OSS_SNMP/MIBS/Entity.php b/OSS_SNMP/MIBS/Entity.php index 25eb040ce..901cd2165 100644 --- a/OSS_SNMP/MIBS/Entity.php +++ b/OSS_SNMP/MIBS/Entity.php @@ -40,16 +40,25 @@ * * @copyright Copyright (c) 2012 - 2013, Open Source Solutions Limited, Dublin, Ireland * @author Barry O'Donovan + * @author Sergio Gómez */ class Entity extends \OSS_SNMP\MIB { const OID_ENTITY_PHYSICAL_DESCRIPTION = '.1.3.6.1.2.1.47.1.1.1.1.2'; + const OID_ENTITY_PHYSICAL_VENDOR_TYPE = '.1.3.6.1.2.1.47.1.1.1.1.3'; + const OID_ENTITY_PHYSICAL_CONTAINED_IN = '.1.3.6.1.2.1.47.1.1.1.1.4'; const OID_ENTITY_PHYSICAL_CLASS = '.1.3.6.1.2.1.47.1.1.1.1.5'; const OID_ENTITY_PHYSICAL_PARENT_REL_POS = '.1.3.6.1.2.1.47.1.1.1.1.6'; const OID_ENTITY_PHYSICAL_NAME = '.1.3.6.1.2.1.47.1.1.1.1.7'; + const OID_ENTITY_PHYSICAL_HARDWARE_REV = '.1.3.6.1.2.1.47.1.1.1.1.8'; + const OID_ENTITY_PHYSICAL_FIRMWARE_REV = '.1.3.6.1.2.1.47.1.1.1.1.9'; + const OID_ENTITY_PHYSICAL_SOFTWARE_REV = '.1.3.6.1.2.1.47.1.1.1.1.10'; + const OID_ENTITY_PHYSICAL_SERIALNUM = '.1.3.6.1.2.1.47.1.1.1.1.11'; + const OID_ENTITY_PHYSICAL_MFG_NAME = '.1.3.6.1.2.1.47.1.1.1.1.12'; + const OID_ENTITY_PHYSICAL_MODEL_NAME = '.1.3.6.1.2.1.47.1.1.1.1.13'; const OID_ENTITY_PHYSICAL_ALIAS = '.1.3.6.1.2.1.47.1.1.1.1.14'; - - + const OID_ENTITY_PHYSICAL_ASSET_ID = '.1.3.6.1.2.1.47.1.1.1.1.15'; + const OID_ENTITY_PHYSICAL_IS_FRU = '.1.3.6.1.2.1.47.1.1.1.1.16'; /** * Returns an associate array of entPhysicalDescr @@ -91,43 +100,43 @@ public function physicalName() /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_CHASSIS = 3; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_CONTAINER = 5; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_POWER_SUPPLY = 6; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_FAN = 7; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_SENSOR = 8; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_MODULE = 9; /** * Physical entitly class type - * @var Physical entitly class type + * @var int Physical entitly class type */ const PHYSICAL_CLASS_PORT = 10; @@ -216,8 +225,168 @@ public function relPosToAlias() return $rtn; } + + /** + * Returns an associate array of entPhysicalSerialNum + * + * e.g. + * + * [1001] = STRING: "FOC16829FD54" + * [1002] = STRING: "" + * [1003] = STRING: "" + * [1004] = STRING: "" + * + * @return array Associate array of entPhysicalSerialNum + */ + public function physicalSerialNum() + { + return $this->getSNMP()->walk1d( self::OID_ENTITY_PHYSICAL_SERIALNUM ); + } -} + /** + * Returns an associate array of entPhysicalVendorType + * + * e.g. + * + * [1] => .1.3.6.1.4.1.9.12.3.1.3.144 + * [2] => .1.3.6.1.4.1.9.12.3.1.5.1 + * [3] => .1.3.6.1.4.1.9.12.3.1.5.1 + * [4] => .1.3.6.1.4.1.9.12.3.1.5.1 + * + * @return array Associate array of entPhysicalVendorType + */ + public function physicalVendorType() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_VENDOR_TYPE); + } + + /** + * Returns an associate array of entPhysicalContainedIn + * + * e.g. + * + * [1] => 0 + * [2] => 1 + * [3] => 1 + * [4] => 1 + * + * @return array Associate array of entPhysicalContainedIn + */ + public function physicalContainedIndex() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_CONTAINED_IN); + } + /** + * Returns an associate array of entPhysicalHardwareRev + * + * e.g. + * + * [1] => V2 + * [2] => + * [3] => + * [4] => + * + * @return array Associate array of entPhysicalHardwareRev + */ + public function physicalHardwareRevision() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_HARDWARE_REV); + } + /** + * Returns an associate array of entPhysicalFirmwareRev + * + * e.g. + * + * [1] => 12.1(22)EA14 + * [2] => + * [3] => + * [4] => + * + * @return array Associate array of entPhysicalFirmwareRev + */ + public function physicalFirmwareRevision() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_FIRMWARE_REV); + } + + /** + * Returns an associate array of entPhysicalSoftwareRev + * + * e.g. + * + * [1] => 12.1(22)EA14 + * [2] => + * [3] => + * [4] => + * + * @return array Associate array of entPhysicalSoftwareRev + */ + public function physicalSoftwareRevision() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_SOFTWARE_REV); + } + + /** + * Returns an associate array of entPhysicalMfgName + * + * e.g. + * + * [1] => cisco + * [2] => cisco + * [3] => cisco + * [4] => cisco + * + * @return array Associate array of entPhysicalMfgName + */ + public function physicalManufacturerName() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_MFG_NAME); + } + + /** + * Returns an associate array of entPhysicalModelName + * + * e.g. + * + * [1] => WS-C6509-E + * [2] => + * [3] => + * [4] => + * + * @return array Associate array of entPhysicalModelName + */ + public function physicalModelName() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_MODEL_NAME); + } + + /** + * Returns an associate array of entPhysicalAssetID + * + * @return array Associate array of entPhysicalAssetID + */ + public function physicalAssetId() + { + return $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_ASSET_ID); + } + + /** + * Returns an associate array of entPhysicalIsFRU + * + * e.g. + * + * [1] => true + * [2] => false + * [3] => false + * [4] => false + * + * @return array Associate array of entPhysicalIsFRU + */ + public function physicalIsFRU() + { + return $this->getSNMP()->ppTruthValue($this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_IS_FRU)); + } +} diff --git a/OSS_SNMP/MIBS/Extreme/Port.php b/OSS_SNMP/MIBS/Extreme/Port.php new file mode 100644 index 000000000..20cecd1e3 --- /dev/null +++ b/OSS_SNMP/MIBS/Extreme/Port.php @@ -0,0 +1,50 @@ + + */ +class Port extends \OSS_SNMP\MIBS\Extreme +{ + const OID_PORT_CONG_DROP_PKTS = '.1.3.6.1.4.1.1916.1.4.14.1.1'; + + +} diff --git a/OSS_SNMP/MIBS/Extreme/Vlan.php b/OSS_SNMP/MIBS/Extreme/Vlan.php index 608ebb61d..2bb243096 100644 --- a/OSS_SNMP/MIBS/Extreme/Vlan.php +++ b/OSS_SNMP/MIBS/Extreme/Vlan.php @@ -426,5 +426,3 @@ public function getPortsForVlan( $vlanIfIndex, $fn = null ) } } - - diff --git a/OSS_SNMP/MIBS/Huawei.php b/OSS_SNMP/MIBS/Huawei.php new file mode 100644 index 000000000..c4839f888 --- /dev/null +++ b/OSS_SNMP/MIBS/Huawei.php @@ -0,0 +1,12 @@ +getSNMP()->get( self::OID_SYSTEM_SOFTWARE_VERSION ); + } + + /** + * Returns the system activated patch + * + * @return string The system activated patch + */ + public function activatedPatch() + { + try { + return $this->getSNMP()->get( self::OID_SYSTEM_ACTIVE_PATCH_VERSION ); + } catch( \OSS_SNMP\Exception $e ) { + return null; + } + } + +} diff --git a/OSS_SNMP/MIBS/Iface.php b/OSS_SNMP/MIBS/Iface.php index e94a942c1..1b9382560 100644 --- a/OSS_SNMP/MIBS/Iface.php +++ b/OSS_SNMP/MIBS/Iface.php @@ -44,7 +44,7 @@ class Iface extends \OSS_SNMP\MIB { const OID_IF_NUMBER = '.1.3.6.1.2.1.2.1.0'; - + const OID_IF_INDEX = '.1.3.6.1.2.1.2.2.1.1'; const OID_IF_DESCRIPTION = '.1.3.6.1.2.1.2.2.1.2'; const OID_IF_TYPE = '.1.3.6.1.2.1.2.2.1.3'; @@ -70,9 +70,25 @@ class Iface extends \OSS_SNMP\MIB const OID_IF_OUT_QUEUE_LENGTH = '.1.3.6.1.2.1.2.2.1.21'; const OID_IF_NAME = '.1.3.6.1.2.1.31.1.1.1.1'; + const OID_IF_IN_MULTICAST = '.1.3.6.1.2.1.31.1.1.1.2'; // no fn() implemented + const OID_IF_IN_BROADCAST = '.1.3.6.1.2.1.31.1.1.1.3'; // no fn() implemented + const OID_IF_OUT_MULTICAST = '.1.3.6.1.2.1.31.1.1.1.4'; // no fn() implemented + const OID_IF_OUT_BROADCAST = '.1.3.6.1.2.1.31.1.1.1.5'; // no fn() implemented + const OID_IF_HC_IN_OCTETS = '.1.3.6.1.2.1.31.1.1.1.6'; // no fn() implemented + const OID_IF_HC_IN_UNICAST_PACKETS = '.1.3.6.1.2.1.31.1.1.1.7'; // no fn() implemented + const OID_IF_HC_IN_MULTICAST = '.1.3.6.1.2.1.31.1.1.1.8'; // no fn() implemented + const OID_IF_HC_IN_BROADCAST = '.1.3.6.1.2.1.31.1.1.1.9'; // no fn() implemented + const OID_IF_HC_OUT_OCTETS = '.1.3.6.1.2.1.31.1.1.1.10'; // no fn() implemented + const OID_IF_HC_OUT_UNICAST_PACKETS = '.1.3.6.1.2.1.31.1.1.1.11'; // no fn() implemented + const OID_IF_HC_OUT_MULTICAST = '.1.3.6.1.2.1.31.1.1.1.12'; // no fn() implemented + const OID_IF_HC_OUT_BROADCAST = '.1.3.6.1.2.1.31.1.1.1.13'; // no fn() implemented + const OID_IF_LINK_UP_DOWN_TRAP = '.1.3.6.1.2.1.31.1.1.1.14'; // no fn() implemented const OID_IF_HIGH_SPEED = '.1.3.6.1.2.1.31.1.1.1.15'; + const OID_IF_PROMISCUOUS_MODE = '.1.3.6.1.2.1.31.1.1.1.16'; // no fn() implemented + const OID_IF_CONNECTOR_PRESENT = '.1.3.6.1.2.1.31.1.1.1.17'; // no fn() implemented const OID_IF_ALIAS = '.1.3.6.1.2.1.31.1.1.1.18'; - + const OID_IF_COUNTER_DISCONTINUTIY = '.1.3.6.1.2.1.31.1.1.1.19'; // no fn() implemented + /** * Get the number of network interfaces (regardless of * their current state) present on this system. @@ -109,12 +125,12 @@ public function mtus() public function physAddresses() { $pa = $this->getSNMP()->walk1d( self::OID_IF_PHYS_ADDRESS ); - + // some switches return leading '00:' as '0:' - we correct this here: foreach( $pa as $i => $a ) if( strpos( $a, ':' ) == 1 ) $pa[ $i ] = '0' . $a; - + return $pa; } @@ -195,16 +211,16 @@ public function adminStates( $translate = false ) public function lastChanges( $asUnixTimestamp = false ) { $lc = $this->getSNMP()->walk1d( self::OID_IF_LAST_CHANGE ); - + if( $asUnixTimestamp ) { $sysUptime = $this->getSNMP()->useSystem()->uptime() / 100; - + foreach( $lc as $i => $t ) if( $t ) $lc[$i] = intval( floor( time() - $sysUptime + ( $t / 100 ) ) ); } - + return $lc; } @@ -524,9 +540,9 @@ public function highSpeeds() { return $this->getSNMP()->walk1d( self::OID_IF_HIGH_SPEED ); } - - - + + + /** * Constant for possible value of interface operation status. * @see operationStates() @@ -2285,5 +2301,3 @@ public function bridgeBasePortIfIndexes() } } - - diff --git a/OSS_SNMP/MIBS/Ip.php b/OSS_SNMP/MIBS/Ip.php new file mode 100644 index 000000000..6d4eab2cf --- /dev/null +++ b/OSS_SNMP/MIBS/Ip.php @@ -0,0 +1,68 @@ + + */ +class Ip extends \OSS_SNMP\MIB +{ + const OID_IP_NET_TO_MEDIA_PHY_ADDRESS = '.1.3.6.1.2.1.4.22.1.2'; + const OID_IP_ADDRESS = '.1.3.6.1.2.1.4.20.1.1'; + + /** Returns an associative array of IpAddresses of device + * + * e.g. [10.0.0.1] => 10.0.0.1 + * + * @return array Associative of IP ADDRESS (value) to ip address (key) + */ + public function ipAddressList() { + return $this->getSNMP()->subOidWalk(self::OID_IP_ADDRESS, 11, -1 ); + } + + /** + * IP Addresses listen by this device and mac associated to the ip + * also the interface index (if) where listen. Usually interface could + * by virtual interface (VLAN) + * @return array [ 'if.ip' => 'mac' ] + */ + public function ipMacIf() { + return $this->getSNMP()->subOidWalk(self::OID_IP_NET_TO_MEDIA_PHY_ADDRESS, 11, -1 ); + } +} diff --git a/OSS_SNMP/MIBS/LLDP.php b/OSS_SNMP/MIBS/LLDP.php new file mode 100644 index 000000000..277857577 --- /dev/null +++ b/OSS_SNMP/MIBS/LLDP.php @@ -0,0 +1,946 @@ + + * @see http://oidref.com/1.0.8802.1.1.2 + */ +class LLDP extends \OSS_SNMP\MIB +{ + /* + * Local system + */ + + /** + * The type of encoding used to identify the chassis associated with the + * local system. + * + * @see localChassisIdSubtype() + */ + const OID_LLDP_LOC_CHASSIS_ID_SUBTYPE = '1.0.8802.1.1.2.1.3.1.0'; + /** + * The string value used to identify the chassis component associated with + * the local system. + * + * @see localChassisId() + */ + const OID_LLDP_LOC_CHASSIS_ID = '1.0.8802.1.1.2.1.3.2.0'; + + /** + * The string value used to identify the system name of the + * local system. + * + * @see localSystemName() + */ + const OID_LLDP_LOC_SYS_NAME = '1.0.8802.1.1.2.1.3.3.0'; + + /** + * The string value used to identify the system description + * of the local system. + * + * @see localSystemDescription() + */ + const OID_LLDP_LOC_SYS_DESC = '1.0.8802.1.1.2.1.3.4.0'; + + /** + * The bitmap value used to identify which system capabilities + * are supported on the local system. + * + * @see localSystemCapabilitySupported() + */ + const OID_LLDP_LOC_SYS_CAP_SUPPORTED = '1.0.8802.1.1.2.1.3.5.0'; + + /** + * The bitmap value used to identify which system capabilities + * are enabled on the local system. + * + * @see localSystemCapabilityEnabled() + */ + const OID_LLDP_LOC_SYS_CAP_ENABLED = '1.0.8802.1.1.2.1.3.6.0'; + + /** + * The type of port identifier encoding used in the associated + * 'lldpLocPortId' object. + * + * @see localPortIdSubtype() + */ + const OID_LLDP_LOC_PORT_ID_SUBTYPE = '1.0.8802.1.1.2.1.3.7.1.2'; + + /** + * The string value used to identify the port component + * associated with the local system. + * + * @see localPortId() + */ + const OID_LLDP_LOC_PORT_ID = '1.0.8802.1.1.2.1.3.7.1.3'; + + /** + * The string value used to identify the description of + * the given port associated with the local system. + * + * @see localPortDescription() + */ + const OID_LLDP_LOC_PORT_DESC = '1.0.8802.1.1.2.1.3.7.1.4'; + + /* + * Remote system + */ + + /** + * The type of encoding used to identify the chassis associated with the + * remote system. + * + * @see remoteChassisIdSubtype() + */ + const OID_LLDP_REM_CHASSIS_ID_SUBTYPE = '.1.0.8802.1.1.2.1.4.1.1.4'; + /** + * The string value used to identify the chassis component associated with + * the remote system. + * + * @see remoteChassisId() + */ + const OID_LLDP_REM_CHASSIS_ID = '.1.0.8802.1.1.2.1.4.1.1.5'; + + /** + * The type of port identifier encoding used in the associated + * 'lldpRemPortId' object. + * + * @see remotePortIdSubtype() + */ + const OID_LLDP_REM_PORT_ID_SUBTYPE = '.1.0.8802.1.1.2.1.4.1.1.6'; + + /** + * The string value used to identify the port component + * associated with the remote system. + * + * @see remotePortId() + */ + const OID_LLDP_REM_PORT_ID = '.1.0.8802.1.1.2.1.4.1.1.7'; + + /** + * The string value used to identify the description of + * the given port associated with the remote system. + * + * @see remotePortDescription() + */ + const OID_LLDP_REM_PORT_DESC = '.1.0.8802.1.1.2.1.4.1.1.8'; + + /** + * The string value used to identify the system name of the + * remote system. + * + * @see remoteSystemName() + */ + const OID_LLDP_REM_SYS_NAME = '.1.0.8802.1.1.2.1.4.1.1.9'; + + /** + * The string value used to identify the system description + * of the remote system. + * + * @see remoteSystemDescription() + */ + const OID_LLDP_REM_SYS_DESC = '.1.0.8802.1.1.2.1.4.1.1.10'; + + /** + * The bitmap value used to identify which system capabilities + * are supported on the remote system. + * + * @see remoteSystemCapabilitySupported() + */ + const OID_LLDP_REM_SYS_CAP_SUPPORTED = '.1.0.8802.1.1.2.1.4.1.1.11'; + + /** + * The bitmap value used to identify which system capabilities + * are enabled on the remote system. + * + * @see remoteSystemCapabilityEnabled() + */ + const OID_LLDP_REM_SYS_CAP_ENABLED = '.1.0.8802.1.1.2.1.4.1.1.12'; + + // ... + + /** + * EntPhysicalAlias when entPhysClass has a value of ‘chassis(3)’ (IETF RFC 2737). + */ + const CHASSIS_ID_SUBTYPE_CHASSIS_COMPONENT = 1; + /** + * IfAlias (IETF RFC 2863). + */ + const CHASSIS_ID_SUBTYPE_INTERFACE_ALIAS = 2; + /** + * EntPhysicalAlias when entPhysicalClass has a value ‘port(10)’ or ‘backplane(4)’ (IETF RFC 2737). + */ + const CHASSIS_ID_SUBTYPE_PORT_COMPONENT = 3; + /** + * MAC address (IEEE Std 802-2001). + */ + const CHASSIS_ID_SUBTYPE_MAC_ADDRESS = 4; + /** + * Octet string that identifies a particular network address family and an + * associated network address that are encoded in network octet order. + */ + const CHASSIS_ID_SUBTYPE_NETWORK_ADDRESS = 5; + /** + * ifName (IETF RFC 2863). + */ + const CHASSIS_ID_SUBTYPE_INTERFACE_NAME = 6; + /** + * Alpha-numeric string locally assigned. + */ + const CHASSIS_ID_SUBTYPE_LOCALLY_ASSIGNED = 7; + + /** + * Text representations of chassis id subtypes. + * + * @see remoteChassisIdSubtype() + * @see IEEE 802.1AB-2004 9.5.2.2 + * + * @var array Text representations of chassis id subtypes + */ + public static $CHASSIS_ID_SUBTYPES = array( + self::CHASSIS_ID_SUBTYPE_CHASSIS_COMPONENT => 'Chassis component', + self::CHASSIS_ID_SUBTYPE_INTERFACE_ALIAS => 'Interface alias', + self::CHASSIS_ID_SUBTYPE_PORT_COMPONENT => 'Port component', + self::CHASSIS_ID_SUBTYPE_MAC_ADDRESS => 'MAC address', + self::CHASSIS_ID_SUBTYPE_NETWORK_ADDRESS => 'Network address', + self::CHASSIS_ID_SUBTYPE_INTERFACE_NAME => 'Interface name', + self::CHASSIS_ID_SUBTYPE_LOCALLY_ASSIGNED => 'Locally assigned', + ); + + /** + * IfAlias (IETF RFC 2863). + */ + const PORT_ID_SUBTYPE_INTERFACE_ALIAS = 1; + /** + * EntPhysicalAlias when entPhysicalClass has a value ‘port(10)’ or ‘backplane(4)’ (IETF RFC 2737). + */ + const PORT_ID_SUBTYPE_PORT_COMPONENT = 2; + /** + * MAC address (IEEE Std 802-2001). + */ + const PORT_ID_SUBTYPE_MAC_ADDRESS = 3; + /** + * Octet string that identifies a particular network address family and an + * associated network address that are encoded in network octet order. + */ + const PORT_ID_SUBTYPE_NETWORK_ADDRESS = 4; + /** + * ifName (IETF RFC 2863). + */ + const PORT_ID_SUBTYPE_INTERFACE_NAME = 5; + /** + * Agent circuit ID (IETF RFC 3046). + */ + const PORT_ID_SUBTYPE_AGENT_CIRCUIT_ID = 6; + /** + * Alpha-numeric string locally assigned. + */ + const PORT_ID_SUBTYPE_LOCALLY_ASSIGNED = 7; + + /** + * Text representations of port id subtypes. + * + * @see remotePortIdSubtype() + * @see IEEE 802.1AB-2004 9.5.3.2 + * + * @var array Text representations of port id subtypes + */ + public static $PORT_ID_SUBTYPES = array( + self::PORT_ID_SUBTYPE_INTERFACE_ALIAS => 'Interface alias', + self::PORT_ID_SUBTYPE_PORT_COMPONENT => 'Port component', + self::PORT_ID_SUBTYPE_MAC_ADDRESS => 'MAC address', + self::PORT_ID_SUBTYPE_NETWORK_ADDRESS => 'Network address', + self::PORT_ID_SUBTYPE_INTERFACE_NAME => 'Interface name', + self::PORT_ID_SUBTYPE_AGENT_CIRCUIT_ID => 'Agent circuid ID', + self::PORT_ID_SUBTYPE_LOCALLY_ASSIGNED => 'Locally assigned', + ); + + /** + * Repeater. + * + * @see IETF RFC 2108 + */ + const SYSTEM_CAPABILITIES_REPEATER = 0b1; + /** + * Bridge. + * + * @see IETF RFC 2674 + */ + const SYSTEM_CAPABILITIES_BRIDGE = 0b10; + /** + * WLAN Access Point. + * + * @see IEEE 802.11 MIB + */ + const SYSTEM_CAPABILITIES_WLAN_AP = 0b100; + /** + * Router. + * + * @see IETF RFC 1812 + */ + const SYSTEM_CAPABILITIES_ROUTER = 0b1000; + /** + * Telephone. + * + * @see IETF RFC 2011 + */ + const SYSTEM_CAPABILITIES_TELEPHONE = 0b10000; + /** + * DOCSIS cable device. + * + * @see IETF RFC 2669 and IETF RFC 2670 + */ + const SYSTEM_CAPABILITIES_DOCSIS = 0b100000; + /** + * Station only capability is intended for devices that implement + * only an end station capabilit. + */ + const SYSTEM_CAPABILITIES_STATION_ONLY = 0b1000000; + + /** + * Text representation of system capabilities. + * + * @see IEEE 802.1AB-2004 9.5.8.1 + * + * @var array Text representation of system capabilities + */ + public static $SYSTEM_CAPABILITIES = array( + self::SYSTEM_CAPABILITIES_REPEATER => 'Repeater', + self::SYSTEM_CAPABILITIES_BRIDGE => 'Bridge', + self::SYSTEM_CAPABILITIES_WLAN_AP => 'WLAN Access Point', + self::SYSTEM_CAPABILITIES_ROUTER => 'Router', + self::SYSTEM_CAPABILITIES_TELEPHONE => 'Telephone', + self::SYSTEM_CAPABILITIES_DOCSIS => 'DOCSIS cable device', + self::SYSTEM_CAPABILITIES_STATION_ONLY => 'Station Only', + ); + + /* + * Local system + */ + + /** + * Get The type of encoding used to identify the chassis + * associated with the local system. + * + * @see CHASSIS_ID_SUBTYPES + * + * @param bool $translate If true, return the string representation + * + * @return int|string The chassis id subtype or its string representation + */ + public function localChassisIdSubtype($translate = false) + { + $subtypes = $this->getSNMP()->get(self::OID_LLDP_LOC_CHASSIS_ID_SUBTYPE); + + if (!$translate) { + return $subtypes; + } + + return $this->getSNMP()->translate($subtypes, self::$CHASSIS_ID_SUBTYPES); + } + + /** + * Get the string value used to identify the chassis component + * associated with the remote system. + * + * @return string the chassis component identity + */ + public function localChassisId() + { + return $this->getSNMP()->get(self::OID_LLDP_LOC_CHASSIS_ID); + } + + /** + * Get the string value used to identify the system name of the + * local system. + * + * @return string The system name + */ + public function localSystemName() + { + return $this->getSNMP()->get(self::OID_LLDP_LOC_SYS_NAME); + } + + /** + * Get the string value used to identify the system description + * of the local system. + * + * @return string The system description + */ + public function localSystemDescription() + { + return $this->getSNMP()->get(self::OID_LLDP_LOC_SYS_DESC); + } + + /** + * Get the bitmap value used to identify which system capabilities + * are supported on the local system. + * + * @return int the system capabilities are supported on the local system + */ + public function localSystemCapabilitySupported() + { + $capability = $this->getSNMP()->get(self::OID_LLDP_LOC_SYS_CAP_SUPPORTED); + + return ord($capability); + } + + /** + * Query if the local system supports the given capability. + * + * Example: + * + * if( $host->useLLVM()->localSystemHasCapabilitySupported(\OSS_SNMP\SNMP\MIBS\LLDP::SYSTEM_CAPABILITIES_ROUTER ) + * echo "Host is a router!!"; + * + * + * @param int $capability The capability to query for (defined by self::SYSTEM_CAPABILITIES_* constants) + * + * @return bool True if the local system supports the given capability + */ + public function localSystemHasCapabilitySupported($capability) + { + if ($this->localSystemCapabilitySupported() & $capability) { + return true; + } + + return false; + } + + /** + * Get an array of individual supported capabilities of the local system. + * + * Example: + * + * print_r( $host->useLLVM()->localSystemCapabilitiesSupported( ) ) + * + * [0] => 8 // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => 32 // self::SYSTEM_CAPABILITIES_DOCSIS + * + * print_r( $host->useLLVM()->localSystemCapabilitiesSupported( true ) ) + * + * [0] => "Router" // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => "DOCSIS cable device" // self::SYSTEM_CAPABILITIES_DOCSIS + * + * @param bool $translate Set to true to return descriptions rather than integers + * + * @return array Individual capabilities of the local system + */ + public function localSystemCapabilitiesSupported($translate = false) + { + $capabilities = array(); + $localCapabilities = $this->localSystemCapabilitySupported(); + + foreach (self::$SYSTEM_CAPABILITIES as $mask => $description) { + if ($localCapabilities & $mask) { + $capabilities[] = $mask; + } + } + + if ($translate) { + return $this->getSNMP()->translate($capabilities, self::$SYSTEM_CAPABILITIES); + } + + return $capabilities; + } + + /** + * Get the bitmap value used to identify which system capabilities + * are enabled on the local system. + * + * @return int the system capabilities are enabled on the local system + */ + public function localSystemCapabilityEnabled() + { + $capability = $this->getSNMP()->get(self::OID_LLDP_LOC_SYS_CAP_ENABLED); + + return ord($capability); + } + + /** + * Query if the local system has the given capability enabled. + * + * Example: + * + * if( $host->useLLVM()->localSystemHasCapabilitySupported( \OSS_SNMP\SNMP\MIBS\LLDP::SYSTEM_CAPABILITIES_ROUTER ) + * echo "Host is a router!!"; + * + * + * @param int $capability The capability to query for (defined by self::SYSTEM_CAPABILITIES_* constants) + * + * @return bool True if the local system has the given capability enabled + */ + public function localSystemHasCapabilityEnabled($capability) + { + if ($this->localSystemCapabilityEnabled() & $capability) { + return true; + } + + return false; + } + + /** + * Get an array of individual enabled capabilities of the local system. + * + * Example: + * + * print_r( $host->useLLVM()->localSystemCapabilitiesEnabled( ) ) + * + * [0] => 8 // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => 32 // self::SYSTEM_CAPABILITIES_DOCSIS + * + * print_r( $host->useLLVM()->localSystemCapabilitiesSupported( true ) ) + * + * [0] => "Router" // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => "DOCSIS cable device" // self::SYSTEM_CAPABILITIES_DOCSIS + * + * @param int $portId The local system connect by the local port ID + * @param bool $translate Set to true to return descriptions rather than integers + * + * @return array Individual capabilities of a given local system + */ + public function localSystemCapabilitiesEnabled($translate = false) + { + $capabilities = array(); + $localCapabilities = $this->localSystemCapabilityEnabled(); + + foreach (self::$SYSTEM_CAPABILITIES as $mask => $description) { + if ($localCapabilities & $mask) { + $capabilities[] = $mask; + } + } + + if ($translate) { + return $this->getSNMP()->translate($capabilities, self::$SYSTEM_CAPABILITIES); + } + + return $capabilities; + } + + /** + * Get an array with the type of port identifier encoding used in the associated + * 'lldpLocPortId' object. + * + * E.g.: + * + * + * .1.0.8802.1.1.2.1.3.7.1.2.503 => INTEGER: 7 + * .1.0.8802.1.1.2.1.3.7.1.2.505 => INTEGER: 7 + * ... + * + * [503] => 7 + * [505] => 7 + * + * @see PORT_ID_SUBTYPES + * + * @param bool $translate If true, return the string representation + * + * @return array An array of port id subtypes + */ + public function localPortIdSubtype($translate = false) + { + $subtypes = $this->getSNMP()->walk1d(self::OID_LLDP_LOC_PORT_ID_SUBTYPE); + + if (!$translate) { + return $subtypes; + } + + return $this->getSNMP()->translate($subtypes, self::$PORT_ID_SUBTYPES); + } + + /** + * Get an array with the string value used to identify the port component + * associated with a given port in the local system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.3.7.1.2.503 => STRING: "503" + * .1.0.8802.1.1.2.1.3.7.1.2.505 => STRING: "505" + * ... + * + * [503] => 503 + * [505] => 505 + * + * @return array the port component identities + */ + public function localPortId() + { + return $this->getSNMP()->walk1d(self::OID_LLDP_LOC_PORT_ID); + } + + /** + * Get an array with the string value used to identify the 802 LAN station's port + * description associated with the local system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.3.7.1.4.503 => STRING: "switch01" + * .1.0.8802.1.1.2.1.3.7.1.4.505 => STRING: "switch02" + * ... + * + * [503] => switch01 + * [505] => switch02 + * + * @return array The port descriptions + */ + public function localPortDescription() + { + return $this->getSNMP()->walk1d(self::OID_LLDP_LOC_PORT_DESC); + } + + /* + * Remote system + */ + + /** + * Get an array with type of encoding used to identify the chassis + * associated with the remote system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.4.1.1.4.5108638.200.102 = INTEGER: 4 + * .1.0.8802.1.1.2.1.4.1.1.4.5761237.201.104 = INTEGER: 4 + * ... + * + * [200] => 4 + * [201] => 4 + * + * @see CHASSIS_ID_SUBTYPES + * + * @param bool $translate If true, return the string representation + * + * @return array An array of chassis id subtypes + */ + public function remoteChassisIdSubtype($translate = false) + { + $subtypes = $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_CHASSIS_ID_SUBTYPE, 13); + + if (!$translate) { + return $subtypes; + } + + return $this->getSNMP()->translate($subtypes, self::$CHASSIS_ID_SUBTYPES); + } + + /** + * Get an array with the string value used to identify the chassis component + * associated with the remote system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.4.1.1.5.7369071.718.125 => Hex-STRING: 08 1F F3 E9 D8 00 + * .1.0.8802.1.1.2.1.4.1.1.5.7706202.653.126 => Hex-STRING: 08 B2 58 A1 EA 80 + * ... + * [718] => 081FF3E9D800 + * [653] => 08B258A1EA80 + * + * @return array the chassis component identities + */ + public function remoteChassisId() + { + return $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_CHASSIS_ID, 13); + } + + /** + * Get an array with the type of port identifier encoding used in the associated + * 'lldpRemPortId' object. + * + * E.g.: + * + * + * .1.0.8802.1.1.2.1.4.1.1.6.15590464.515.3 => INTEGER: 5 + * .1.0.8802.1.1.2.1.4.1.1.6.15591663.556.4 => INTEGER: 5 + * ... + * + * [515] => 5 + * [556] => 5 + * + * @see PORT_ID_SUBTYPES + * + * @param bool $translate If true, return the string representation + * + * @return array An array of port id subtypes + */ + public function remotePortIdSubtype($translate = false) + { + $subtypes = $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_PORT_ID_SUBTYPE, 13); + + if (!$translate) { + return $subtypes; + } + + return $this->getSNMP()->translate($subtypes, self::$PORT_ID_SUBTYPES); + } + + /** + * Get an array with the string value used to identify the port component + * associated with a given port in the remote system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.4.1.1.7.15590464.515.3 => STRING: "Gi1/0/24" + * .1.0.8802.1.1.2.1.4.1.1.7.15591663.556.4 => STRING: "Gi0/1" + * ... + * + * [515] => Gi1/0/24 + * [556] => Gi0/1 + * + * @return array the port component identities + */ + public function remotePortId() + { + return $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_PORT_ID, 13); + } + + /** + * Get an array with the string value used to identify the 802 LAN station's + * port description associated with the remote system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.4.1.1.8.15590464.515.3 => STRING: "GigabitEthernet1/0/24" + * .1.0.8802.1.1.2.1.4.1.1.8.15591663.556.4 => STRING: "GigabitEthernet0/1" + * ... + * + * [515] => GigabitEthernet1/0/24 + * [556] => GigabitEthernet0/1 + * + * @return array The port descriptions + */ + public function remotePortDescription() + { + return $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_PORT_DESC, 13); + } + + /** + * Get an array with the string value used to identify the system name of the + * remote system. + * + * E.g.: + * + * .1.0.8802.1.1.2.1.4.1.1.9.15590464.515.3 => STRING: "switch01" + * .1.0.8802.1.1.2.1.4.1.1.9.15591663.556.4 => STRING: "switch02" + * ... + * + * [515] => switch01 + * [556] => switch02 + * + * @return array The system names + */ + public function remoteSystemName() + { + return $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_SYS_NAME, 13); + } + + /** + * Get an array with the string value used to identify the system description + * of the remote system. + * + * E.g. + * + * .1.0.8802.1.1.2.1.4.1.1.10.15590464.515.3 => STRING: "Cisco IOS Software, ..." + * .1.0.8802.1.1.2.1.4.1.1.10.15591663.556.4 => STRING: "Cisco IOS Software, ..." + * ... + * + * [515] => "Cisco IOS Software, ..." + * [556] => "Cisco IOS Software, ..." + * + * @return array The system descriptions + */ + public function remoteSystemDescription() + { + return $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_SYS_DESC, 13); + } + + /** + * Get an array with the bitmap value used to identify which system capabilities + * are supported on the remote system. + * + * @return array the system capabilities are supported on the remote system + */ + public function remoteSystemCapabilitySupported() + { + $capabilities = $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_SYS_CAP_SUPPORTED, 13); + + foreach ($capabilities as $index => $capability) { + $capabilities[$index] = ord($capability); + } + + return $capabilities; + } + + /** + * Query if a given remote system (by connected port ID) supports the given capability. + * + * Example: + * + * if( $host->useLLVM()->remoteSystemHasCapabilitySupported( $portId, \OSS_SNMP\SNMP\MIBS\LLDP::SYSTEM_CAPABILITIES_ROUTER ) + * echo "Host is a router!!"; + * + * + * @param int $portId The remote system connect by the local port ID + * @param int $capability The capability to query for (defined by self::SYSTEM_CAPABILITIES_* constants) + * + * @return bool True if the remote system supports the given capability + */ + public function remoteSystemHasCapabilitySupported($portId, $capability) + { + if ($this->remoteSystemCapabilitySupported()[$portId] & $capability) { + return true; + } + + return false; + } + + /** + * Get an array of individual supported capabilities of a given remote system (by connected port ID). + * + * Example: + * + * print_r( $host->useLLVM()->remoteSystemCapabilitiesSupported( 10111 ) ) + * + * [0] => 8 // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => 32 // self::SYSTEM_CAPABILITIES_DOCSIS + * + * print_r( $host->useLLVM()->remoteSystemCapabilitiesSupported( 10111, true ) ) + * + * [0] => "Router" // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => "DOCSIS cable device" // self::SYSTEM_CAPABILITIES_DOCSIS + * + * @param int $portId The remote system connect by the local port ID + * @param bool $translate Set to true to return descriptions rather than integers + * + * @return array Individual capabilities of a given remote system + */ + public function remoteSystemCapabilitiesSupported($portId, $translate = false) + { + $capabilities = array(); + $remoteCapabilities = $this->remoteSystemCapabilitySupported()[$portId]; + + foreach (self::$SYSTEM_CAPABILITIES as $mask => $description) { + if ($remoteCapabilities & $mask) { + $capabilities[] = $mask; + } + } + + if ($translate) { + return $this->getSNMP()->translate($capabilities, self::$SYSTEM_CAPABILITIES); + } + + return $capabilities; + } + + /** + * Get an array with the bitmap value used to identify which system capabilities + * are enabled on the remote system. + * + * @return array the system capabilities are enabled on the remote system + */ + public function remoteSystemCapabilityEnabled() + { + $capabilities = $this->getSNMP()->subOidWalk(self::OID_LLDP_REM_SYS_CAP_ENABLED, 13); + + foreach ($capabilities as $index => $capability) { + $capabilities[$index] = ord($capability); + } + + return $capabilities; + } + + /** + * Query if a given remote system (by connected port ID) has the given capability enabled. + * + * Example: + * + * if( $host->useLLVM()->remoteSystemHasCapabilitySupported( $portId, \OSS_SNMP\SNMP\MIBS\LLDP::SYSTEM_CAPABILITIES_ROUTER ) + * echo "Host is a router!!"; + * + * + * @param int $portId The remote system connect by the local port ID + * @param int $capability The capability to query for (defined by self::SYSTEM_CAPABILITIES_* constants) + * + * @return bool True if the remote system has the given capability enabled + */ + public function remoteSystemHasCapabilityEnabled($portId, $capability) + { + if ($this->remoteSystemCapabilityEnabled()[$portId] & $capability) { + return true; + } + + return false; + } + + /** + * Get an array of individual enabled capabilities of a given remote system (by connected port ID). + * + * Example: + * + * print_r( $host->useLLVM()->remoteSystemCapabilitiesEnabled( 10111 ) ) + * + * [0] => 8 // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => 32 // self::SYSTEM_CAPABILITIES_DOCSIS + * + * print_r( $host->useLLVM()->remoteSystemCapabilitiesSupported( 10111, true ) ) + * + * [0] => "Router" // self::SYSTEM_CAPABILITIES_ROUTER + * [1] => "DOCSIS cable device" // self::SYSTEM_CAPABILITIES_DOCSIS + * + * @param int $portId The remote system connect by the local port ID + * @param bool $translate Set to true to return descriptions rather than integers + * + * @return array Individual capabilities of a given remote system + */ + public function remoteSystemCapabilitiesEnabled($portId, $translate = false) + { + $capabilities = array(); + $remoteCapabilities = $this->remoteSystemCapabilityEnabled()[$portId]; + + foreach (self::$SYSTEM_CAPABILITIES as $mask => $description) { + if ($remoteCapabilities & $mask) { + $capabilities[] = $mask; + } + } + + if ($translate) { + return $this->getSNMP()->translate($capabilities, self::$SYSTEM_CAPABILITIES); + } + + return $capabilities; + } +} diff --git a/OSS_SNMP/MIBS/MAU.php b/OSS_SNMP/MIBS/MAU.php index 8423ccb0a..f1aa14d2f 100644 --- a/OSS_SNMP/MIBS/MAU.php +++ b/OSS_SNMP/MIBS/MAU.php @@ -541,6 +541,365 @@ public function index() const TYPE_100GBASEER4 = '.1.3.6.1.2.1.26.4.78'; + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///// START: Extreme specific OIDs: http://www.circitor.fr/Mibs/Html/E/EXTREME-BASE-MIB.php#extremeMauType + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASESX = '.1.3.6.1.4.1.1916.3.1.1.1'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELX = '.1.3.6.1.4.1.1916.3.1.1.2'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASECX = '.1.3.6.1.4.1.1916.3.1.1.3'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASESXFD = '.1.3.6.1.4.1.1916.3.1.1.4'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELXFD = '.1.3.6.1.4.1.1916.3.1.1.5'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASECXFD = '.1.3.6.1.4.1.1916.3.1.1.6'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASEWDMHD = '.1.3.6.1.4.1.1916.3.1.1.7'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASEWDMFD = '.1.3.6.1.4.1.1916.3.1.1.8'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELX70HD = '.1.3.6.1.4.1.1916.3.1.1.9'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELX70FD = '.1.3.6.1.4.1.1916.3.1.1.10'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASEZXHD = '.1.3.6.1.4.1.1916.3.1.1.11'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASEZXFD = '.1.3.6.1.4.1.1916.3.1.1.12'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELX100HD = '.1.3.6.1.4.1.1916.3.1.1.13'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_1000BASELX100FD = '.1.3.6.1.4.1.1916.3.1.1.14'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_10GBASECX4 = '.1.3.6.1.4.1.1916.3.1.1.15'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_10GBASEZR = '.1.3.6.1.4.1.1916.3.1.1.16'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_10GBASEDWDM = '.1.3.6.1.4.1.1916.3.1.1.17'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_10GBASECX = '.1.3.6.1.4.1.1916.3.1.1.18'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_10GBASET = '.1.3.6.1.4.1.1916.3.1.1.19'; + + /** + * Constant for MAU type (Extreme specific): + * @see types() + */ + const TYPE_EXTREME_40GBASEX = '.1.3.6.1.4.1.1916.3.1.1.20'; + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///// END: Extreme specific OIDs: http://www.circitor.fr/Mibs/Html/E/EXTREME-BASE-MIB.php#extremeMauType + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///// START: Arista specific OIDs: https://www.arista.com/assets/data/docs/MIBS/ARISTA-MAU-MIB.txt + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASECR = '.1.3.6.1.4.1.30065.3.4.1.1'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASEDWDMER = '.1.3.6.1.4.1.30065.3.4.1.2'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASESR4 = '.1.3.6.1.4.1.30065.3.4.1.3'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASELR4 = '.1.3.6.1.4.1.30065.3.4.1.4'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASECR4 = '.1.3.6.1.4.1.30065.3.4.1.5'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASEDWDMZR = '.1.3.6.1.4.1.30065.3.4.1.6'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASECRA = '.1.3.6.1.4.1.30065.3.4.1.7'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASEZR = '.1.3.6.1.4.1.30065.3.4.1.8'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASELRL = '.1.3.6.1.4.1.30065.3.4.1.9'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASESR10 = '.1.3.6.1.4.1.30065.3.4.1.10'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASELR4 = '.1.3.6.1.4.1.30065.3.4.1.11'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASEER4 = '.1.3.6.1.4.1.30065.3.4.1.12'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEXSR4 = '.1.3.6.1.4.1.30065.3.4.1.13'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEAR4 = '.1.3.6.1.4.1.30065.3.4.1.14'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEPLR4 = '.1.3.6.1.4.1.30065.3.4.1.15'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEPLRL4 = '.1.3.6.1.4.1.30065.3.4.1.16'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEPSM4 = '.1.3.6.1.4.1.30065.3.4.1.17'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASELRL4 = '.1.3.6.1.4.1.30065.3.4.1.18'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASESR4 = '.1.3.6.1.4.1.30065.3.4.1.19'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEUNIV = '.1.3.6.1.4.1.30065.3.4.1.20'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASEER4 = '.1.3.6.1.4.1.30065.3.4.1.21'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASEXSR10 = '.1.3.6.1.4.1.30065.3.4.1.22'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASEAR = '.1.3.6.1.4.1.30065.3.4.1.23'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASEAR4 = '.1.3.6.1.4.1.30065.3.4.1.24'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASECR4 = '.1.3.6.1.4.1.30065.3.4.1.25'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASELRL4 = '.1.3.6.1.4.1.30065.3.4.1.26'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GDWDMCOHERENT = '.1.3.6.1.4.1.30065.3.4.1.27'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_10GBASEDWDMZT = '.1.3.6.1.4.1.30065.3.4.1.28'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASESRBD = '.1.3.6.1.4.1.30065.3.4.1.29'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_40GBASESR4D = '.1.3.6.1.4.1.30065.3.4.1.30'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASEPSM4 = '.1.3.6.1.4.1.30065.3.4.1.31'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASECLR4 = '.1.3.6.1.4.1.30065.3.4.1.32'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GDWDMCOHERENTE = '.1.3.6.1.4.1.30065.3.4.1.33'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GBASECWDM4 = '.1.3.6.1.4.1.30065.3.4.1.35'; + + /** + * Constant for MAU type (Arista specific): + * @see types() + */ + const TYPE_ARISTA_100GEDWDM2 = '.1.3.6.1.4.1.30065.3.4.1.36'; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///// END: Arista specific OIDs: https://www.arista.com/assets/data/docs/MIBS/ARISTA-MAU-MIB.txt + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + + /** * Text representation of MAU types * @@ -625,7 +984,65 @@ public function index() self::TYPE_100GBASECR10 => '100GbaseCR10', self::TYPE_100GBASESR10 => '100GbaseSR10', self::TYPE_100GBASELR4 => '100GbaseLR4', - self::TYPE_100GBASEER4 => '100GbaseER4' + self::TYPE_100GBASEER4 => '100GbaseER4', + + self::TYPE_EXTREME_1000BASESX => '1000BaseSX', + self::TYPE_EXTREME_1000BASELX => '1000BaseLX', + self::TYPE_EXTREME_1000BASECX => '1000BaseCX', + self::TYPE_EXTREME_1000BASESXFD => '1000BaseSXFD', + self::TYPE_EXTREME_1000BASELXFD => '1000BaseLXFD', + self::TYPE_EXTREME_1000BASECXFD => '1000BaseCXFD', + self::TYPE_EXTREME_1000BASEWDMHD => '1000BaseWDMHD', + self::TYPE_EXTREME_1000BASEWDMFD => '1000BaseWDMFD', + self::TYPE_EXTREME_1000BASELX70HD => '1000BaseLX70HD', + self::TYPE_EXTREME_1000BASELX70FD => '1000BaseLX70FD', + self::TYPE_EXTREME_1000BASEZXHD => '1000BaseZXHD', + self::TYPE_EXTREME_1000BASEZXFD => '1000BaseZXFD', + self::TYPE_EXTREME_1000BASELX100HD => '1000BaseLX100HD', + self::TYPE_EXTREME_1000BASELX100FD => '1000BaseLX100FD', + self::TYPE_EXTREME_10GBASECX4 => '10GBaseCX4', + self::TYPE_EXTREME_10GBASEZR => '10GBaseZR', + self::TYPE_EXTREME_10GBASEDWDM => '10GBaseDWDM', + self::TYPE_EXTREME_10GBASECX => '10GBaseCX', + self::TYPE_EXTREME_10GBASET => '10GBaseT', + self::TYPE_EXTREME_40GBASEX => '40GBaseX', + + self::TYPE_ARISTA_10GBASECR => '10GbaseCR', + self::TYPE_ARISTA_10GBASEDWDMER => '10GbaseDwdmER', + self::TYPE_ARISTA_40GBASESR4 => '40GbaseSR4', + self::TYPE_ARISTA_40GBASELR4 => '40GbaseLR4', + self::TYPE_ARISTA_40GBASECR4 => '40GbaseCR4', + self::TYPE_ARISTA_10GBASEDWDMZR => '10GbaseDwdmZR', + self::TYPE_ARISTA_10GBASECRA => '10GbaseCRA', + self::TYPE_ARISTA_10GBASEZR => '10GbaseZR', + self::TYPE_ARISTA_10GBASELRL => '10GbaseLRL', + self::TYPE_ARISTA_100GBASESR10 => '100GbaseSR10', + self::TYPE_ARISTA_100GBASELR4 => '100GbaseLR4', + self::TYPE_ARISTA_100GBASEER4 => '100GbaseER4', + self::TYPE_ARISTA_40GBASEXSR4 => '40GbaseXSR4', + self::TYPE_ARISTA_40GBASEAR4 => '40GbaseAR4', + self::TYPE_ARISTA_40GBASEPLR4 => '40GbasePLR4', + self::TYPE_ARISTA_40GBASEPLRL4 => '40GbasePLRL4', + self::TYPE_ARISTA_40GBASEPSM4 => '40GbasePSM4', + self::TYPE_ARISTA_40GBASELRL4 => '40GbaseLRL4', + self::TYPE_ARISTA_100GBASESR4 => '100GbaseSR4', + self::TYPE_ARISTA_40GBASEUNIV => '40GbaseUniv', + self::TYPE_ARISTA_40GBASEER4 => '40GbaseER4', + self::TYPE_ARISTA_100GBASEXSR10 => '100GbaseXSR10', + self::TYPE_ARISTA_10GBASEAR => '10GbaseAR', + self::TYPE_ARISTA_100GBASEAR4 => '100GbaseAR4', + self::TYPE_ARISTA_100GBASECR4 => '100GbaseCR4', + self::TYPE_ARISTA_100GBASELRL4 => '100GbaseLRL4', + self::TYPE_ARISTA_100GDWDMCOHERENT => '100GDwdmCoherent', + self::TYPE_ARISTA_10GBASEDWDMZT => '10GbaseDwdmZT', + self::TYPE_ARISTA_40GBASESRBD => '40GbaseSRBD', + self::TYPE_ARISTA_40GBASESR4D => '40GbaseSR4D', + self::TYPE_ARISTA_100GBASEPSM4 => '100GbasePSM4', + self::TYPE_ARISTA_100GBASECLR4 => '100GbaseCLR4', + self::TYPE_ARISTA_100GDWDMCOHERENTE => '100GDwdmCoherentE', + self::TYPE_ARISTA_100GBASECWDM4 => '100GbaseCWDM4', + self::TYPE_ARISTA_100GEDWDM2 => '100GEDwdm2', + ); diff --git a/OSS_SNMP/MIBS/RFC1213.php b/OSS_SNMP/MIBS/RFC1213.php new file mode 100644 index 000000000..c114e14b3 --- /dev/null +++ b/OSS_SNMP/MIBS/RFC1213.php @@ -0,0 +1,77 @@ + + */ +class RFC1213 extends \OSS_SNMP\MIB +{ + const OID_RFC1213_PHYSADDRESS = '.1.3.6.1.2.1.3.1.1.2'; + + /** + * + * NOTE- must use "community@vlan" as community + * + * @param $ifindex + * @return associative array for macaddress in this device + * [ + * "ifindex.instance.ip" => macaddress + * ] + * (instance usually "1", ifindex the vlan_ifindex if vlan ) + * ex. + * [ + * "53.1.10.0.1.5" => "0008E4F1F322", + * ] + * if $ifindex only search for this ifindex, if $ifindex and $ip search for both + */ + public function physAddress($ifindex = null, $ip = null) { + + $oid = self::OID_RFC1213_PHYSADDRESS; + + if ($ifindex) { + $oid .= "." . $ifindex; + if ($ip) { + $oid .= ".1." . $ip; + } + } + return $this->getSNMP()->subOidWalk($oid, 11, -1); + } + +} diff --git a/OSS_SNMP/MIBS/Routes.php b/OSS_SNMP/MIBS/Routes.php new file mode 100644 index 000000000..939276ddd --- /dev/null +++ b/OSS_SNMP/MIBS/Routes.php @@ -0,0 +1,553 @@ + BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +namespace OSS_SNMP\MIBS; + +/** + * A class for obtaining route information using ipCidrRouteTable information. + * + * @see http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&translate=Translate&objectInput=1.3.6.1.2.1.4.24.4.1#oidContent + * @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland + * @author Dave Hope + */ +class Routes extends \OSS_SNMP\MIB +{ + const OID_ROUTE_ENTRY_DEST = '1.3.6.1.2.1.4.24.4.1.1'; // ipCidrRouteDest + const OID_ROUTE_ENTRY_MASK = '1.3.6.1.2.1.4.24.4.1.2'; // ipCidrRouteMask + const OID_ROUTE_ENTRY_TOS = '1.3.6.1.2.1.4.24.4.1.3'; // ipCidrRouteTos + const OID_ROUTE_ENTRY_NEXTHOP = '1.3.6.1.2.1.4.24.4.1.4'; // ipCidrRouteNextHop + const OID_ROUTE_ENTRY_IFINDEX = '1.3.6.1.2.1.4.24.4.1.5'; // ipCidrRouteIfIndex + const OID_ROUTE_ENTRY_TYPE = '1.3.6.1.2.1.4.24.4.1.6'; // ipCidrRouteType + const OID_ROUTE_ENTRY_PROTO = '1.3.6.1.2.1.4.24.4.1.7'; // ipCidrRouteProto + const OID_ROUTE_ENTRY_AGE = '1.3.6.1.2.1.4.24.4.1.8'; // ipCidrRouteAge + const OID_ROUTE_ENTRY_INFO = '1.3.6.1.2.1.4.24.4.1.9'; // ipCidrRouteInfo + const OID_ROUTE_ENTRY_NEXTHOPAS = '1.3.6.1.2.1.4.24.4.1.10'; // ipCidrRouteNextHopAS + const OID_ROUTE_ENTRY_METRIC1 = '1.3.6.1.2.1.4.24.4.1.11'; // ipCidrRouteMetric1 + const OID_ROUTE_ENTRY_METRIC2 = '1.3.6.1.2.1.4.24.4.1.12'; // ipCidrRouteMetric2 + const OID_ROUTE_ENTRY_METRIC3 = '1.3.6.1.2.1.4.24.4.1.13'; // ipCidrRouteMetric3 + const OID_ROUTE_ENTRY_METRIC4 = '1.3.6.1.2.1.4.24.4.1.14'; // ipCidrRouteMetric4 + const OID_ROUTE_ENTRY_METRIC5 = '1.3.6.1.2.1.4.24.4.1.15'; // ipCidrRouteMetric5 + const OID_ROUTE_ENTRY_STATUS = '1.3.6.1.2.1.4.24.4.1.16'; // ipCidrRouteStatus + + + /** + * Returns the destination network + * + * > "The destination IP address of this route." + * + * @return array Returns the destination network for all routes indexed by SNMP route ID. + */ + public function routeDest() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_DEST , 12 , 24 ); + } + + + /** + * Returns the destination netmask + * + * > "Indicate the mask to be logical-ANDed with the destination address + * > before being compared to the value in the ipCidrRouteDest field. For + * > those systems that do not support arbitrary subnet masks, an agent + * > constructs the value of the ipCidrRouteMask by reference to the IP + * > Ad-dress Class." + * + * @return array Returns the netmask for all routes indexed by SNMP route ID. + */ + public function routeMask() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_MASK , 12 , 24 ); + } + + + /** + * Returns the route type of service + * + * > "The policy specifier is the IP TOS Field. The encoding of IP TOS + * > is as specified by the following convention. Zero indicates the + * > default path if no more specific policy applies." + * + * @return array Returns the TOS for all routes indexed by SNMP route ID. + */ + public function routeTos() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_TOS , 12 , 24 ); + } + + /** + * Returns the next hop + * + * > "On remote routes, the address of the next sys- tem en route; + * > Otherwise, 0.0.0.0." + * + * @return array Returns the next hop for all routes indexed by SNMP route ID. + */ + public function routeNextHop() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_NEXTHOP , 12 , 24 ); + } + + + /** + * Returns the interface index for the next hop. + * + * > "The ifIndex value which identifies the local interface through which + * > the next hop of this route should be reached." + * + * @return array Returns the ifindex for all routes indexed by SNMP route ID. + */ + public function routeIfIndex() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_IFINDEX , 12 , 24 ); + } + + + /** + * Possible value for route type + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_TYPE_OTHER = 1; + + /** + * Possible value for route type + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_TYPE_REJECT = 2; + + /** + * Possible value for route type + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_TYPE_LOCAL = 3; + + /** + * Possible value for route type + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_TYPE_REMOTE = 4; + + /** + * Look up for text representation of route type + * @var array Look up for text representation of route types + */ + public static $ROUTE_ENTRY_TYPES = [ + self::ROUTE_ENTRY_TYPE_OTHER => 'other', + self::ROUTE_ENTRY_TYPE_REJECT => 'reject', + self::ROUTE_ENTRY_TYPE_LOCAL => 'local', + self::ROUTE_ENTRY_TYPE_REMOTE => 'remote' + ]; + + + /** + * Returns the route type for all connections (see `self::$ROUTE_ENTRY_TYPES`) + * + * > "The type of route. Note that local(3) refers to a route for which the + * > next hop is the final destination; remote(4) refers to a route for + * > which the next hop is not the final destina-tion. + * + * > Routes which do not result in traffic forwarding or rejection should not + * > be displayed even if the implementation keeps them stored internally. + * > reject (2) refers to a route which, if matched, discards the message as + * > unreachable. This is used in someprotocols as a means of correctly + * > aggregating routes." + * + * @param bool $translate If true, use `self::$ROUTE_ENTRY_TYPES` array to return textual representation + * @return array The Route types. + */ + public function routeType( $translate = false ) + { + $s = $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_TYPE , 12 , 24 ); + + if( !$translate ) + return $s; + + return $this->getSNMP()->translate( $s, self::$ROUTE_ENTRY_TYPES ); + } + + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_OTHER = 1; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_LOCAL = 2; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_NETMGMT = 3; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_ICMP = 4; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_EGP = 5; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_GGP = 6; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_HELLO = 7; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_RIP = 8; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_ISIS = 9; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_ESLS = 10; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_CISCOLGRP = 11; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_BBNSPFLGP = 12; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_OSPF = 13; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_BGP = 14; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_IDPR = 15; + + /** + * Possible value for route protocol + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_PROTO_CISCOEIGRP = 16; + + /** + * Look up for text representation of route protcols + * @var array Look up for text representation of route protcol + */ + public static $ROUTE_ENTRY_PROTOS = [ + self::ROUTE_ENTRY_PROTO_OTHER => 'other', + self::ROUTE_ENTRY_PROTO_LOCAL => 'local', + self::ROUTE_ENTRY_PROTO_NETMGMT => 'netmgmt', + self::ROUTE_ENTRY_PROTO_ICMP => 'icmp', + self::ROUTE_ENTRY_PROTO_EGP => 'egp', + self::ROUTE_ENTRY_PROTO_GGP => 'ggp', + self::ROUTE_ENTRY_PROTO_HELLO => 'hello', + self::ROUTE_ENTRY_PROTO_RIP => 'RIP', + self::ROUTE_ENTRY_PROTO_ISIS => 'isis', + self::ROUTE_ENTRY_PROTO_ESLS => 'esls', + self::ROUTE_ENTRY_PROTO_CISCOLGRP => 'Ciscplgrp', + self::ROUTE_ENTRY_PROTO_BBNSPFLGP => 'bbnSpflgp', + self::ROUTE_ENTRY_PROTO_OSPF => 'ospf', + self::ROUTE_ENTRY_PROTO_BGP => 'bgp', + self::ROUTE_ENTRY_PROTO_IDPR => 'idpr', + self::ROUTE_ENTRY_PROTO_CISCOEIGRP => 'CiscoEigrp' + ]; + + + /** + * Returns the route protocol. + * + * > "The routing mechanism via which this route was learned. Inclusion + * > of values for gateway rout-ing protocols is not intended to imply + * > that hosts should support those protocols." + * + * @param bool $translate If true, use the `$ROUTE_ENTRY_PROTOS` array to return textual representation + * @return array The route protocols (see `self::$ROUTE_ENTRY_PROTOS`) + */ + public function routeProto( $translate = false ) + { + $s = $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_PROTO , 12 , 24 ); + + if( !$translate ) + return $s; + + return $this->getSNMP()->translate( $s, self::$ROUTE_ENTRY_PROTOS ); + } + + + /** + * Returns the route age + * + * > "The number of seconds since this route was last updated or otherwise determined to be + * > correct. Note that no semantics of `too old' can be implied except through knowledge + * > of the routing protocol by which the route was learned." + * + * @return array The age of the routes in seconds + */ + public function routeAge() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_AGE , 12 , 24 ); + } + + + /** + * Returns the route info + * + * > "A reference to MIB definitions specific to the particular routing + * > protocol which is responsible for this route, as determined by the + * > value specified in the route's ipCidrRouteProto value. + * > + * + * @return array A reference to MIB definitions specific to the particular routing protocol. + */ + public function routeInfo() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_INFO , 12 , 24 ); + } + + + /** + * Returns the AS of the next hop + * + * > "The Autonomous System Number of the Next Hop. The semantics of + * > this object are determined by the routing-protocol specified in + * > the route's ipCidrRouteProto value. When this object is unknown + * > or not relevant its value should be set to zero." + * + * @return array The AS of the next hop + */ + public function routeNextHopAS() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_NEXTHOPAS , 12 , 24 ); + } + + + /** + * The first routing metric for this route + * + * @return array The first routing metric for the route + */ + public function routeMetric1() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_METRIC1 , 12 , 24 ); + } + + + /** + * The second routing metric for this route + * + * @return array The first routing metric for the route + */ + public function routeMetric2() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_METRIC2 , 12 , 24 ); + } + + + /** + * The third routing metric for this route + * + * @return array The first routing metric for the route + */ + public function routeMetric3() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_METRIC3 , 12 , 24 ); + } + + + /** + * The fourth routing metric for this route + * + * @return array The first routing metric for the route + */ + public function routeMetric4() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_METRIC4 , 12 , 24 ); + } + + + /** + * The fifth routing metric for this route + * + * @return array The first routing metric for the route + */ + public function routeMetric5() + { + return $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_METRIC5 , 12 , 24 ); + } + + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_ACTIVE = 1; + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_NOTINSERVICE = 2; + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_NOTREADY = 3; + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_CREATEANDGO = 4; + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_CREATEANDWAIT = 5; + + /** + * Possible value for route status + * @var int Possible value for peer connection state + */ + const ROUTE_ENTRY_STATUS_DESTROY = 6; + + + /** + * Look up for text representation of route status + * @var array Look up for text representation of route status + */ + public static $ROUTE_STATUS_TYPES = [ + self::ROUTE_ENTRY_STATUS_ACTIVE => 'active', + self::ROUTE_ENTRY_STATUS_NOTINSERVICE => 'not in service', + self::ROUTE_ENTRY_STATUS_NOTREADY => 'not ready', + self::ROUTE_ENTRY_STATUS_CREATEANDGO => 'create and go', + self::ROUTE_ENTRY_STATUS_CREATEANDWAIT => 'create and wait', + self::ROUTE_ENTRY_STATUS_DESTROY => 'destroy' + ]; + + + /** + * Returns the route status + * + * > "The row status variable, used according to row installation and + * > removal conventions." + * + * @return array The routes installation and removal status + */ + public function routeStatus( $translate = false ) + { + $s = $this->getSNMP()->subOidWalkLong( self::OID_ROUTE_ENTRY_STATUS , 12 , 24 ); + + if( !$translate ) + return $s; + + return $this->getSNMP()->translate( $s, self::$ROUTE_STATUS_TYPES ); + } + + + /** + * Utility function to gather all routes into a single array. + * @param bool $translate Where a called function supports translation, if true then translate + * @return array Array of routes + */ + public function routeDetails( $translate = false ) + { + $fetchList = [ + 'routeDest' => 'destination', + 'routeMask' => 'mask', + 'routeTos' => 'TOS', + 'routeNextHop' => 'nextHop', + 'routeIfIndex' => 'ifIndex', + 'routeType' => 'type', + 'routeProto' => 'protocol', + 'routeAge' => 'age', + 'routeInfo' => 'info', + 'routeNextHopAS' => 'nextHopAS', + 'routeMetric1' => 'metric1', + 'routeMetric2' => 'metric2', + 'routeMetric3' => 'metric3', + 'routeMetric4' => 'metric4', + 'routeMetric5' => 'metric5', + 'routeStatus' => 'status' + ]; + $canTranslate = [ 'routeType' , 'routeProto', 'routeStatus' ]; + $details = []; + + foreach( $fetchList as $fn => $idx ) + { + if( in_array( $fn, $canTranslate ) ) + $values = $this->$fn( $translate ); + else + $values = $this->$fn(); + foreach( $values as $ip => $value ) + $details[ $ip ][ $idx ] = $value; + } + return $details; + } + +} +?> diff --git a/OSS_SNMP/MIBS/SNMP/Engine.php b/OSS_SNMP/MIBS/SNMP/Engine.php index c0bde2dd6..291073e7c 100644 --- a/OSS_SNMP/MIBS/SNMP/Engine.php +++ b/OSS_SNMP/MIBS/SNMP/Engine.php @@ -43,8 +43,24 @@ */ class Engine extends \OSS_SNMP\MIB { + const OID_BOOTS = '.1.3.6.1.6.3.10.2.1.2.0'; const OID_TIME = '.1.3.6.1.6.3.10.2.1.3.0'; + /** + * Get the SNMP engine boots + * + * + * > "The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was last configured." + * + * @see http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&translate=Translate&objectInput=1.3.6.1.6.3.10.2.1.2#oidContent + * + * @return int The SNMP engine boots + */ + public function boots() + { + return $this->getSNMP()->get( self::OID_BOOTS ); + } + /** * Get the SNMP engine time * diff --git a/OSS_SNMP/MIBS/Vdsl2Line.php b/OSS_SNMP/MIBS/Vdsl2Line.php new file mode 100644 index 000000000..ee2c6198c --- /dev/null +++ b/OSS_SNMP/MIBS/Vdsl2Line.php @@ -0,0 +1,837 @@ + line-profile-10 + * + * @return array Array of line profiles indexed by ifIndex + */ + public function profiles() + { + return $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_CONFIG_TEMPLATE ); + } + + /** + * The xDSL2 Line Configuration Template (profile) + * + * @param int $ifIndex The ifIndex to get the results for + * @return string The line profile + */ + public function profile($ifIndex) + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_CONFIG_TEMPLATE . '.' . $ifIndex ); + } + + + /** + * Array of actual net data rates + * + * "Actual net data rate at which the bearer channel is operating, + * if in L0 power management state. In L1 or L2 states, it relates to the previous L0 state. + * The data rate is coded in bit/s" + * + * 'ifIndex.1' => downstream_rate, + * 'ifIndex.2' => upstream_rate + * + * would yield an array: + * '1.1' => 7200000, + * '1.2' => 1780000 + * + * @return array Actual net data rates + */ + public function rates() + { + return $this->getSNMP()->subOidWalk( self::OID_XDSL2_CHANNEL_STATUS_ACTUAL_DATA_RATE , 14, -1 ); + } + + /** + * The actual downstream rate of specified ifIndex + * + * NB: SNMP exceptions are caught and in such cases null is returned + * as not all dsl ports have all properties. + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The actual downstream rate in bit/s + */ + public function dsRate($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_CHANNEL_STATUS_ACTUAL_DATA_RATE . '.' . $ifIndex . '.1' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + /** + * The actual upstream rate of specified ifIndex + * + * NB: SNMP exceptions are caught and in such cases null is returned + * as not all dsl ports have all properties. + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The actual upstream rate in bit/s + */ + public function usRate($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_CHANNEL_STATUS_ACTUAL_DATA_RATE . '.' . $ifIndex . '.2' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + + /** + * Get an array of device xTU SNR margins + * + * "SNR Margin is the maximum increase in dB of the noise power + * received at the XTU (xTU-R for a band in the downstream direction + * and xTU-C for a band in the upstream direction), such that + * the BER requirements are met for all bearer channels received + * at the XTU. Values range from -640 to 630 in units of 0.1 dB + * (Physical values are -64 to 63 dB). + * A special value of 0x7FFFFFFF (2147483647) indicates the + * SNR Margin is out of range to be represented. + * A special value of 0x7FFFFFFE (2147483646) indicates the + * SNR Margin measurement is currently unavailable." + * + * [ "ifindex.band" => snr_margin ] + * + * e.g. + * + * [ + * 'ifIndex.upstream' => snr_margin + * 'ifIndex.downstream' => snr_margin + * 'ifIndex.us0' => snr_margin + * 'ifIndex.ds1' => snr_margin + * 'ifIndex.us1' => snr_margin + * 'ifIndex.ds2' => snr_margin + * 'ifIndex.us2' => snr_margin + * 'ifIndex.ds3' => snr_margin + * 'ifIndex.us3' => snr_margin + * ] + * + * would yield an array: + * [ + * '1.1' => 255 + * '1.2' => 118 + * '1.3' => 255 + * '1.4' => 118 + * '1.5' => 255 + * '1.6' => 118 + * '1.7' => 255 + * '1.8' => 118 + * '1.9' => 255 + * ] + * + * @param int|null $ifIndex The ifIndex to get the results for + * @return array Device xTU SNR margins + */ + public function margins($ifIndex = null) + { + try + { + $oid = self::OID_XDSL2_LINE_BAND_STATUS_SNR_MGN; + if ($ifIndex) { + $oid .= '.' . $ifIndex; + } + + return $this->getSNMP()->subOidWalk( $oid, 14, -1 ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + /** + * Get line SNR margin for upstream band number 0 (US0) + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The SNR margin for band US0 + */ + public function us0SnrMargin($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_BAND_STATUS_SNR_MGN . '.' . $ifIndex . '.3' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + /** + * Get line SNR margin for downstream band number 1 (DS1) + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The SNR margin for band DS1 + */ + public function ds1SnrMargin($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_BAND_STATUS_SNR_MGN . '.' . $ifIndex . '.4' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + + /** + * Get an array of device xTU line attenuations + * + *"Values range from 0 to 1270 in units of 0.1 dB (Physical values + * are 0 to 127 dB). + * A special value of 0x7FFFFFFF (2147483647) indicates the line + * attenuation is out of range to be represented. + * A special value of 0x7FFFFFFE (2147483646) indicates the line + * attenuation measurement is unavailable." + * + * [ "ifindex.band" => attenuation ] + * + * e.g. + * + * [ + * 'ifIndex.upstream' => attenuation + * 'ifIndex.downstream' => attenuation + * 'ifIndex.us0' => attenuation + * 'ifIndex.ds1' => attenuation + * 'ifIndex.us1' => attenuation + * 'ifIndex.ds2' => attenuation + * 'ifIndex.us2' => attenuation + * 'ifIndex.ds3' => attenuation + * 'ifIndex.us3' => attenuation + * ] + * + * would yield an array: + * [ + * '1.1' => 2147483646 + * '1.2' => 2147483646 + * '1.3' => 152 + * '1.4' => 197 + * '1.5' => 1271 + * '1.6' => 1271 + * '1.7' => 1271 + * '1.8' => 1271 + * '1.9' => 1271 + * ] + * + * @param int|null $ifIndex The ifIndex to get the results for + * @return array Device xTU line attenuations (indexed by ifIndex) + */ + public function attenuations($ifIndex = null) + { + try + { + $oid = self::OID_XDSL2_LINE_BAND_STATUS_LINE_ATENNUATION; + if ($ifIndex) { + $oid .= '.' . $ifIndex; + } + + return $this->getSNMP()->subOidWalk( $oid, 14, -1 ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + /** + * Get line attenuation for upstream band number 0 (US0) + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The line attenuation for band US0 + */ + public function us0Attenuation($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_BAND_STATUS_LINE_ATENNUATION . '.' . $ifIndex . '.3' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + /** + * Get line attenuation for downstream band number 1 (DS1) + * + * @param int $ifIndex The ifIndex to get the results for + * @return int The line attenuation for band DS1 + */ + public function ds1Attenuation($ifIndex) + { + try + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_BAND_STATUS_LINE_ATENNUATION . '.' . $ifIndex . '.4' ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + + /** + * Maximum Attainable Data Rate Downstream. + * + * "The maximum downstream net data rate currently attainable by + * the xTU-C transmitter and the xTU-R receiver, coded in bit/s." + * + * e.g. [1] => 4276000 + * + * @return array Associate array of downstream attainable rates indexed by ifIndex + */ + public function dsAttainableRates() + { + return $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_ATTAINABLE_RATE_DS ); + } + + /** + * Maximum Attainable Data Rate Downstream of specified ifIndex + * + * @param int $ifIndex The ifIndex to get the results for + * @return array Associate array of downstream attainable rates indexed by ifIndex + */ + public function dsAttainableRate($ifIndex) + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_STATUS_ATTAINABLE_RATE_DS . "." . $ifIndex ); + } + + + /** + * Maximum Attainable Data Rate Upstream. + * + * "The maximum upstream net data rate currently attainable by the + * xTU-R transmitter and the xTU-C receiver, coded in bit/s." + * + * e.g. [1] => 1252000 + * + * @return array Associate array of upstream attainable rates indexed by ifIndex + */ + public function usAttainableRates() + { + return $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_ATTAINABLE_RATE_US ); + } + + /** + * Maximum Attainable Data Rate Upstream of specified ifIndex + * + * @param int $ifIndex The ifIndex to get the results for + * @return array Associate array of downstream attainable rates indexed by ifIndex + */ + public function usAttainableRate($ifIndex) + { + return $this->getSNMP()->get( self::OID_XDSL2_LINE_STATUS_ATTAINABLE_RATE_US . "." . $ifIndex ); + } + + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_T1413 = '0000000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ETSI_DTS = '4000000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_POTS_NON_OVERLAPPED = '2000000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_POTS_OVERLAPPED = '1000000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_ISDN_NON_OVERLAPPED = '0800000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_ISDN_OVERLAPPED = '0400000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_TCM_ISDN_NON_OVERLAPPED = '0200000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_TCM_ISDN_OVERLAPPED = '0100000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITE_POTS_NON_OVERLAPPED = '0080000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITE_POTS_OVERLAPPED = '0040000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITE_TCM_ISDN_NON_OVERLAPPED = '0020000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITE_TCM_ISDN_OVERLAPPED = '0010000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GDMT_TCM_ISDN_SYMMETRIC = '0008000000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_NON_OVERLAPPED = '0000200000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_OVERLAPPED = '0000100000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ISDN_NON_OVERLAPPED = '0000080000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ISDN_OVERLAPPED = '0000040000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITEBIS_POTS_NON_OVERLAPPED = '0000008000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITEBIS_POTS_OVERLAPPED = '0000004000000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_I_ALL_DIGITAL_NON_OVERLAPPED = '0000000800000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_I_ALL_DIGITAL_OVERLAPPED = '0000000400000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_J_ALL_DIGITAL_NON_OVERLAPPED = '0000000200000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_J_ALL_DIGITAL_OVERLAPPED = '0000000100000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITEBIS_ANNEX_I_NON_OVERLAPPED = '0000000080000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_GLITEBIS_ANNEX_I_OVERLAPPED = '0000000040000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_NON_OVERLAPPED_MODE1 = '0000000020000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_NON_OVERLAPPED_MODE2 = '0000000010000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_OVERLAPPED_MODE3 = '0000000008000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_OVERLAPPED_MODE4 = '0000000004000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_M_NON_OVERLAPPED = '0000000002000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_M_OVERLAPPED = '0000000001000000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_NON_OVERLAPPED = '0000000000800000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_OVERLAPPED = '0000000000400000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ISDN_NON_OVERLAPPED = '0000000000200000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ISDN_OVERLAPPED = '0000000000100000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_I_ALL_DIGITAL_NON_OVERLAPPED = '0000000000020000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_I_ALL_DIGITAL_OVERLAPPED = '0000000000010000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_J_ALL_DIGITAL_NON_OVERLAPPED = '0000000000008000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_J_ALL_DIGITAL_OVERLAPPED = '0000000000004000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_ANNEX_M_NON_OVERLAPPED = '0000000000002000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_ANNEX_M_OVERLAPPED = '0000000000001000'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_A = '0000000000000080'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_B = '0000000000000040'; + + /** + * Constant for possible value of transmission mode. + * @see transmissionModes() + */ + const XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_C = '0000000000000020'; + + + /** + * Text representation of transmission modes. + * + * @see transmissionModes() + * @var array Text representations of transmission modes. + */ + public static $XDSL2_TRANSMISSION_MODES = array( + self::XDSL2_TRANSMISSION_MODE_T1413 => 'T1.413', + self::XDSL2_TRANSMISSION_MODE_ETSI_DTS => 'ETSI DTS/TM06006', + self::XDSL2_TRANSMISSION_MODE_GDMT_POTS_NON_OVERLAPPED => 'G.992.1 POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GDMT_POTS_OVERLAPPED => 'G.992.1 POTS overlapped', + self::XDSL2_TRANSMISSION_MODE_GDMT_ISDN_NON_OVERLAPPED => 'G.992.1 ISDN non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GDMT_ISDN_OVERLAPPED => 'G.992.1 ISDN overlapped', + self::XDSL2_TRANSMISSION_MODE_GDMT_TCM_ISDN_NON_OVERLAPPED => 'G.992.1 TCM-ISDN non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GDMT_TCM_ISDN_OVERLAPPED => 'G.992.1 TCM-ISDN overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITE_POTS_NON_OVERLAPPED => 'G.992.2 POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITE_POTS_OVERLAPPED => 'G.992.2 POTS overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITE_TCM_ISDN_NON_OVERLAPPED => 'G.992.2 with TCM-ISDN non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITE_TCM_ISDN_OVERLAPPED => 'G.992.2 with TCM-ISDN overlapped', + //Bit 13-17: Reserved + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_NON_OVERLAPPED => 'G.992.3 POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_OVERLAPPED => 'G.992.3 POTS overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_ISDN_NON_OVERLAPPED => 'G.992.3 ISDN non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_ISDN_OVERLAPPED => 'G.992.3 ISDN overlapped', + //Bit 22-23: Reserved + self::XDSL2_TRANSMISSION_MODE_GLITEBIS_POTS_NON_OVERLAPPED => 'G.992.4 POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITEBIS_POTS_OVERLAPPED => 'G.992.4 POTS overlapped', + //Bit 26-27: Reserved + self::XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_I_ALL_DIGITAL_NON_OVERLAPPED => 'G.992.3 Annex I All-Digital non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_I_ALL_DIGITAL_OVERLAPPED => 'G.992.3 Annex I All-Digital overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_J_ALL_DIGITAL_NON_OVERLAPPED => 'G.992.3 Annex J All-Digital non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_ANNEX_J_ALL_DIGITAL_OVERLAPPED => 'G.992.3 Annex J All-Digital overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITEBIS_ANNEX_I_NON_OVERLAPPED => 'G.992.4 Annex I All-Digital non-overlapped', + self::XDSL2_TRANSMISSION_MODE_GLITEBIS_ANNEX_I_OVERLAPPED => 'G.992.4 Annex I All-Digital overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_NON_OVERLAPPED_MODE1 => 'G.992.3 Annex L POTS non-overlapped, mode 1, wide U/S', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_NON_OVERLAPPED_MODE2 => 'G.992.3 Annex L POTS non-overlapped, mode 2, narrow U/S', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_OVERLAPPED_MODE3 => 'G.992.3 Annex L POTS overlapped, mode 3, wide U/S', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_L_OVERLAPPED_MODE4 => 'G.992.3 Annex L POTS overlapped, mode 4, narrow U/S', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_M_NON_OVERLAPPED => 'G.992.3 Annex M POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2_POTS_ANNEX_M_OVERLAPPED => 'G.992.3 Annex M POTS overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_NON_OVERLAPPED => 'G.992.5 POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_OVERLAPPED => 'G.992.5 POTS overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ISDN_NON_OVERLAPPED => 'G.992.5 ISDN non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ISDN_OVERLAPPED => 'G.992.5 ISDN overlapped', + //Bit 44-45: Reserved + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_I_ALL_DIGITAL_NON_OVERLAPPED => 'G.992.5 Annex I All-Digital non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_I_ALL_DIGITAL_OVERLAPPED => 'G.992.5 Annex I All-Digital overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_J_ALL_DIGITAL_NON_OVERLAPPED => 'G.992.5 Annex J All-Digital non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_ANNEX_J_ALL_DIGITAL_OVERLAPPED => 'G.992.5 Annex J All-Digital overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_ANNEX_M_NON_OVERLAPPED => 'G.992.5 Annex M POTS non-overlapped', + self::XDSL2_TRANSMISSION_MODE_ADSL2PLUS_POTS_ANNEX_M_OVERLAPPED => 'G.992.5 Annex M POTS overlapped', + //Bit 52-55: Reserved + self::XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_A => 'G.993.2 Annex A', + self::XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_B => 'G.993.2 Annex B', + self::XDSL2_TRANSMISSION_MODE_VDSL2_ANNEX_C => 'G.993.2 Annex C' + //Bit 59-63: Reserved + ); + + + /** + * Array of xDSL line transmission modes + * + * "The xTU Transmission System (xTS) in use. It is coded in a bitmap representation with + * one bit set to '1' (the selected coding for the DSL line). This parameter may be derived + * from the handshaking procedures defined in Recommendation G.994.1. A set of xDSL line + * transmission modes, with one bit per mode." + * + * @see XDSL2_TRANSMISSION_MODES + * @see https://tools.ietf.org/html/rfc5650 Xdsl2TransmissionModeType + * @see http://www.circitor.fr/Mibs/Html/VDSL2-LINE-TC-MIB.php#Xdsl2TransmissionModeType + * @param boolean $translate If true, return the string representation + * @return array An array of xDSL line transmission modes + */ + public function transmissionModes($translate = false) + { + try + { + $modes = $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_XTU_TRANSMISSION_SYSTEM ); + + if( !$translate ) { + return $modes; + } + + return $this->getSNMP()->translate( $modes, self::$XDSL2_TRANSMISSION_MODES ); + } + catch( \OSS_SNMP\Exception $e ) + { + return null; + } + } + + + /** + * Actual Aggregate Transmit Power Downstream. + * + * "The total amount of transmit power delivered by the xTU-C at + * the U-C reference point, at the instant of measurement. It + * ranges from -310 to 310 units of 0.1 dBm (physical values are -31 + * to 31 dBm). + * A value of 0x7FFFFFFF (2147483647) indicates the measurement is + * out of range to be represented." + * + * e.g. [1] => 192 + * + * @return array Associate array of downstream actual aggregate transmit powers + */ + public function dsActualAggregateTransmitPowers() + { + return $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_ACT_ATP_DS ); + } + + /** + * Actual Aggregate Transmit Power Upstream. + * + * "The total amount of transmit power delivered by the xTU-R at the + * U-R reference point, at the instant of measurement. It ranges + * from -310 to 310 units of 0.1 dBm (physical values are -31 + * to 31 dBm). + * A value of 0x7FFFFFFF (2147483647) indicates the measurement is + * out of range to be represented." + * + * e.g. + * [1] => 120 + * [2] => 104 + * + * @return array Associate array of upstream actual aggregate transmit powers + */ + public function usActualAggregateTransmitPowers() + { + return $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_ACT_ATP_US ); + } + + + /** + * Constant for possible value of power management state. + * @see powerManagementStates() + */ + const XDSL2_POWER_MANAGEMENT_STATE_L0 = 1; + /** + * Constant for possible value of power management state. + * @see powerManagementStates() + */ + const XDSL2_POWER_MANAGEMENT_STATE_L1 = 2; + /** + * Constant for possible value of power management state. + * @see powerManagementStates() + */ + const XDSL2_POWER_MANAGEMENT_STATE_L2 = 3; + /** + * Constant for possible value of power management state. + * @see powerManagementStates() + */ + const XDSL2_POWER_MANAGEMENT_STATE_L3 = 4; + + /** + * Text representation of power management states. + * + * @see powerManagementStates() + * @var array Text representations of power management states. + */ + public static $XDSL2_POWER_MANAGEMENT_STATES = array( + self::XDSL2_POWER_MANAGEMENT_STATE_L0 => 'L0', + self::XDSL2_POWER_MANAGEMENT_STATE_L1 => 'L1', + self::XDSL2_POWER_MANAGEMENT_STATE_L2 => 'L2', + self::XDSL2_POWER_MANAGEMENT_STATE_L3 => 'L3' + ); + + /** + * Array of the current power management states. + * + * "One of four possible power management states: + * L0 - Synchronized and full transmission (i.e., Showtime), + * L1 - Low Power with reduced net data rate (G.992.2 only), + * L2 - Low Power with reduced net data rate (G.992.3 and G.992.4 only), + * L3 - No power + * The various possible values are:l0(1), l1(2), l2(3), l3(4)." + * + * @see XDSL2_POWER_MANAGEMENT_STATES + * @param boolean $translate If true, return the string representation + * @return array An array of xDSL line current power management states + */ + public function powerManagementStates($translate = false) + { + $states = $this->getSNMP()->walk1d( self::OID_XDSL2_LINE_STATUS_POWER_MNG_STATE ); + if( !$translate ) { + return $states; + } + + return $this->getSNMP()->translate( $states, self::$XDSL2_POWER_MANAGEMENT_STATES ); + } + +} \ No newline at end of file diff --git a/OSS_SNMP/Platform.php b/OSS_SNMP/Platform.php index 747939879..1c69b4bdc 100644 --- a/OSS_SNMP/Platform.php +++ b/OSS_SNMP/Platform.php @@ -84,7 +84,7 @@ class Platform * * @var string The platform serial number */ - protected $_serial = '(not implemented)'; + protected $_serial = null; /** * The \OSS_SNMP\SNMP object @@ -115,30 +115,37 @@ public function parse() { // query the platform for it's description and parse it for details - $sysDescr = $this->getSNMPHost()->useSystem()->description(); + if( $this->getSNMPHost()->iAmADummy() ) { - try { - $sysObjectId = $this->getSNMPHost()->useSystem()->systemObjectID(); - } catch( Exception $e ){ - $sysObjectId = null; + include( __DIR__ . '/Platforms/dummy.php' ); + + } else { + $sysDescr = $this->getSNMPHost()->useSystem()->description(); + + try { + $sysObjectId = $this->getSNMPHost()->useSystem()->systemObjectID(); + } catch( Exception $e ){ + $sysObjectId = null; + } + + // there's possibly a better way to do this...? + foreach( glob( __DIR__ . '/Platforms/vendor_*.php' ) as $f ) { + include( $f ); + } } - - // there's possibly a better way to do this...? - foreach( glob( __DIR__ . '/Platforms/vendor_*.php' ) as $f ) - include( $f ); } - /** - * Set the SNMPT Host - * - * @param \OSS_SNMP\SNMP $s The SNMP Host object - * @return \OSS_SNMP\Platform For fluent interfaces - */ - public function setSNMPHost( $s ) - { - $this->_snmpHost = $s; - return $this; - } + /** + * Set the SNMPT Host + * + * @param \OSS_SNMP\SNMP $s The SNMP Host object + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setSNMPHost( $s ) + { + $this->_snmpHost = $s; + return $this; + } /** * Get the SNMPHost object diff --git a/OSS_SNMP/Platforms/dummy.php b/OSS_SNMP/Platforms/dummy.php new file mode 100644 index 000000000..2866c7fd0 --- /dev/null +++ b/OSS_SNMP/Platforms/dummy.php @@ -0,0 +1,41 @@ +setVendor( 'Brocade' ); +$this->setModel( 'FESX648' ); +$this->setOs( 'Dummy' ); +$this->setOsVersion( '1.2.3' ); +$this->setOsDate( date('Y-m-d H:i:s' ) ); +$this->setSerialNumber( 'ABC987654321' ); diff --git a/OSS_SNMP/Platforms/vendor_allied-telesis.php b/OSS_SNMP/Platforms/vendor_allied-telesis.php new file mode 100644 index 000000000..092d4ba94 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_allied-telesis.php @@ -0,0 +1,59 @@ +setVendor( 'Allied Telesis' ); + $this->setOs( 'AW+' ); + + preg_match( '/Allied Telesis router\/switch, AW\+ v([0-9\-\.]+)/', + $sysDescr, $matches ); + + if( $sysObjectId && $sysObjectId == '.1.3.6.1.4.1.207.1.14.118' ) { + $this->setModel('AT-28GTX'); + } else { + $this->setModel('Unknown'); + } + + $this->setOsVersion( isset( $matches[1] ) ? $matches[1] : 'Unknown' ); + $this->setOsDate( null ); + +} diff --git a/OSS_SNMP/Platforms/vendor_arista.php b/OSS_SNMP/Platforms/vendor_arista.php index 7244069c1..675d7ba4f 100644 --- a/OSS_SNMP/Platforms/vendor_arista.php +++ b/OSS_SNMP/Platforms/vendor_arista.php @@ -45,7 +45,7 @@ $sysDescr, $matches ); $this->setVendor( 'Arista' ); - $this->setModel( isset( $matches[2] ) ? $matches[2] : 'Uknown' ); + $this->setModel( isset( $matches[2] ) ? $matches[2] : 'Unknown' ); $this->setOs( 'EOS' ); $this->setOsVersion( isset( $matches[1] ) ? $matches[1] : 'Unknown' ); $this->setOsDate( null ); diff --git a/OSS_SNMP/Platforms/vendor_brocade.php b/OSS_SNMP/Platforms/vendor_brocade.php index 1b5656db3..cbda72f83 100644 --- a/OSS_SNMP/Platforms/vendor_brocade.php +++ b/OSS_SNMP/Platforms/vendor_brocade.php @@ -38,12 +38,15 @@ // // 'Brocade Communications Systems, Inc. FESX624+2XG, IronWare Version 07.3.00cT3e1 Compiled on Apr 25 2012 at 17:01:00 labeled as SXS07300c' // 'Brocade Communication Systems, Inc. TurboIron-X24, IronWare Version 04.2.00b Compiled on Oct 22 2010 at 15:15:36 labeled as TIS04200b' +// 'Brocade Communications Systems, Inc. Stacking System ICX7450-48, IronWare Version 08.0.30dT213 Compiled on Nov 3 2015 at 22:16:04 labeled as SPR08030d' // 'Brocade NetIron CES, IronWare Version V5.2.0cT183 Compiled on Oct 28 2011 at 02:58:44 labeled as V5.2.00c' // 'Brocade NetIron MLX (System Mode: MLX), IronWare Version V5.4.0cT163 Compiled on Mar 25 2013 at 17:08:16 labeled as V5.4.00c' +// 'Brocade MLXe (System Mode: MLX), IronWare Version V5.7.0dT163 Compiled on Sep 23 2015 at 09:35:50 labeled as V5.7.00db' +// 'Brocade VDX Switch, BR-VDX6720-24, Network Operating System Software Version 4.1.3b.' -if( substr( $sysDescr, 0, 8 ) == 'Brocade ' ) +if( substr( $sysDescr, 0, 8 ) == 'Brocade ' || substr( $sysDescr, 0, 23 ) == 'Foundry Networks, Inc. ' ) { - if( preg_match( '/Brocade Communication[s]* Systems, Inc. (.+),\s([a-zA-Z]+)\sVersion\s(.+)\sCompiled\son\s(([a-zA-Z]+)\s(\d+)\s(\d+)\s)at\s((\d\d):(\d\d):(\d\d))\slabeled\sas\s(.+)/', + if( preg_match( '/Brocade Communication[s]* Systems, Inc. [(Stacking System)]*(.+),\s([a-zA-Z]+)\sVersion\s(.+)\sCompiled\son\s(([a-zA-Z]+)\s+(\d+)\s(\d+)\s)at\s((\d\d):(\d\d):(\d\d))\slabeled\sas\s(.+)/', $sysDescr, $matches ) ) { $this->setVendor( 'Brocade' ); @@ -53,26 +56,36 @@ $this->setOsDate( new \DateTime( "{$matches[6]}/{$matches[5]}/{$matches[7]}:{$matches[8]} +0000" ) ); $this->getOsDate()->setTimezone( new \DateTimeZone( 'UTC' ) ); } - else if( preg_match( '/Brocade (NetIron [a-zA-Z0-9]+).*IronWare\sVersion\s(.+)\s+Compiled\s+on\s+(([a-zA-Z]+)\s+(\d+)\s+(\d+)\s+)at\s+((\d\d):(\d\d):(\d\d))\s+labeled\s+as\s+(.+)/', + else if( preg_match( '/Brocade ((NetIron )?[a-zA-Z0-9]+).*IronWare\sVersion\s(.+)\s+Compiled\s+on\s+(([a-zA-Z]+)\s+(\d+)\s+(\d+)\s+)at\s+((\d\d):(\d\d):(\d\d))\s+labeled\s+as\s+(.+)/', $sysDescr, $matches ) ) { $this->setVendor( 'Brocade' ); $this->setModel( $matches[1] ); $this->setOs( 'IronWare' ); - $this->setOsVersion( $matches[2] ); - $this->setOsDate( new \DateTime( "{$matches[5]}/{$matches[4]}/{$matches[6]}:{$matches[7]} +0000" ) ); + $this->setOsVersion( $matches[3] ); + $this->setOsDate( new \DateTime( "{$matches[6]}/{$matches[5]}/{$matches[7]}:{$matches[8]} +0000" ) ); $this->getOsDate()->setTimezone( new \DateTimeZone( 'UTC' ) ); } - else if( preg_match( '/Foundry Networks, Inc. (.+),\sIronWare\sVersion\s(.+)\sCompiled\son\s(([a-zA-Z]+)\s(\d+)\s(\d+)\s)at\s((\d\d):(\d\d):(\d\d))\slabeled\sas\s(.+)/', + // Foundry Networks, Inc. FES12GCF, IronWare Version 04.1.01eTc1 Compiled on Mar 06 2011 at 17:05:36 labeled as FES04101e + // Foundry Networks, Inc. BigIron RX, IronWare Version V2.7.2aT143 Compiled on Sep 29 2009 at 17:15:24 labeled as V2.7.02a + else if( preg_match( '/^Foundry Networks, Inc\. ([A-Za-z0-9\s]+), IronWare Version ([0-9a-zA-Z\.]+) Compiled on (([a-zA-Z]+) (\d+) (\d+) )at ((\d\d):(\d\d):(\d\d)) labeled as ([A-Za-z0-9\.]+)$/', $sysDescr, $matches ) ) { - echo "Vendor: " . 'Foundry Networks' . "\n"; - echo "Model: " . $matches[1] . "\n"; - echo "OS: " . 'IronWare' . "\n"; - echo "OS Ver: " . $matches[2] . "\n"; + $this->setVendor( 'Foundry Networks' ); + $this->setModel( $matches[1] ); + $this->setOs( 'IronWare' ); + $this->setOsVersion( $matches[2] ); $d = new \DateTime( "{$matches[5]}/{$matches[4]}/{$matches[6]}:{$matches[7]} +0000" ); $d->setTimezone( new \DateTimeZone( 'UTC' ) ); - echo "OS Date: " . $d->format( 'Y-m-d H:i:s' ) . "\n\n"; + $this->setOsDate( $d ); + } + else if( preg_match( '/Brocade VDX Switch,\s(.+), Network Operating System Software Version\s(.+)\./', + $sysDescr, $matches ) ) + { + $this->setVendor( 'Brocade' ); + $this->setModel( $matches[1] ); + $this->setOs( 'Network Operating System Software' ); + $this->setOsVersion( $matches[2] ); } try { @@ -81,3 +94,4 @@ $this->setSerialNumber( '(error)' ); } } + diff --git a/OSS_SNMP/Platforms/vendor_cisco.php b/OSS_SNMP/Platforms/vendor_cisco.php index dabc8bf68..efc11805a 100644 --- a/OSS_SNMP/Platforms/vendor_cisco.php +++ b/OSS_SNMP/Platforms/vendor_cisco.php @@ -33,20 +33,105 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +if( substr( $sysDescr, 0, 26 ) == 'Cisco IOS Software, IOS-XE' ) +{ + // 'Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSAL-M), Version 03.08.02.E RELEASE SOFTWARE (fc2)' + // 'Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06E RELEASE SOFTWARE (fc1)' + + preg_match( '/Cisco IOS Software, IOS-XE Software,\s([a-zA-Z0-9\s]+[a-zA-Z0-9])\s+Software\s\(([0-9A-Za-z\(\)_\.\-]+)\),\sVersion\s([0-9A-Za-z\.]+)\sRELEASE SOFTWARE.*/', + $sysDescr, $matches ); -// Works with sysDescr such as: -// -// 'Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISE_WAN-VM), Version 12.2(33)SXI5, RELEASE SOFTWARE (fc2)' + $this->setVendor( 'Cisco Systems' ); + $this->setModel( $matches[1]); + $this->setOs( 'IOS-XE' ); + $this->setOsVersion( isset( $matches[3] ) ? $matches[3] : '' ); + $this->setOsDate( null ); -if( substr( $sysDescr, 0, 18 ) == 'Cisco IOS Software' ) +} +else if( substr( $sysDescr, 0, 18 ) == 'Cisco IOS Software' ) { - preg_match( '/Cisco IOS Software, (.+) Software \((.+)\), Version\s([0-9A-Za-z\(\)\.]+), RELEASE SOFTWARE\s\((.+)\)/', + // 'Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISE_WAN-VM), Version 12.2(33)SXI5, RELEASE SOFTWARE (fc2)' + // 'Cisco IOS Software [Everest], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.6.2, RELEASE SOFTWARE (fc2)' + + preg_match( '/Cisco IOS Software(?: \[\w+\])?,\s([\w\s]+)\sSoftware \((.+)\), Version\s([0-9A-Za-z\(\)\.]+), RELEASE SOFTWARE\s\((.+)\)/', $sysDescr, $matches ); $this->setVendor( 'Cisco Systems' ); - $this->setModel( $this->getSNMPHost()->useEntity()->physicalName()[1] ); + try { + if( $this instanceof \OSS_SNMP\TestPlatform ) { + $this->setModel('PHPUnit'); + } else { + $model = $this->getSNMPHost()->useEntity()->physicalName(); + if( isset( $model[1] ) ) { + $this->setModel( $model[ 1 ] ); + } else { + $this->setModel( 'Unknown' ); + } + } + } catch( \Exception $e ) { + $this->setModel( 'Unknown' ); + } + $this->setOs( 'IOS' ); - $this->setOsVersion( $matches[3] ); + $this->setOsVersion( isset( $matches[3] ) ? $matches[3] : '' ); $this->setOsDate( null ); } +else if( substr( $sysDescr, 0, 48 ) == 'Cisco Internetwork Operating System Software IOS' ) +{ + // 'Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(13)EA1, RELEASE SOFTWARE.*' + + $sysDescr = trim( preg_replace( '/\s+/', ' ', $sysDescr ) ); + preg_match( '/Cisco(.+)C2950 Software(.+)Version\s([0-9A-Za-z\(\)\.]+),\sRELEASE SOFTWARE.*/', + $sysDescr, $matches ); + $this->setVendor( 'Cisco Systems' ); + $this->setModel( 'C2950' ); + $this->setOs( 'IOS' ); + $this->setOsVersion( isset( $matches[3] ) ? $matches[3] : '' ); + $this->setOsDate( null ); +} +else if( substr( $sysDescr, 0, 21 ) == 'Cisco IOS XR Software' ) +{ + // 'Cisco IOS XR Software (Cisco ASR9K Series), Version 4.3.2[Default]\r\nCopyright (c) 2013 by Cisco Systems, Inc., referer: http://10.0.35.20/ixp/switch/add-by-snmp' + + preg_match( '/Cisco IOS XR Software \((.+ Series)\),\s+Version\s([0-9A-Za-z\(\)\.\[\]]+)\s+Copyright \(c\) [0-9]+ by Cisco Systems, Inc.*/', + $sysDescr, $matches ); + $this->setVendor( 'Cisco Systems' ); + $this->setModel( $matches[1] ); + $this->setOs( 'IOS XR' ); + $this->setOsVersion( isset( $matches[2] ) ? $matches[2] : '' ); + $this->setOsDate( null ); +} +else if( substr( $sysDescr, 0, 11 ) == 'Cisco NX-OS' ) { + + // Cisco NX-OS(tm) n9000, Software (n9000-dk9), Version 6.1(2)I2(2b), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 8/7/2014 15:00:00 + // Cisco NX-OS(tm) n3500, Software (n3500-uk9), Version 6.0(2)A1(1d), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 1/30/2014 9:00:00 + // Cisco NX-OS(tm) n3500, Software (n3500-uk9), Version 6.0(2)A6(3), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Compiled 7/1/2015 10:00:00 + // Cisco NX-OS(tm) n3500, Software (n3500-uk9), Version 6.0(2)A1(1d), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 1/30/2014 9:00:00 + + if( preg_match( '/^Cisco NX\-OS\(tm\) (n[\d+]+), Software \([a-zA-Z0-9\-]+\), Version ([a-zA-Z0-9\.\(\)]+), RELEASE SOFTWARE Copyright \(c\) (?:\d+)-(?:\d+) by Cisco Systems, Inc\.(?: Device Manager Version nms\.sro not found,)?\s+Compiled (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)$/', + $sysDescr, $matches ) ) + { + $this->setVendor( 'Cisco Systems' ); + $this->setModel( $matches[1] ); + $this->setOs( 'NX-OS' ); + $this->setOsVersion( isset( $matches[2] ) ? $matches[2] : '' ); + $d = new \DateTime( sprintf( "{$matches[5]}/%02d/%02d {$matches[6]}:{$matches[7]}:{$matches[8]} +0000", $matches[3], $matches[4] ) ); + $d->setTimezone( new \DateTimeZone( 'UTC' ) ); + $this->setOsDate( $d ); + } + + // Cisco NX-OS(tm) nxos.7.0.3.I2.3.bin, Software (nxos), Version 7.0(3)I2(3), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 3/19/2016 22:00:00 + else if( preg_match( '/^Cisco NX\-OS\(tm\) ([a-zA-Z0-9\.]+), Software \([a-zA-Z0-9\-]+\), Version ([a-zA-Z0-9\.\(\)]+), RELEASE SOFTWARE Copyright \(c\) (?:\d+)-(?:\d+) by Cisco Systems, Inc\.(?: Device Manager Version nms\.sro not found,)?\s+Compiled (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)$/', + $sysDescr, $matches ) ) + { + $this->setVendor( 'Cisco Systems' ); + $this->setModel( 'nXXXX' ); + $this->setOs( 'NX-OS' ); + $this->setOsVersion( isset( $matches[2] ) ? $matches[2] : '' ); + $d = new \DateTime( sprintf( "{$matches[5]}/%02d/%02d {$matches[6]}:{$matches[7]}:{$matches[8]} +0000", $matches[3], $matches[4] ) ); + $d->setTimezone( new \DateTimeZone( 'UTC' ) ); + $this->setOsDate( $d ); + } + +} diff --git a/OSS_SNMP/Platforms/vendor_cumulus.php b/OSS_SNMP/Platforms/vendor_cumulus.php new file mode 100644 index 000000000..33e563855 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_cumulus.php @@ -0,0 +1,55 @@ +setVendor( 'Cumulus Networks' ); + $this->setOs( 'Cumulus Linux' ); + $this->setOsDate( null ); + + // 'Cumulus Linux 3.4.0 (Linux Kernel 4.1.33-1+cl3u9)' + // 'Cumulus-Linux 4.2.0 (Linux Kernel 4.19.94-1+cl4u5)' + preg_match( '/Cumulus.Linux\s+([\d\.]+)\s+/', $sysDescr, $matches ); + $this->setOsVersion( $matches[1] ); + + // 'Edgecore x86_64-accton_as5812_54x-r0 5812-54X-O-AC-F Chassis' + // 'Mellanox x86_64-mlnx_x86-r0 MSN2100 Chassis' + preg_match( '/^(\S+)\s+.*\s+(\S+)\s+Chassis/', + $this->getSNMPHost()->get( '.1.3.6.1.2.1.47.1.1.1.1.2.1' ), $matches ); + + $this->setModel( $matches[1]." ".$matches[2] ); + + $this->setSerialNumber( $this->getSNMPHost()->get( '.1.3.6.1.2.1.47.1.1.1.1.11.1' ) ); +} diff --git a/OSS_SNMP/Platforms/vendor_dell_force10.php b/OSS_SNMP/Platforms/vendor_dell_force10.php index 3a8e7962e..066a7b1be 100644 --- a/OSS_SNMP/Platforms/vendor_dell_force10.php +++ b/OSS_SNMP/Platforms/vendor_dell_force10.php @@ -38,17 +38,19 @@ // // 'Dell Force10 OS Operating System Version: 1.0 Application Software Version: 8.3.12.1 Series: S4810 Copyright (c) 1999-2012 by Dell Inc. All Rights Reserved. Build Time: Sun Nov 18 11:05:15 2012' // 'Dell Force10 OS Operating System Version: 2.0 Application Software Version: 9.3(0.0) Series: S4810 Copyright (c) 1999-2014 by Dell Inc. All Rights Reserved. Build Time: Thu Jan 2 02:14:08 2014' +// 'Dell Networking OS Operating System Version: 2.0 Application Software Version: 9.10(0.1P3) Series: S4810 Copyright (c) 1999-2016 by Dell Inc. All Rights Reserved. Build Time: Tue Jun 14 15:00:23 2016' -if( substr( $sysDescr, 0, 12 ) == 'Dell Force10 ' ) +if( substr( $sysDescr, 0, 5 ) == 'Dell ' ) { - if( preg_match( '/^Dell Force10 OS Operating System Version: ([\d\.]+) Application Software Version:\s([0-9\(\)\.]+)\sSeries:\s([A-Z0-9]+)\sCopyright \(c\) \d+-\d+ by Dell Inc. All Rights Reserved. Build Time:\s[A-Za-z0-9]+\s(([a-zA-Z]+)\s(\d+)\s((\d\d):(\d\d):(\d\d))\s(\d+))$/', - $sysDescr, $matches ) ) + $sysDescr = preg_replace('/\R/',' ', $sysDescr ); + if( preg_match( '/^Dell (Force10|Networking) OS Operating System Version: ([\d\.]+) Application Software Version:\s([A-Z0-9\(\)\.]+)\sSeries:\s([A-Z0-9]+)\sCopyright \(c\) \d+-\d+ by Dell Inc. All Rights Reserved. Build Time:\s[A-Za-z0-9]+\s(([a-zA-Z]+)\s+(\d+)\s((\d\d):(\d\d):(\d\d))\s(\d+))$/', + $sysDescr, $matches ) ) { - $this->setVendor( 'Dell Force10' ); - $this->setModel( $matches[3] ); - $this->setOs( "FTOS {$matches[1]}" ); - $this->setOsVersion( $matches[2] ); - $this->setOsDate( new \DateTime( "{$matches[6]}/{$matches[5]}/{$matches[11]}:{$matches[7]} +0000" ) ); + $this->setVendor( "Dell {$matches[1]}" ); + $this->setModel( $matches[4] ); + $this->setOs( "FTOS {$matches[2]}" ); + $this->setOsVersion( $matches[3] ); + $this->setOsDate( new \DateTime( "{$matches[7]}/{$matches[6]}/{$matches[12]}:{$matches[8]} +0000" ) ); $this->getOsDate()->setTimezone( new \DateTimeZone( 'UTC' ) ); } diff --git a/OSS_SNMP/Platforms/vendor_extreme.php b/OSS_SNMP/Platforms/vendor_extreme.php index ad0d0027c..4ce2084a1 100644 --- a/OSS_SNMP/Platforms/vendor_extreme.php +++ b/OSS_SNMP/Platforms/vendor_extreme.php @@ -58,7 +58,11 @@ // the model is not included in the system description here so we need to pull it out of the entity MIB // this may need to be checked on a model by model basis. // Works for: - $this->setModel( $this->getSNMPHost()->get( '.1.3.6.1.2.1.47.1.1.1.1.2.1' ) ); + if( $this instanceof \OSS_SNMP\TestPlatform ) { + $this->setModel('PHPunit'); + } else { + $this->setModel($this->getSNMPHost()->get('.1.3.6.1.2.1.47.1.1.1.1.2.1')); + } } else if( substr( $sysDescr, 0, 12 ) == 'ExtremeXOS (' ) { @@ -82,7 +86,19 @@ } catch( Exception $e ) { $this->setSerialNumber( '(error)' ); } +} + +// 'Extreme BR-SLX9850-4 Router, SLX Operating System Version 18r.1.00a.' +if( substr( $sysDescr, 0, 10 ) == 'Extreme BR' ) +{ + $this->setVendor( 'Extreme Networks' ); + $this->setOs( 'SLX' ); + preg_match( '/^Extreme ([\w\-]+) Router, SLX Operating System Version ([\w.\-]+)\.$/', + $sysDescr, $matches ); -} + $this->setModel( $matches[1] ); + $this->setOsVersion( $matches[2] ); + $this->setOsDate( null ); +} diff --git a/OSS_SNMP/Platforms/vendor_fiberstore.php b/OSS_SNMP/Platforms/vendor_fiberstore.php new file mode 100644 index 000000000..6169103a5 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_fiberstore.php @@ -0,0 +1,55 @@ +setVendor( 'FiberStore' ); + $this->setOs( 'FSOS' ); + + preg_match( '/FSOS\s+software,\s+[\w]+\s+software\s+\(([\w\s]+)\),\s+Version\s+([\w.]+).*/', + $sysDescr, $matches ); + + $this->setModel( $matches[1] ); + $this->setOsVersion( $matches[2] ); + $this->setOsDate( null ); +} + diff --git a/OSS_SNMP/Platforms/vendor_h3c.php b/OSS_SNMP/Platforms/vendor_h3c.php new file mode 100644 index 000000000..5fb8e6a07 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_h3c.php @@ -0,0 +1,46 @@ +setVendor( 'H3C' ); + try { + $this->setModel( $this->getSNMPHost()->useEntity()->physicalName()[1] ); + } catch( \OSS_SNMP\Exception $e ) { + $this->setModel( 'Unknown' ); + } + $this->setOs( 'Comware' ); + $this->setOsVersion( $matches[2] ); + $this->setOsDate( null ); +} +else if( substr( $sysDescr, 0, 10 ) == 'H3C Switch' ) +{ + $sysDescr = trim( preg_replace( '/\s+/', ' ', $sysDescr ) ); + preg_match( '/H3C Switch (.+) Software Version (.+)Copyright/', + $sysDescr, $matches ); + + $this->setVendor( 'H3C' ); + $this->setModel( $matches[1] ); + $this->setOs( null ); + $this->setOsVersion( $matches[2] ); + $this->setOsDate( null ); +} +else if( substr( $sysDescr, 0, 29 ) == 'H3C Comware Platform Software' ) +{ + $sysDescr = trim( preg_replace( '/\s+/', ' ', $sysDescr ) ); + preg_match( '/H3C Comware Platform Software, Software Version (.+) H3C (.+)Copyright/', + $sysDescr, $matches ); + + $this->setVendor( 'H3C' ); + $this->setModel( $matches[2] ); + $this->setOs( 'Comware' ); + $this->setOsVersion( $matches[1] ); + $this->setOsDate( null ); +} diff --git a/OSS_SNMP/Platforms/vendor_hitachi_cable.php b/OSS_SNMP/Platforms/vendor_hitachi_cable.php new file mode 100644 index 000000000..f5feb8604 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_hitachi_cable.php @@ -0,0 +1,48 @@ +setVendor( $matches[1] ); + $this->setModel( $matches[2] ); + $this->setOs( 'hitachi os' ); + $this->setOsVersion( $matches[3] ); + + if( preg_match( '/Build date: (\d\d\d\d-\d\d-\d\d) (\d\d:\d\d:\d\d) ([A-Za-z]+)/', $sysDescr, $d ) ) + { + $this->setOsDate( new \DateTime( "{$d[1]} {$d[2]} +00:00") ); + $this->getOsDate()->setTimezone( new \DateTimeZone( $d[3] ) ); + } +} diff --git a/OSS_SNMP/Platforms/vendor_hp_procurve.php b/OSS_SNMP/Platforms/vendor_hp_procurve.php index 0ccae0457..62479e845 100644 --- a/OSS_SNMP/Platforms/vendor_hp_procurve.php +++ b/OSS_SNMP/Platforms/vendor_hp_procurve.php @@ -40,7 +40,7 @@ if( substr( $sysDescr, 0, 9 ) == 'ProCurve ' ) { - if( preg_match( '/ProCurve (\w+) Switch ([0-9]+), revision ([A-Z0-9\.]+), ROM [A-Z0-9\.]+ .*/', + if( preg_match( '/ProCurve (\w+) Switch (\w+).*, revision ([A-Z0-9\.]+), ROM ([A-Z0-9\.]+ .*)/', $sysDescr, $matches ) ) { $this->setVendor( 'Hewlett-Packard' ); diff --git a/OSS_SNMP/Platforms/vendor_huawei.php b/OSS_SNMP/Platforms/vendor_huawei.php new file mode 100644 index 000000000..a0557915b --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_huawei.php @@ -0,0 +1,80 @@ +setVendor( 'Huawei' ); + + switch( $sysObjectId ) + { + case '.1.3.6.1.4.1.2011.2.123': + $this->setModel( "MA5603T" ); + break; + case '.1.3.6.1.4.1.2011.2.169': + $this->setModel( "MA5616" ); + break; + case '.1.3.6.1.4.1.2011.2.80.8': + $this->setModel( "MA5600T" ); + break; + case '.1.3.6.1.4.1.2011.2.6.6.1': + $this->setModel( "MA5300V1" ); + break; + default: + $this->setModel( null ); + } + + $this->setOs( null ); + if( stripos( $sysDescr, 'Huawei Versatile Routing Platform Software' ) !== false ) { + $this->setOs( 'Huawei Versatile Routing Platform Software' ); + } + + // lose uptime + if( $pos = strpos( $sysDescr, 'uptime is') ) { + $sysDescr = substr( $sysDescr, 0, $pos ); + } + + $sysDescr = trim( $sysDescr ); + + $matches = []; + preg_match( '/^Huawei\s+.*[Vv]ersion\s+([\w.\d]+)\s+.*\s+([\w\-]+)$/is', $sysDescr, $matches ); + + if( isset( $matches[1] ) ) { + $this->setOsVersion( $matches[1] ); + } else if( $this instanceof \OSS_SNMP\TestPlatform ) { + $this->setOsVersion('PHPUnit'); + } else { + $this->setOsVersion($this->getSNMPHost()->useHuawei_System()->softwareVersion()); + } + + if( isset( $matches[2] ) ) { + $this->setModel($matches[2]); + } + + $this->setOsDate( null ); + +} + +// 'S6720-30C-EI-24S-AC Huawei Versatile Routing Platform Software VRP (R) software,Version 5.160 (S6720 V200R009C00SPC500) Copyright (C) 2007 Huawei Technologies Co., Ltd.' +// https://github.com/opensolutions/OSS_SNMP/issues/41 +// +// 'S6720-54C-EI-48S-AC Huawei Versatile Routing Platform Software VRP (R) software,Version 5.170 (S6720 V200R010C00SPC600) Copyright (C) 2007 Huawei Technologies Co., Ltd.' +// https://github.com/opensolutions/OSS_SNMP/issues/59 +else if( preg_match( '/^(S\d+\-[A-Z0-9\-]+)\s+Huawei Versatile Routing Platform Software\s+VRP \(R\) software,Version ([0-9\.]+) \((S[0-9]+) [A-Z0-9]+\)\s+Copyright \(C\) 2007 Huawei Technologies.*$/', + $sysDescr, $matches ) ) { + + $this->setVendor( 'Huawei' ); + $this->setModel( $matches[1] ); + $this->setOs( 'Huawei Versatile Routing Platform Software VRP' ); + $this->setOsVersion( $matches[2] ); + $this->setOsDate( null ); +} diff --git a/OSS_SNMP/Platforms/vendor_ignitenet.php b/OSS_SNMP/Platforms/vendor_ignitenet.php new file mode 100644 index 000000000..b76097052 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_ignitenet.php @@ -0,0 +1,13 @@ +setVendor( 'IgniteNet' ); + $this->setModel( "FNS-SFP-24" ); + $this->setOs( null ); + $this->setOsVersion( null ); + $this->setOsDate( null ); +} diff --git a/OSS_SNMP/Platforms/vendor_juniper.php b/OSS_SNMP/Platforms/vendor_juniper.php index 3ebd32df7..9d5be364f 100644 --- a/OSS_SNMP/Platforms/vendor_juniper.php +++ b/OSS_SNMP/Platforms/vendor_juniper.php @@ -32,18 +32,29 @@ // Sample sysDescr: // "Juniper Networks, Inc. ex4500-40f Ethernet Switch, kernel JUNOS 12.3R3.4, Build date: 2013-06-14 01:37:19 UTC Copyright (c) 1996-2013 Juniper Networks, Inc." -if( substr( $sysDescr, 0, 22 ) == 'Juniper Networks, Inc.' ) +if( substr( $sysDescr, 0, 16 ) == 'Juniper Networks' ) { - preg_match( '/(Juniper Networks), Inc. ([^\s]+) .* kernel ([^\s]+) ([^\s,]+)/', $sysDescr, $matches ); - $this->setVendor( $matches[1] ); - $this->setModel( $matches[2] ); - $this->setOs( $matches[3] ); - $this->setOsVersion( $matches[4] ); - - if( preg_match( '/Build date: (\d\d\d\d-\d\d-\d\d) (\d\d:\d\d:\d\d) ([A-Za-z]+)/', $sysDescr, $d ) ) - { - $this->setOsDate( new \DateTime( "{$d[1]} {$d[2]} +00:00") ); - $this->getOsDate()->setTimezone( new \DateTimeZone( $d[3] ) ); + if( preg_match( '/(Juniper Networks), Inc. ([^\s]+) .* kernel ([^\s]+) ([^\s,]+)/', $sysDescr, $matches ) ) { + $this->setVendor($matches[1]); + $this->setModel($matches[2]); + $this->setOs($matches[3]); + $this->setOsVersion($matches[4]); + + if (preg_match('/Build date: (\d\d\d\d-\d\d-\d\d) (\d\d:\d\d:\d\d) ([A-Za-z]+)/', $sysDescr, $d)) { + $this->setOsDate(new \DateTime("{$d[1]} {$d[2]} +00:00")); + $this->getOsDate()->setTimezone(new \DateTimeZone($d[3])); + } + } + + // 'Juniper Networks EX3400 Ethernet Switch , Junos OS Release 15.1X53-D5x EX series' + else if( preg_match( '/(Juniper Networks) (\w+) Ethernet Switch .* Release ([\w\-.]+) EX series/', $sysDescr, $matches ) ) { + $this->setVendor($matches[1]); + $this->setModel($matches[2]); + $this->setOs('JUNOS'); + $this->setOsVersion($matches[3]); + $this->setOsDate(null); + } + } diff --git a/OSS_SNMP/Platforms/vendor_quanta.php b/OSS_SNMP/Platforms/vendor_quanta.php new file mode 100644 index 000000000..d516f19f7 --- /dev/null +++ b/OSS_SNMP/Platforms/vendor_quanta.php @@ -0,0 +1,51 @@ +setVendor( 'Quanta' ); + $this->setModel( "Quanta" ); + $this->setOs( 'VxWorks' ); + $this->setOsVersion( null ); + $this->setOsDate( null ); + + try { + $this->setSerialNumber( $this->getSNMPHost()->get( '.1.3.6.1.2.1.47.1.1.1.1.11.1' ) ); + } catch( Exception $e ) { + $this->setSerialNumber( '(error)' ); + } +} diff --git a/OSS_SNMP/SNMP.php b/OSS_SNMP/SNMP.php index fcb1eb5de..f6bd13fb4 100644 --- a/OSS_SNMP/SNMP.php +++ b/OSS_SNMP/SNMP.php @@ -1,7 +1,6 @@ _dummy = true; + } else { + + // make sure SNMP is installed! + if( !function_exists( 'snmp2_get' ) ) { + die( "It looks like the PHP SNMP package is not installed. This is required!\n" ); + } + + $this->setOidOutputFormat( self::OID_OUTPUT_NUMERIC ); + + } + return $this->setHost( $host ) ->setCommunity( $community ) ->setVersion( $version) @@ -202,8 +231,7 @@ public function __construct( $host = '127.0.0.1', $community = 'public' , $versi ->setAuthProtocol( $authprotocol ) ->setAuthPassphrase( $authpassphrase ) ->setPrivProtocol( $privprotocol ) - ->setPrivPassphrase( $privpassphrase ) - ->setOidOutputFormat( self::OID_OUTPUT_NUMERIC ); + ->setPrivPassphrase( $privpassphrase ); } @@ -215,13 +243,12 @@ public function __construct( $host = '127.0.0.1', $community = 'public' , $versi */ public function realWalk( $oid ) { - $v1='snmprealwalk'; - $v2c='snmp2_real_walk'; - switch( $this->getVersion() ) { case 1: + return $this->_lastResult = @snmprealwalk( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); + break; case '2c': - return $this->_lastResult = @${"v".$this->getVersion()}( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); + return $this->_lastResult = @snmp2_real_walk( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); break; case '3': return $this->_lastResult = @snmp3_real_walk( $this->getHost(), $this->getSecName(), $this->getSecLevel(), @@ -247,13 +274,12 @@ public function get( $oid ) if( $this->cache() && ( $rtn = $this->getCache()->load( $oid ) ) !== null ) return $rtn; - $v1='snmpget'; - $v2c='snmp2_get'; - switch( $this->getVersion() ) { case 1: + $this->_lastResult = @snmpget( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); + break; case '2c': - $this->_lastResult = @${"v".$this->getVersion()}( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); + $this->_lastResult = @snmp2_get( $this->getHost(), $this->getCommunity(), $oid, $this->getTimeout(), $this->getRetry() ); break; case '3': $this->_lastResult = @snmp3_get( $this->getHost(), $this->getSecName(), $this->getSecLevel(), @@ -341,12 +367,28 @@ public function walk1d( $oid ) * 10105 => Hex-STRING: 00 00 00 01 * 10108 => Hex-STRING: 00 00 00 01 * + * subOidWalk( '.1.3.6.1.2.1.17.4.3.1.1', 15, -1 ) + * + * .1.3.6.1.2.1.17.4.3.1.1.0.0.136.54.152.12 = Hex-STRING: 00 00 75 33 4E 92 + * .1.3.6.1.2.1.17.4.3.1.1.8.3.134.58.182.16 = Hex-STRING: 00 00 75 33 4E 93 + * .1.3.6.1.2.1.17.4.3.1.1.0.4.121.22.55.8 = Hex-STRING: 00 00 75 33 4E 94 + * + * would yield an array: + * [54.152.12] => Hex-STRING: 00 00 75 33 4E 92 + * [58.182.16] => Hex-STRING: 00 00 75 33 4E 93 + * [22.55.8] => Hex-STRING: 00 00 75 33 4E 94 + * * @throws \OSS_SNMP\Exception On *any* SNMP error, warnings are supressed and a generic exception is thrown * @param string $oid The OID to walk * @param int $position The position of the OID to use as the key + * @param int $elements Number of additional elements to include in the returned array keys after $position. + * This defaults to 1 meaning just the requested OID element (see examples above). + * With -1, retrieves ALL to the end. + * If there is less elements than $elements, return all availables (no error). + * * @return array The resultant values */ - public function subOidWalk( $oid, $position ) + public function subOidWalk( $oid, $position, $elements = 1) { if( $this->cache() && ( $rtn = $this->getCache()->load( $oid ) ) !== null ) return $rtn; @@ -362,7 +404,12 @@ public function subOidWalk( $oid, $position ) { $oids = explode( '.', $_oid ); - $result[ $oids[ $position] ] = $this->parseSnmpValue( $value ); + $index = $oids[ $position]; + for( $pos = $position + 1; $pos < sizeof($oids) && ( $elements == -1 || $pos < $position+$elements ); $pos++ ) { + $index .= '.' . $oids[ $pos ]; + } + + $result[ $index ] = $this->parseSnmpValue( $value ); } return $this->getCache()->save( $oid, $result ); @@ -438,7 +485,7 @@ public function parseSnmpValue( $v ) { case 'STRING': if( substr( $value, 0, 1 ) == '"' ) - $rtn = (string)trim( substr( substr( $value, 1 ), 0, -1 ) ); + $rtn = (string)substr( substr( $value, 1 ), 0, -1 ); else $rtn = (string)$value; break; @@ -451,7 +498,7 @@ public function parseSnmpValue( $v ) $rtn = (int)substr( $value, $m[0][1] ); }else{ $rtn = (int)$value; - } + } break; case 'Counter32': @@ -497,11 +544,13 @@ public function parseSnmpValue( $v ) */ public static function ppTruthValue( $value ) { - if( is_array( $value ) ) - foreach( $value as $k => $v ) - $value[$k] = self::$SNMP_TRUTHVALUES[ $v ]; - else - $value = self::$SNMP_TRUTHVALUES[ $value ]; + if( is_array( $value ) ) { + foreach( $value as $k => $v ) { + $value[$k] = isset(self::$SNMP_TRUTHVALUES[$v]) ? self::$SNMP_TRUTHVALUES[$v] : false; + } + } else { + $value = isset(self::$SNMP_TRUTHVALUES[$value]) ? self::$SNMP_TRUTHVALUES[$value] : false; + } return $value; } @@ -514,24 +563,24 @@ public static function ppTruthValue( $value ) * * @see ppHexStringFlags() */ - public static $HEX_STRING_WORDS_AS_ARRAY = array( - '0' => array( false, false, false, false ), - '1' => array( false, false, false, true ), - '2' => array( false, false, true, false ), - '3' => array( false, false, true, true ), - '4' => array( false, true, false, false ), - '5' => array( false, true, false, true ), - '6' => array( false, true, true, false ), - '7' => array( false, true, true, true ), - '8' => array( true, false, false, false ), - '9' => array( true, false, false, true ), - 'a' => array( true, false, true, false ), - 'b' => array( true, false, true, true ), - 'c' => array( true, true, false, false ), - 'd' => array( true, true, false, true ), - 'e' => array( true, true, true, false ), - 'f' => array( true, true, true, true ), - ); + public static $HEX_STRING_WORDS_AS_ARRAY = [ + '0' => [ false, false, false, false ], + '1' => [ false, false, false, true ], + '2' => [ false, false, true, false ], + '3' => [ false, false, true, true ], + '4' => [ false, true, false, false ], + '5' => [ false, true, false, true ], + '6' => [ false, true, true, false ], + '7' => [ false, true, true, true ], + '8' => [ true, false, false, false ], + '9' => [ true, false, false, true ], + 'a' => [ true, false, true, false ], + 'b' => [ true, false, true, true ], + 'c' => [ true, true, false, false ], + 'd' => [ true, true, false, true ], + 'e' => [ true, true, true, false ], + 'f' => [ true, true, true, true ], + ]; /** * Takes a HEX-String of true / false - on / off - set / unset flags @@ -554,7 +603,7 @@ public static function ppHexStringFlags( $str ) { $str = strtolower( $str ); // ensure all hex digits are lower case - $values = array ( 0 => 'dummy' ); + $values = [ 0 => 'dummy' ]; for( $i = 0; $i < strlen( $str ); $i++ ) $values = array_merge( $values, self::$HEX_STRING_WORDS_AS_ARRAY[ $str[$i] ] ); @@ -698,6 +747,7 @@ public function getVersion() return $this->_version; } + /** * Sets the target host for SNMP queries. * @@ -706,7 +756,12 @@ public function getVersion() */ public function setHost( $h ) { - $this->_host = $h; + // need to be careful with IPv6 addresses + if( strpos( $h, ':' ) !== false || $this->getForceIPv6() ) { + $this->_host = '[' . $h . ']'; + } else { + $this->_host = $h; + } // clear the temporary result cache and last result $this->_lastResult = null; @@ -726,6 +781,28 @@ public function getHost() return $this->_host; } + /** + * Forces use of IPv6 + * + * @param bool $b Set to true to force IPv4, false for default behavior + * @return \OSS_SNMP\SNMP An instance of $this (for fluent interfaces) + */ + public function setForceIPv6( $b ) + { + $this->_forceIPv6 = $b; + return $this; + } + + /** + * Is IPv6 forced? + * + * @return bool True to force IPv4, false for default behavior + */ + public function getForceIPv6() + { + return $this->_forceIPv6; + } + /** * Sets the community string to use for SNMP queries. * @@ -923,4 +1000,87 @@ public function getPlatform() return $this->_platform; } + + /** + * Get indexed SNMP values where the array key is spread over a number of OID positions + * + * @throws \OSS_SNMP\Exception On *any* SNMP error, warnings are supressed and a generic exception is thrown + * @param string $oid The OID to walk + * @param int $positionS The start position of the OID to use as the key + * @param int $positionE The end position of the OID to use as the key + * @return array The resultant values + */ + public function subOidWalkLong( $oid, $positionS, $positionE ) + { + if( $this->cache() && ( $rtn = $this->getCache()->load( $oid ) ) !== null ) + return $rtn; + + $this->_lastResult = $this->realWalk( $oid ); + + if( $this->_lastResult === false ) + throw new Exception( 'Could not perform walk for OID ' . $oid ); + + $result = array(); + + foreach( $this->_lastResult as $_oid => $value ) + { + $oids = explode( '.', $_oid ); + + $oidKey = ''; + for($i = $positionS; $i <= $positionE; $i++) + { + $oidKey .= $oids[$i] .'.'; + } + + $result[ $oidKey ] = $this->parseSnmpValue( $value ); + } + + return $this->getCache()->save( $oid, $result ); + } + + /** + * Set the value of an SNMP object + * + * @param string $oid The OID to set + * @param string $type The MIB defines the type of each object id + * @param mixed $value The new value + * @return boolean + */ + public function set($oid, $type, $value) + { + switch( $this->getVersion() ) { + case 1: + $this->_lastResult = @snmpset( $this->getHost(), $this->getCommunity(), $oid, $type, $value, $this->getTimeout(), $this->getRetry() ); + break; + case '2c': + $this->_lastResult = @snmp2_set( $this->getHost(), $this->getCommunity(), $oid, $type, $value, $this->getTimeout(), $this->getRetry() ); + break; + case '3': + $this->_lastResult = @snmp3_set( $this->getHost(), $this->getSecName(), $this->getSecLevel(), + $this->getAuthProtocol(), $this->getAuthPassphrase(), $this->getPrivProtocol(), $this->getPrivPassphrase(), + $oid, $type, $value, $this->getTimeout(), $this->getRetry() + ); + break; + default: + throw new Exception( 'Invalid SNMP version: ' . $this->getVersion() ); + } + + if( $this->_lastResult === false ) + throw new Exception( 'Could not add variable ' . $value . ' for OID ' . $oid ); + + $this->getCache()->clear( $oid ); + + return $this->_lastResult; + } + + + /** + * Indicate if we are in dummy mode or not + * @return bool + */ + public function iAmADummy() + { + return $this->_dummy === true; + } + } diff --git a/OSS_SNMP/TestPlatform.php b/OSS_SNMP/TestPlatform.php new file mode 100644 index 000000000..6a83d7b98 --- /dev/null +++ b/OSS_SNMP/TestPlatform.php @@ -0,0 +1,322 @@ + + */ +class TestPlatform +{ + /** + * The platform vendor + * + * @var string The platform vendor + */ + protected $_vendor = 'Unknown'; + + /** + * The platform model + * + * @var string The platform model + */ + protected $_model = 'Unknown'; + + /** + * The platform operating system + * + * @var string The platform operating system + */ + protected $_os = 'Unknown'; + + /** + * The platform operating system version + * + * @var string The platform operating system version + */ + protected $_osver = 'Unknown'; + + /** + * The platform operating system (compile) date + * + * @var string The platform operating system (compile) date + */ + protected $_osdate = null; + + /** + * The platform serial number + * + * @var string The platform serial number + */ + protected $_serial = null; + + /** + * The system description + * + * @var string The system description + */ + protected $_sysDesc; + + /** + * The system object ID + * + * @var string The system object ID + */ + protected $_sysObjId; + + + /** + * The constructor. + * + * @param SNMP $snmpHost The SNMP Host object + * @return Platform An instance of $this (for fluent interfaces) + */ + public function __construct( $sysDesc, $sysObjId = '' ) + { + $this->setSysDesc( $sysDesc ); + $this->setSysObjId( $sysObjId ); + + $this->parse(); + + return $this; + } + + + + public function parse() + { + // query the platform for it's description and parse it for details + + $sysDescr = $this->getSysDesc(); + $sysObjectId = $this->getSysObjId(); + + // there's possibly a better way to do this...? + foreach( glob( __DIR__ . '/Platforms/vendor_*.php' ) as $f ) + include( $f ); + } + + /** + * Set the system description + * + * @param string $s The system desc + * @return TestPlatform For fluent interfaces + */ + public function setSysDesc( $s ) + { + $this->_sysDesc = $s; + return $this; + } + + /** + * Get the system description + * + * @return string The system description + */ + public function getSysDesc() + { + return $this->_sysDesc; + } + + /** + * Set the system obj ID + * + * @param string $s The system obj ID + * @return TestPlatform For fluent interfaces + */ + public function setSysObjId( $s ) + { + $this->_sysObjId = $s; + return $this; + } + + /** + * Get the system obj ID + * + * @return string The system obj ID + */ + public function getSysObjId() + { + return $this->_sysObjId; + } + + /** + * Get the SNMPHost object + * + * @return \OSS_SNMP\SNMP The SNMP object + */ + public function getSNMPHost() + { + return $this->_snmpHost; + } + + /** + * Set vendor + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setVendor( $s ) + { + $this->_vendor = $s; + return $this; + } + + /** + * Set model + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setModel( $s ) + { + $this->_model = $s; + return $this; + } + + /** + * Set operating system + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setOs( $s ) + { + $this->_os = $s; + return $this; + } + + /** + * Set OS version + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setOsVersion( $s ) + { + $this->_osver = $s; + return $this; + } + + /** + * Set OS date + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setOsDate( $s ) + { + $this->_osdate = $s; + return $this; + } + + /** + * Set the serial number + * + * @param string $s + * @return \OSS_SNMP\Platform For fluent interfaces + */ + public function setSerialNumber( $s ) + { + $this->_serial = $s; + return $this; + } + + /** + * Get vendor + * + * @return string + */ + public function getVendor() + { + return $this->_vendor; + } + + /** + * Get model + * + * @return string + */ + public function getModel() + { + return $this->_model; + } + + /** + * Get operating system + * + * @return string + */ + public function getOs() + { + return $this->_os; + } + + /** + * Get OS version + * + * @return string + */ + public function getOsVersion() + { + return $this->_osver; + } + + /** + * Get OS date + * + * return \DateTime + */ + public function getOsDate() + { + return $this->_osdate; + } + + /** + * Get the serial number + * + * return string + */ + public function getSerialNumber() + { + return $this->_serial; + } + +}