bug - Fix Cisco NTP values (#15639)

* ntp fix

style

* Number::unsignedAsSigned
This commit is contained in:
PipoCanaja
2023-12-17 18:02:03 +01:00
committed by GitHub
parent 470e2ae34f
commit fa2919bb78

View File

@@ -54,9 +54,23 @@ if (is_array($components) && count($components) > 0) {
// Extract the statistics and update rrd
$rrd['stratum'] = $array['stratum'];
$rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]);
$rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]);
$rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]);
// Cisco NTPSignedTimeValue - 16 bits of signedint, and 16 bits of unsignedint for fractional
// The time in seconds that could represent signed quantities like time delay with respect to some
// source. This textual-convention is specific to Cisco implementation of NTP where 32-bit integers are
// used for such quantities. The signed integer part is in the first 16 bits and the fraction part is in
// the last 16 bits.
$hexoffset = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']];
$rrd['offset'] = Number::unsignedAsSigned(hexdec(substr($hexoffset, 0, 5)), 16) + hexdec(substr($hexoffset, -5)) / 65536;
$hexdelay = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']];
$rrd['delay'] = Number::unsignedAsSigned(hexdec(substr($hexdelay, 0, 5)), 16) + hexdec(substr($hexdelay, -5)) / 65536;
// Cisco NTPUnsignedTimeValue - 16 bits of unsignedint, and 16 bits of unsignedint for fractional
$hexdisp = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']];
$rrd['dispersion'] = hexdec(substr($hexdisp, 0, 5)) + hexdec(substr($hexdisp, -5)) / 65536;
$tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer');
data_update($device, 'ntp', $tags, $rrd);