fix serial parsing for some areca controller firmwares

git-svn-id: http://www.observium.org/svn/observer/trunk@1209 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-06-18 16:38:41 +00:00
parent e19d01cd63
commit 033dd8524f
2 changed files with 17 additions and 0 deletions

View File

@@ -766,4 +766,15 @@ function formatCiscoHardware(&$device, $short = false)
}
}
}
# from http://ditio.net/2008/11/04/php-string-to-hex-and-hex-to-string-functions/
function hex2str($hex)
{
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2)
{
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
return $string;
}
?>

View File

@@ -9,4 +9,10 @@ if (!$version) { $version = trim(snmp_get($device, "1.3.6.1.4.1.18928.1.2.1.4.0"
$serial = trim(snmp_get($device, "1.3.6.1.4.1.18928.1.1.1.3.0", "-OQv", "", ""),'"');
if (!$serial) { $serial = trim(snmp_get($device, "1.3.6.1.4.1.18928.1.2.1.3.0", "-OQv", "", ""),'"'); }
if (strstr($serial,' '))
{
# Sometimes firmware outputs serial as hex-string
$serial = hex2str(str_replace(' ','',str_replace(' 00','',$serial)));
}
?>