Skip to content

Commit 74299ed

Browse files
author
Andrii Sultanov
committed
CA-408126 follow-up: Fix negative ds_min and RRD values in historical archives
When reading RRD archives from XML, make sure ds_min is (almost never) negative, this will convert negative values to NaNs as well. Signed-off-by: Andrii Sultanov <[email protected]>
1 parent 5ec5732 commit 74299ed

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ocaml/libs/xapi-rrd/lib/rrd.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,19 @@ let from_xml input =
744744
let name = get_el "name" i in
745745
let type_ = get_el "type" i in
746746
let min_hb = get_el "minimal_heartbeat" i in
747-
let min = get_el "min" i in
747+
(* CA-408126 - work around negative data in historical RRDs
748+
where ds_min could have been incorrectly set to neg_infinity.
749+
Currently the only metric that could be negative is
750+
DCMI-power-reading, so account for it.
751+
Setting ds_min to 0. means Fring.make below will turn negative
752+
historical values to NaNs.*)
753+
let min = float_of_string (get_el "min" i) in
754+
let min =
755+
if min < 0. && name <> "DCMI-power-reading" then
756+
0.
757+
else
758+
min
759+
in
748760
let max = get_el "max" i in
749761
ignore (get_el "last_ds" i) ;
750762
let value = get_el "value" i in
@@ -767,7 +779,7 @@ let from_xml input =
767779
failwith "Bad format"
768780
)
769781
; ds_mrhb= float_of_string min_hb
770-
; ds_min= float_of_string min
782+
; ds_min= min
771783
; ds_max= float_of_string max
772784
; ds_last= VT_Unknown
773785
; (* float_of_string "last_ds"; *)

0 commit comments

Comments
 (0)