Neil Lathwood 42e5819130 refactor: Updated discovery/poller to use numeric sysObjectID (#7922)
* refactor: Updated discovery to use a core module for sysDescr/sysObjectID use

* final update hopefully

* revert changes

* more changes + docs

* migrated poller to use numerical sysObjectID

* more updates for sysObjectID

* update any alert rules which might have enterprises. in

* moved schema file

* small updates

* updated getHostOS()

* scrut fixes

* updated sysObjectId -> sysObjectID

* updated sysObjectId -> sysObjectID

* updated remainder of sysObjectId -> sysObjectID

* another sysObjectId -> sysObjectID

* fixed secureplatform test data

* Fix tests: $device is not pulled from the database before polling
Also, update the db in the core discovery module.
2018-01-06 23:00:47 -06:00

52 lines
1.5 KiB
PHP

<?php
use LibreNMS\RRD\RrdDefinition;
list($hardware, $version, ) = explode(',', str_replace(', ', ',', $device['sysDescr']));
// Clean up hardware
$hardware = str_replace('PROCURVE', 'ProCurve', $hardware);
if (substr($hardware, 0, 3) == 'HP ') {
$hardware = substr($hardware, 3);
}
if (substr($hardware, 0, 24) == 'Hewlett-Packard Company ') {
$hardware = substr($hardware, 24);
}
$altversion = trim(snmp_get($device, 'hpSwitchOsVersion.0', '-Oqv', 'NETSWITCH-MIB'), '"');
if ($altversion) {
$version = $altversion;
}
$altversion = trim(snmp_get($device, '.1.3.6.1.4.1.11.2.3.7.11.12.1.2.1.11.0', '-Oqv'), '"');
if ($altversion) {
$version = $altversion;
}
if (preg_match('/^PROCURVE (.*) - (.*)/', $device['sysDescr'], $regexp_result)) {
$hardware = 'ProCurve '.$regexp_result[1];
$version = $regexp_result[2];
}
$serial = snmp_get($device, '.1.3.6.1.4.1.11.2.36.1.1.2.9.0', '-Oqv', 'SEMI-MIB');
$serial = trim(str_replace('"', '', $serial));
// FIXME maybe genericise? or do away with it if we ever walk the full dot1qTpFdbTable as we can count ourselves then ;)
$FdbAddressCount = snmp_get($device, 'hpSwitchFdbAddressCount.0', '-Ovqn', 'STATISTICS-MIB');
if (is_numeric($FdbAddressCount)) {
$rrd_def = RrdDefinition::make()->addDataset('value', 'GAUGE', -1, 100000);
$fields = array(
'value' => $FdbAddressCount,
);
$tags = compact('rrd_def');
data_update($device, 'fdb_count', $tags, $fields);
$graphs['fdb_count'] = true;
echo 'FDB Count ';
}