Skip to content

Commit

Permalink
rrdd plugins: Improved accuracy of time reporting.
Browse files Browse the repository at this point in the history
Signed-off-by: Rok Strniša <rok.strnisa@citrix.com>
  • Loading branch information
Rok Strniša committed Jul 10, 2012
1 parent 4490e67 commit f7f12f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ocaml/rrdd/rrdd_main.ml
Expand Up @@ -558,7 +558,7 @@ let monitor_loop () =
try
do_monitor xc;
Mutex.execute Rrdd_shared.last_loop_end_time_m (fun _ ->
Rrdd_shared.last_loop_end_time := Unix.time ()
Rrdd_shared.last_loop_end_time := Unix.gettimeofday ()
);
Thread.delay !Rrdd_shared.timeslice
with e ->
Expand Down Expand Up @@ -589,6 +589,7 @@ let _ =
Debug.set_facility Syslog.Local5;

(* Read configuration file. *)
debug "Reading configuration file ..";
read_config ();

let pidfile = ref "" in
Expand Down
6 changes: 3 additions & 3 deletions ocaml/rrdd/rrdd_server.ml
Expand Up @@ -598,14 +598,14 @@ module Plugin = struct

(* Returns the number of seconds until the next reading phase for the
* sampling frequency given at registration by the plugin with the specified
* unique ID. *)
* unique ID. If the plugin is not registered, -1 is returned. *)
let next_reading _ ~(uid : string) : float =
let open Rrdd_shared in
if Mutex.execute registered_m (fun _ -> Hashtbl.mem registered uid)
then Mutex.execute last_loop_end_time_m (fun _ ->
!last_loop_end_time +. !timeslice -. (Unix.time ())
!last_loop_end_time +. !timeslice -. (Unix.gettimeofday ())
)
else infinity
else -1.

(* The function registers a plugin, and returns the number of seconds until
* the next reading phase for the specified sampling frequency. *)
Expand Down

0 comments on commit f7f12f2

Please sign in to comment.