newdevice: detect more devices as Comware (#6386)

* newdevice: improve comware detection
Only some H3C Comware devices were detected as comware, detect them all.

* Update the test data

FYI, C1234 was just a nonsense string
This commit is contained in:
Tony Murray
2017-04-13 04:52:07 -05:00
committed by Neil Lathwood
parent d44d23dba6
commit e005f78211
7 changed files with 31 additions and 9 deletions

View File

@@ -5,6 +5,4 @@ icon: hpe
over: over:
- { graph: device_bits, text: Traffic } - { graph: device_bits, text: Traffic }
discovery: discovery:
- sysObjectId: .1.3.6.1.4.1.25506.11.1 - sysObjectId: .1.3.6.1.4.1.25506.
- sysDescr: Comware
- sysDescr_regex: '/HP [a-zA-Z0-9- ]+ Switch Software Version/'

View File

@@ -319,7 +319,13 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
log_event('Sensor Warn Low Limit Updated: ' . mres($class) . ' ' . mres($type) . ' ' . mres($index) . ' ' . mres($descr) . ' (' . $low_warn_limit . ')', $device, 'sensor', 3, $sensor_id); log_event('Sensor Warn Low Limit Updated: ' . mres($class) . ' ' . mres($type) . ' ' . mres($index) . ' ' . mres($descr) . ' (' . $low_warn_limit . ')', $device, 'sensor', 3, $sensor_id);
} }
if ($oid == $sensor_entry['sensor_oid'] && $descr == $sensor_entry['sensor_descr'] && $multiplier == $sensor_entry['sensor_multiplier'] && $divisor == $sensor_entry['sensor_divisor'] && $entPhysicalIndex_measured == $sensor_entry['entPhysicalIndex_measured'] && $entPhysicalIndex == $sensor_entry['entPhysicalIndex']) { if ($oid == $sensor_entry['sensor_oid'] &&
$descr == $sensor_entry['sensor_descr'] &&
$multiplier == $sensor_entry['sensor_multiplier'] &&
$divisor == $sensor_entry['sensor_divisor'] &&
$entPhysicalIndex_measured == $sensor_entry['entPhysicalIndex_measured'] &&
$entPhysicalIndex == $sensor_entry['entPhysicalIndex']
) {
echo '.'; echo '.';
} else { } else {
$update = array( $update = array(

View File

@@ -21,7 +21,24 @@ if (!empty($entphydata)) {
foreach ($tempdata as $tempindex => $value) { foreach ($tempdata as $tempindex => $value) {
if ($index['entPhysicalIndex'] == $tempindex && $value['hh3cEntityExtTemperature'] != 65535) { if ($index['entPhysicalIndex'] == $tempindex && $value['hh3cEntityExtTemperature'] != 65535) {
$cur_oid = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.12.'; $cur_oid = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.12.';
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid . $tempindex, 'temp-' . $tempindex, 'comware', $index['entPhysicalName'], '1', '1', null, null, null, null, $value['hh3cEntityExtTemperature'], 'snmp', $index); discover_sensor(
$valid['sensor'],
'temperature',
$device,
$cur_oid . $tempindex,
'temp-' . $tempindex,
'comware',
$index['entPhysicalName'],
'1',
'1',
null,
null,
null,
null,
$value['hh3cEntityExtTemperature'],
'snmp',
$index
);
} }
} }
} }

View File

@@ -467,7 +467,7 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase
{ {
$this->checkOS('comware'); $this->checkOS('comware');
$this->checkOS('comware', 'comware1'); $this->checkOS('comware', 'comware1');
$this->checkOS('comware', 'comware-hp-c1234'); $this->checkOS('comware', 'comware-h3c');
} }
public function testCoriant() public function testCoriant()

View File

@@ -0,0 +1,2 @@
1.3.6.1.2.1.1.1.0|4|HP V1910-48G Switch Software Version 5.20 Release 1111P01
1.3.6.1.2.1.1.2.0|6|.1.3.6.1.4.1.25506.11.1.85

View File

@@ -1 +0,0 @@
1.3.6.1.2.1.1.1.0|4|HP C1234 Switch Software Version

View File

@@ -1,2 +1,2 @@
1.3.6.1.2.1.1.1.0|4|HPE V1910-24G Switch Software Version 5.20, Release 1516 Copyright(c) 2010-2015 Hewlett-Packard Development Company, L.P. 1.3.6.1.2.1.1.1.0|4|Hangzhou H3C Comware Platform Software, Software Version 3.10, Release 2211P06
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.25506.11.1.82 1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.25506.1.244