diff --git a/LibreNMS/OS/EltexMes23xx.php b/LibreNMS/OS/EltexMes23xx.php new file mode 100644 index 0000000000..85c12309a1 --- /dev/null +++ b/LibreNMS/OS/EltexMes23xx.php @@ -0,0 +1,40 @@ +. + * + * @link https://www.librenms.org + * + * @copyright 2022 PipoCanaja + * @author PipoCanaja + */ + +namespace LibreNMS\OS; + +use LibreNMS\OS; + +class EltexMes23xx extends OS +{ + /** + * Specific HexToString for Eltex + */ + public function normData(string $par = ''): string + { + $tmp = str_replace([':', ' '], '', trim(strtoupper($par))); + $ret = preg_match('/^[0-9A-F]+$/', $tmp) ? hex2str($tmp) : $par; //if string is pure hex, convert to ascii + + return $ret; + } +} diff --git a/includes/discovery/entity-physical/eltex-mes23xx.inc.php b/includes/discovery/entity-physical/eltex-mes23xx.inc.php index 1e69d1ab7d..fd44781a5d 100644 --- a/includes/discovery/entity-physical/eltex-mes23xx.inc.php +++ b/includes/discovery/entity-physical/eltex-mes23xx.inc.php @@ -29,14 +29,6 @@ $trans = snmpwalk_cache_multi_oid($device, 'eltPhdTransceiverInfoEntry', [], 'EL echo ' entAliasMappingIdentifier'; $mapping = snmpwalk_cache_multi_oid($device, 'entAliasMappingIdentifier', [], 'ENTITY-MIB:IF-MIB'); -function normData($par = null) -{ - $tmp = str_replace([':', ' '], '', trim(strtoupper($par))); - $ret = preg_match('/^[0-9A-F]+$/', $tmp) ? hex2str($tmp) : $par; //if string is pure hex, convert to ascii - - return $ret; -} - foreach ($trans as $index => $data) { unset($connectedto); foreach ($mapping as $ekey => $edata) { @@ -50,11 +42,11 @@ foreach ($trans as $index => $data) { 'entPhysicalDescr' => $data['eltPhdTransceiverInfoType'], 'entPhysicalClass' => 'sfp-cage', 'entPhysicalName' => strtoupper($data['eltPhdTransceiverInfoConnectorType']), - 'entPhysicalModelName' => normData($data['eltPhdTransceiverInfoPartNumber']), + 'entPhysicalModelName' => \LibreNMS\OS\EltexMes23xx::normData($data['eltPhdTransceiverInfoPartNumber']), 'entPhysicalSerialNum' => $data['eltPhdTransceiverInfoSerialNumber'], 'entPhysicalContainedIn' => $connectedto, 'entPhysicalMfgName' => $data['eltPhdTransceiverInfoVendorName'], - 'entPhysicalHardwareRev' => normData($data['eltPhdTransceiverInfoVendorRev']), + 'entPhysicalHardwareRev' => \LibreNMS\OS\EltexMes23xx::normData($data['eltPhdTransceiverInfoVendorRev']), 'entPhysicalIsFRU' => 'true', ]; }