fix: Allow line returns in snmprec files with the 4x data type (#6443)

* fix: Allow line returns in snmprec files with the 4x data type
Fill in IOS data files
IOS-XE discovery fails, fix that

* Restore IOS-XE, unsure if it can be removed
This commit is contained in:
Tony Murray 2017-04-18 16:28:48 -05:00 committed by Neil Lathwood
parent c88c677a16
commit 963f444f17
10 changed files with 20 additions and 11 deletions

View File

@ -524,6 +524,7 @@ List of SNMP data types:
| Type | Value |
| ----------------- | ------------- |
| OCTET STRING | 4 |
| HEX STRING | 4x |
| Integer32 | 2 |
| NULL | 5 |
| OBJECT IDENTIFIER | 6 |
@ -534,5 +535,7 @@ List of SNMP data types:
| Opaque | 68 |
| Counter64 | 70 |
Hex encoded strings (4x) should be used for any strings that contain line returns
You can run `./scripts/pre-commit.php -u` to run the unit tests to check your code.
If you would like to run tests locally against a full snmpsim instance, run `./scripts/pre-commit.php -u --snmpsim`.

View File

@ -35,4 +35,4 @@ register_mibs:
discovery:
- sysDescr:
- IOS-XE
- X86_64_LINUX_IOSD
- LINUX_IOSD

View File

@ -37,7 +37,8 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase
private function checkOS($expected_os, $filename = null)
{
$community = $filename ?: $expected_os;
global $debug;
$debug = true;
ob_start();
$os = getHostOS($this->genDevice($community));
$output = ob_get_contents();

View File

@ -43,10 +43,12 @@ function cache_snmprec($file)
$line = strtok($data, "\r\n");
while ($line !== false) {
list($oid, $type, $data) = explode('|', $line, 3);
if ($type == 4) {
if ($type == '4') {
$data = trim($data);
} elseif ($type == 6) {
} elseif ($type == '6') {
$data = trim($data, '.');
} elseif ($type == '4x') {
$data = hex2str($data);
}
$snmpMockCache[$file][$oid] = array($type, $data);

View File

@ -1 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco IOS Software, 3800 Software (C3825-ADVIPSERVICESK9-M), Version 12.4(22)T5, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Wed 28-Apr-10 11:30 by prod_rel_team
1.3.6.1.2.1.1.1.0|4x|436973636f20494f5320536f6674776172652c203338303020536f667477617265202843333832352d414456495053455256494345534b392d4d292c2056657273696f6e2031352e312834294d31302c2052454c4541534520534f4654574152452028666332290d0a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230313520627920436973636f2053797374656d732c20496e632e0d0a436f6d70696c6564205475652032342d4d61722d31352030393a35302062792070726f645f72656c5f7465616d
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.543

View File

@ -1,2 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA14, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by cisco Systems, Inc. Compiled Tue 26-O
1.3.6.1.2.1.1.1.0|4x|436973636f20496e7465726e6574776f726b204f7065726174696e672053797374656d20536f667477617265200d0a494f532028746d2920433239353020536f667477617265202843323935302d49364b324c3251342d4d292c2056657273696f6e2031322e3128323229454131342c2052454c4541534520534f4654574152452028666331290d0a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230313020627920636973636f2053797374656d732c20496e632e0d0a436f6d70696c6564205475652032362d4f
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.359

View File

@ -1,2 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA14, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by cisco Systems, Inc. Compiled Tue 26-O
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.429
1.3.6.1.2.1.1.1.0|4x|436973636f20494f5320536f6674776172652c20433337353020536f667477617265202843333735302d4950424153452d4d292c2056657273696f6e2031322e32283530295345332c2052454c4541534520534f4654574152452028666331290d0a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230303920627920436973636f2053797374656d732c20496e632e0d0a436f6d70696c6564205765642032322d4a756c2d30392030363a31392062792070726f645f72656c5f7465616d
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.516

View File

@ -1 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco IOS Software, ASR1000 Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.5(3)S, RELEASE SOFTWARE (fc6) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Thu 01-Aug-13 03:38 by mcpre
1.3.6.1.2.1.1.1.0|4x|436973636f20494f5320536f6674776172652c2049535220536f66747761726520285838365f36345f4c494e55585f494f53442d554e4956455253414c4b392d4d292c2056657273696f6e2031352e3428332953322c2052454c4541534520534f4654574152452028666333290d0a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230313520627920436973636f2053797374656d732c20496e632e0d0a436f6d70696c6564204672692033302d4a616e2d31352031353a3139206279206d63707265
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.2093

View File

@ -1 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-ADVENTERPRISEK9-M), Version 15.1(3)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 21:59 by mcpre
1.3.6.1.2.1.1.1.0|4x|436973636f20494f5320536f6674776172652c204153523130303020536f66747761726520285050435f4c494e55585f494f53442d414456454e54455250524953454b392d4d292c2056657273696f6e2031352e352833295331612c2052454c4541534520534f4654574152452028666331290d0a546563686e6963616c20537570706f72743a20687474703a2f2f7777772e636973636f2e636f6d2f74656368737570706f72740d0a436f707972696768742028632920313938362d3230313520627920436973636f2053797374656d732c20496e632e0d0a436f6d70696c6564205765642030342d4e6f762d31352031373a3430206279206d63707265
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.1116

View File

@ -1,2 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Cisco IOS XR Software (Cisco ASR9K Series), Version 5.3.4[Default] Copyright (c) 2016 by Cisco Systems, Inc.
1.3.6.1.2.1.1.1.0|4x|436973636f20494f5320585220536f6674776172652028436973636f20415352394b20536572696573292c202056657273696f6e20352e332e345b44656661756c745d0d0a436f7079726967687420286329203230313720627920436973636f2053797374656d732c20496e632e
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.1018