From 42ca0670c9cc27afc018aaf39dbcedfada4b3d1e Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Thu, 22 Mar 2018 14:00:04 +0100 Subject: [PATCH] vmm_stats: guard vmmapi_stats --- stats/vmm_stats.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stats/vmm_stats.ml b/stats/vmm_stats.ml index 77a6859..4bb39a6 100644 --- a/stats/vmm_stats.ml +++ b/stats/vmm_stats.ml @@ -28,7 +28,7 @@ let rec safe_sysctl f arg = let vm_vmmapi_stats pid = let name = "ukvm" ^ string_of_int pid in - vmmapi_stats name + try Some (vmmapi_stats name) with _ -> None let gather pid nics = safe_sysctl sysctl_rusage pid, @@ -40,13 +40,16 @@ let gather pid nics = String.Map.empty nics let tick t = + Logs.debug (fun m -> m "tick with %d vms" (IM.cardinal t.pid_nic)) ; let pid_rusage, pid_vmmapi, nic_ifdata = IM.fold (fun pid nics (rus, vmms, ifds) -> let ru, vmm, ifd = gather pid nics in (match ru with | None -> rus | Some ru -> IM.add pid ru rus), - IM.add pid vmm vmms, + (match vmm with + | None -> vmms + | Some vmm -> IM.add pid vmm vmms), String.Map.union (fun _k a _b -> Some a) ifd ifds) t.pid_nic (IM.empty, IM.empty, String.Map.empty) in