mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
improve callback serial number regex (#6435)
Adds S/N and Serial Num/number
This commit is contained in:
committed by
Neil Lathwood
parent
924b751be4
commit
2f881e3d80
@@ -85,19 +85,16 @@ if ($enabled == 1) {
|
||||
}, $entry['sysDescr']);
|
||||
|
||||
// wipe serial numbers, preserve the format
|
||||
$entry['sysDescr'] = preg_replace_callback('/(SN[:=]? ?)([A-Za-z0-9.\-]{4,16})/', function ($matches) {
|
||||
$patterns = array(
|
||||
'/[A-Z]/',
|
||||
'/[a-z]/',
|
||||
'/[0-9]/'
|
||||
);
|
||||
$replacements = array(
|
||||
'A',
|
||||
'a',
|
||||
'0'
|
||||
);
|
||||
return $matches[1] . preg_replace($patterns, $replacements, $matches[2]);
|
||||
}, $entry['sysDescr']);
|
||||
$sn_patterns = array('/[A-Z]/', '/[a-z]/', '/[0-9]/');
|
||||
$sn_replacements = array('A', 'a', '0');
|
||||
$entry['sysDescr'] = preg_replace_callback(
|
||||
'/((s\/?n|serial num(ber)?)[:=]? ?)([a-z0-9.\-]{4,16})/i',
|
||||
function ($matches) use ($sn_patterns, $sn_replacements) {
|
||||
return $matches[1] . preg_replace($sn_patterns, $sn_replacements, $matches[4]);
|
||||
},
|
||||
$entry['sysDescr']
|
||||
);
|
||||
|
||||
return $entry;
|
||||
}, $device_info);
|
||||
|
||||
|
Reference in New Issue
Block a user