Skip to content

Commit 0e1461f

Browse files
committed
Merge pull request #31 from djs55/jons
Update to @jonludlam's new rrd interfaces
2 parents aefb7cc + be9f99d commit 0e1461f

8 files changed

+211
-156
lines changed

Diff for: _oasis

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ Executable "xcp-rrdd"
2525
Install: false
2626
ByteOpt: -bin-annot
2727
NativeOpt: -bin-annot
28-
BuildDepends: threads, rpclib, rpclib.unix, gzip, forkexec, stdext, uuid, http-svr, xcp-inventory, xcp-rrd, rrdd-libs, xcp, xcp.rrd, xcp.network, xcp.xen, xenops, rrd-transport, threads, rpclib.syntax, io-page.unix, xen-gnt.unix, oclock
28+
BuildDepends: threads, rpclib, rpclib.unix, gzip, forkexec, stdext, uuid, http-svr, xcp-inventory, rrd, rrdd-libs, xcp, xcp.rrd, xcp.network, xcp.xen, xenops, rrd-transport, threads, rpclib.syntax, io-page.unix, xen-gnt.unix, oclock
2929

Diff for: _tags

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 7b66ad44912d3b99106b79b4783fa090)
2+
# DO NOT EDIT (digest: a5ff006be747e15efd9341c4930682c1)
33
# Ignore VCS directories, you can use the same kind of rule outside
44
# OASIS_START/STOP if you want to exclude directories that contains
55
# useless stuff for the build process
6+
true: annot, bin_annot
67
<**/.svn>: -traverse
78
<**/.svn>: not_hygienic
89
".bzr": -traverse
@@ -16,18 +17,18 @@
1617
# Library rrdd_libs
1718
"lib/rrdd_libs.cmxs": use_rrdd_libs
1819
<lib/rrdd_libs.{cma,cmxa}>: oasis_library_rrdd_libs_byte
19-
<lib/*.ml{,i}>: oasis_library_rrdd_libs_byte
20+
<lib/*.ml{,i,y}>: oasis_library_rrdd_libs_byte
2021
<lib/rrdd_libs.{cma,cmxa}>: oasis_library_rrdd_libs_native
21-
<lib/*.ml{,i}>: oasis_library_rrdd_libs_native
22-
<lib/*.ml{,i}>: pkg_stdext
23-
<lib/*.ml{,i}>: pkg_threads
24-
<lib/*.ml{,i}>: pkg_xcp
22+
<lib/*.ml{,i,y}>: oasis_library_rrdd_libs_native
23+
<lib/*.ml{,i,y}>: pkg_stdext
24+
<lib/*.ml{,i,y}>: pkg_threads
25+
<lib/*.ml{,i,y}>: pkg_xcp
2526
# Executable xcp-rrdd
2627
<rrdd/xcp_rrdd.{native,byte}>: oasis_executable_xcp_rrdd_byte
27-
<rrdd/*.ml{,i}>: oasis_executable_xcp_rrdd_byte
28+
<rrdd/*.ml{,i,y}>: oasis_executable_xcp_rrdd_byte
2829
"rrdd/blktap3_stats_stubs.c": oasis_executable_xcp_rrdd_byte
2930
<rrdd/xcp_rrdd.{native,byte}>: oasis_executable_xcp_rrdd_native
30-
<rrdd/*.ml{,i}>: oasis_executable_xcp_rrdd_native
31+
<rrdd/*.ml{,i,y}>: oasis_executable_xcp_rrdd_native
3132
"rrdd/blktap3_stats_stubs.c": oasis_executable_xcp_rrdd_native
3233
<rrdd/xcp_rrdd.{native,byte}>: use_libxcp-rrdd_stubs
3334
<rrdd/xcp_rrdd.{native,byte}>: pkg_forkexec
@@ -38,40 +39,40 @@
3839
<rrdd/xcp_rrdd.{native,byte}>: pkg_rpclib
3940
<rrdd/xcp_rrdd.{native,byte}>: pkg_rpclib.syntax
4041
<rrdd/xcp_rrdd.{native,byte}>: pkg_rpclib.unix
42+
<rrdd/xcp_rrdd.{native,byte}>: pkg_rrd
4143
<rrdd/xcp_rrdd.{native,byte}>: pkg_rrd-transport
4244
<rrdd/xcp_rrdd.{native,byte}>: pkg_stdext
4345
<rrdd/xcp_rrdd.{native,byte}>: pkg_threads
4446
<rrdd/xcp_rrdd.{native,byte}>: pkg_uuid
4547
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp
4648
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp-inventory
47-
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp-rrd
4849
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp.network
4950
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp.rrd
5051
<rrdd/xcp_rrdd.{native,byte}>: pkg_xcp.xen
5152
<rrdd/xcp_rrdd.{native,byte}>: pkg_xen-gnt.unix
5253
<rrdd/xcp_rrdd.{native,byte}>: pkg_xenops
5354
<rrdd/xcp_rrdd.{native,byte}>: use_rrdd_libs
54-
<rrdd/*.ml{,i}>: pkg_forkexec
55-
<rrdd/*.ml{,i}>: pkg_gzip
56-
<rrdd/*.ml{,i}>: pkg_http-svr
57-
<rrdd/*.ml{,i}>: pkg_io-page.unix
58-
<rrdd/*.ml{,i}>: pkg_oclock
59-
<rrdd/*.ml{,i}>: pkg_rpclib
60-
<rrdd/*.ml{,i}>: pkg_rpclib.syntax
61-
<rrdd/*.ml{,i}>: pkg_rpclib.unix
62-
<rrdd/*.ml{,i}>: pkg_rrd-transport
63-
<rrdd/*.ml{,i}>: pkg_stdext
64-
<rrdd/*.ml{,i}>: pkg_threads
65-
<rrdd/*.ml{,i}>: pkg_uuid
66-
<rrdd/*.ml{,i}>: pkg_xcp
67-
<rrdd/*.ml{,i}>: pkg_xcp-inventory
68-
<rrdd/*.ml{,i}>: pkg_xcp-rrd
69-
<rrdd/*.ml{,i}>: pkg_xcp.network
70-
<rrdd/*.ml{,i}>: pkg_xcp.rrd
71-
<rrdd/*.ml{,i}>: pkg_xcp.xen
72-
<rrdd/*.ml{,i}>: pkg_xen-gnt.unix
73-
<rrdd/*.ml{,i}>: pkg_xenops
74-
<rrdd/*.ml{,i}>: use_rrdd_libs
55+
<rrdd/*.ml{,i,y}>: pkg_forkexec
56+
<rrdd/*.ml{,i,y}>: pkg_gzip
57+
<rrdd/*.ml{,i,y}>: pkg_http-svr
58+
<rrdd/*.ml{,i,y}>: pkg_io-page.unix
59+
<rrdd/*.ml{,i,y}>: pkg_oclock
60+
<rrdd/*.ml{,i,y}>: pkg_rpclib
61+
<rrdd/*.ml{,i,y}>: pkg_rpclib.syntax
62+
<rrdd/*.ml{,i,y}>: pkg_rpclib.unix
63+
<rrdd/*.ml{,i,y}>: pkg_rrd
64+
<rrdd/*.ml{,i,y}>: pkg_rrd-transport
65+
<rrdd/*.ml{,i,y}>: pkg_stdext
66+
<rrdd/*.ml{,i,y}>: pkg_threads
67+
<rrdd/*.ml{,i,y}>: pkg_uuid
68+
<rrdd/*.ml{,i,y}>: pkg_xcp
69+
<rrdd/*.ml{,i,y}>: pkg_xcp-inventory
70+
<rrdd/*.ml{,i,y}>: pkg_xcp.network
71+
<rrdd/*.ml{,i,y}>: pkg_xcp.rrd
72+
<rrdd/*.ml{,i,y}>: pkg_xcp.xen
73+
<rrdd/*.ml{,i,y}>: pkg_xen-gnt.unix
74+
<rrdd/*.ml{,i,y}>: pkg_xenops
75+
<rrdd/*.ml{,i,y}>: use_rrdd_libs
7576
"rrdd/blktap3_stats_stubs.c": pkg_forkexec
7677
"rrdd/blktap3_stats_stubs.c": pkg_gzip
7778
"rrdd/blktap3_stats_stubs.c": pkg_http-svr
@@ -80,13 +81,13 @@
8081
"rrdd/blktap3_stats_stubs.c": pkg_rpclib
8182
"rrdd/blktap3_stats_stubs.c": pkg_rpclib.syntax
8283
"rrdd/blktap3_stats_stubs.c": pkg_rpclib.unix
84+
"rrdd/blktap3_stats_stubs.c": pkg_rrd
8385
"rrdd/blktap3_stats_stubs.c": pkg_rrd-transport
8486
"rrdd/blktap3_stats_stubs.c": pkg_stdext
8587
"rrdd/blktap3_stats_stubs.c": pkg_threads
8688
"rrdd/blktap3_stats_stubs.c": pkg_uuid
8789
"rrdd/blktap3_stats_stubs.c": pkg_xcp
8890
"rrdd/blktap3_stats_stubs.c": pkg_xcp-inventory
89-
"rrdd/blktap3_stats_stubs.c": pkg_xcp-rrd
9091
"rrdd/blktap3_stats_stubs.c": pkg_xcp.network
9192
"rrdd/blktap3_stats_stubs.c": pkg_xcp.rrd
9293
"rrdd/blktap3_stats_stubs.c": pkg_xcp.xen

Diff for: myocamlbuild.ml

+51-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* OASIS_START *)
2-
(* DO NOT EDIT (digest: 6f0944cbfac660560d181ed9869f7ea0) *)
2+
(* DO NOT EDIT (digest: b5e4a9541fee12f1471092b125db073d) *)
33
module OASISGettext = struct
44
(* # 22 "src/oasis/OASISGettext.ml" *)
55

@@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct
249249
*)
250250
open Ocamlbuild_plugin
251251

252+
type conf =
253+
{ no_automatic_syntax: bool;
254+
}
252255

253256
(* these functions are not really officially exported *)
254257
let run_and_read =
@@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct
315318

316319
(* This lists all supported packages. *)
317320
let find_packages () =
318-
List.map before_space (split_nl & run_and_read "ocamlfind list")
321+
List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))
319322

320323

321324
(* Mock to list available syntaxes. *)
@@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct
338341
]
339342

340343

341-
let dispatch =
344+
let dispatch conf =
342345
function
343346
| After_options ->
344347
(* By using Before_options one let command line options have an higher
@@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct
357360
* -linkpkg *)
358361
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
359362

360-
(* For each ocamlfind package one inject the -package option when
361-
* compiling, computing dependencies, generating documentation and
362-
* linking. *)
363-
List.iter
364-
begin fun pkg ->
365-
let base_args = [A"-package"; A pkg] in
366-
(* TODO: consider how to really choose camlp4o or camlp4r. *)
367-
let syn_args = [A"-syntax"; A "camlp4o"] in
368-
let args =
369-
(* Heuristic to identify syntax extensions: whether they end in
370-
".syntax"; some might not.
371-
*)
372-
if Filename.check_suffix pkg "syntax" ||
373-
List.mem pkg well_known_syntax then
374-
syn_args @ base_args
375-
else
376-
base_args
377-
in
378-
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
379-
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
380-
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
381-
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
382-
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
383-
end
384-
(find_packages ());
363+
if not (conf.no_automatic_syntax) then begin
364+
(* For each ocamlfind package one inject the -package option when
365+
* compiling, computing dependencies, generating documentation and
366+
* linking. *)
367+
List.iter
368+
begin fun pkg ->
369+
let base_args = [A"-package"; A pkg] in
370+
(* TODO: consider how to really choose camlp4o or camlp4r. *)
371+
let syn_args = [A"-syntax"; A "camlp4o"] in
372+
let (args, pargs) =
373+
(* Heuristic to identify syntax extensions: whether they end in
374+
".syntax"; some might not.
375+
*)
376+
if Filename.check_suffix pkg "syntax" ||
377+
List.mem pkg well_known_syntax then
378+
(syn_args @ base_args, syn_args)
379+
else
380+
(base_args, [])
381+
in
382+
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
383+
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
384+
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
385+
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
386+
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
387+
388+
(* TODO: Check if this is allowed for OCaml < 3.12.1 *)
389+
flag ["ocaml"; "compile"; "package("^pkg^")"] & S pargs;
390+
flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
391+
flag ["ocaml"; "doc"; "package("^pkg^")"] & S pargs;
392+
flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
393+
end
394+
(find_packages ());
395+
end;
385396

386397
(* Like -package but for extensions syntax. Morover -syntax is useless
387398
* when linking. *)
@@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct
546557

547558
(* When ocaml link something that use the C library, then one
548559
need that file to be up to date.
560+
This holds both for programs and for libraries.
549561
*)
550-
dep ["link"; "ocaml"; "program"; tag_libstubs lib]
551-
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
562+
dep ["link"; "ocaml"; tag_libstubs lib]
563+
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
552564

553-
dep ["compile"; "ocaml"; "program"; tag_libstubs lib]
554-
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
565+
dep ["compile"; "ocaml"; tag_libstubs lib]
566+
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
555567

556568
(* TODO: be more specific about what depends on headers *)
557569
(* Depends on .h files *)
@@ -580,18 +592,18 @@ module MyOCamlbuildBase = struct
580592
()
581593

582594

583-
let dispatch_default t =
595+
let dispatch_default conf t =
584596
dispatch_combine
585597
[
586598
dispatch t;
587-
MyOCamlbuildFindlib.dispatch;
599+
MyOCamlbuildFindlib.dispatch conf;
588600
]
589601

590602

591603
end
592604

593605

594-
# 594 "myocamlbuild.ml"
606+
# 606 "myocamlbuild.ml"
595607
open Ocamlbuild_plugin;;
596608
let package_default =
597609
{
@@ -629,8 +641,10 @@ let package_default =
629641
}
630642
;;
631643

632-
let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
644+
let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
645+
646+
let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
633647

634-
# 635 "myocamlbuild.ml"
648+
# 649 "myocamlbuild.ml"
635649
(* OASIS_STOP *)
636650
Ocamlbuild_plugin.dispatch dispatch_default;;

Diff for: rrdd/rrdd_http_handler.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let unarchive_rrd_handler (req : Http.Request.t) (s : Unix.file_descr) _ =
1515
Http.http_200_ok ~version:"1.0" ~keep_alive:false ()
1616
@ ["Access-Control-Allow-Origin: *"] in
1717
Http_svr.headers s header_content;
18-
Rrd.to_fd rrd s
18+
Rrd_unix.to_fd rrd s
1919

2020
(* A handler for putting a VM's RRD data into the Http response.
2121
* The rrdd assumes that it has RRD for the vm_uuid, since xapi confirmed this
@@ -29,7 +29,7 @@ let get_vm_rrd_handler (req : Http.Request.t) (s : Unix.file_descr) _ =
2929
let rrd = Mutex.execute mutex
3030
(fun () -> Rrd.copy_rrd (Hashtbl.find vm_rrds vm_uuid).rrd) in
3131
Http_svr.headers s (Http.http_200_ok ~version:"1.0" ~keep_alive:false ());
32-
Rrd.to_fd rrd s
32+
Rrd_unix.to_fd rrd s
3333

3434
(* A handler for putting the host's RRD data into the Http response. *)
3535
let get_host_rrd_handler (req : Http.Request.t) (s : Unix.file_descr) _ =
@@ -43,7 +43,7 @@ let get_host_rrd_handler (req : Http.Request.t) (s : Unix.file_descr) _ =
4343
Http_svr.headers s
4444
(Http.http_200_ok ~version:"1.0" ~keep_alive:false () @
4545
["Access-Control-Allow-Origin: *"]);
46-
Rrd.to_fd ~json:(List.mem_assoc "json" query) rrd s
46+
Rrd_unix.to_fd ~json:(List.mem_assoc "json" query) rrd s
4747

4848
(* Get an XML/JSON document (as a string) representing the updates since the
4949
* specified start time. *)
@@ -62,7 +62,7 @@ let get_host_stats ?(json = false) ~(start : int64) ~(interval : int64)
6262
("host:" ^ localhost_uuid ^ ":", rrdi.rrd)::vm_rrds
6363
else vm_rrds
6464
in
65-
Rrd.export ~json prefixandrrds start interval cfopt)
65+
Rrd_updates.export ~json prefixandrrds start interval cfopt)
6666

6767
(* Writes XML/JSON representing the updates since the specified start time to
6868
* the file descriptor that corresponds to the client HTTP connection. *)

Diff for: rrdd/rrdd_monitor.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ let update_rrds timestamp dss (uuid_domids : (string * int) list) rebooting_vms
7373
let current_dss = Rrd.ds_names rrdi.rrd in
7474
let new_defaults = List.filter (fun ds -> not (List.mem ds.ds_name current_dss)) default_dss in
7575
let rrd =
76+
let now = Unix.gettimeofday () in
7677
if List.length new_defaults > 0 then (
77-
let rrd = List.fold_left (fun rrd ds -> Rrd.rrd_add_ds rrd (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)) rrdi.rrd new_defaults in
78+
let rrd = List.fold_left (fun rrd ds -> Rrd.rrd_add_ds rrd now (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)) rrdi.rrd new_defaults in
7879
Hashtbl.replace vm_rrds vm_uuid {rrd; dss; domid};
7980
rrd
8081
) else rrdi.rrd
@@ -118,8 +119,9 @@ let update_rrds timestamp dss (uuid_domids : (string * int) list) rebooting_vms
118119
let current_dss = Rrd.ds_names rrdi.rrd in
119120
let new_defaults = List.filter (fun ds -> not (List.mem ds.ds_name current_dss)) default_dss in
120121
let rrd =
122+
let now = Unix.gettimeofday () in
121123
if List.length new_defaults > 0 then
122-
let rrd = List.fold_left (fun rrd ds -> Rrd.rrd_add_ds rrd (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)) rrdi.rrd new_defaults in
124+
let rrd = List.fold_left (fun rrd ds -> Rrd.rrd_add_ds rrd now (Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)) rrdi.rrd new_defaults in
123125
host_rrd := Some {rrd; dss = host_dss; domid = 0};
124126
rrd
125127
else

Diff for: rrdd/rrdd_server.ml

+6-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ let send_host_rrd_to_master _ () =
202202
let add_ds ~rrdi ~ds_name =
203203
let open Ds in
204204
let ds = List.find (fun ds -> ds.ds_name = ds_name) rrdi.dss in
205-
Rrd.rrd_add_ds rrdi.rrd
205+
let now = Unix.gettimeofday () in
206+
Rrd.rrd_add_ds rrdi.rrd now
206207
(Rrd.ds_create ds.ds_name ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)
207208

208209
let add_host_ds _ ~(ds_name : string) : unit =
@@ -238,10 +239,11 @@ let query_possible_host_dss _ () : Data_source.t list =
238239
)
239240

240241
let query_host_ds _ ~(ds_name : string) : float =
242+
let now = Unix.gettimeofday () in
241243
Mutex.execute mutex (fun () ->
242244
match !host_rrd with
243245
| None -> failwith "No data source!"
244-
| Some rrdi -> Rrd.query_named_ds rrdi.rrd ds_name Rrd.CF_Average
246+
| Some rrdi -> Rrd.query_named_ds rrdi.rrd now ds_name Rrd.CF_Average
245247
)
246248

247249
let add_vm_ds _ ~(vm_uuid : string) ~(domid : int) ~(ds_name : string) : unit =
@@ -265,9 +267,10 @@ let query_possible_vm_dss _ ~(vm_uuid : string) : Data_source.t list =
265267
)
266268

267269
let query_vm_ds _ ~(vm_uuid : string) ~(ds_name : string) : float =
270+
let now = Unix.gettimeofday () in
268271
Mutex.execute mutex (fun () ->
269272
let rrdi = Hashtbl.find vm_rrds vm_uuid in
270-
Rrd.query_named_ds rrdi.rrd ds_name Rrd.CF_Average
273+
Rrd.query_named_ds rrdi.rrd now ds_name Rrd.CF_Average
271274
)
272275

273276
let update_use_min_max _ ~(value : bool) () : unit =

Diff for: rrdd/rrdd_shared.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let send_rrd ?(session_id : string option) ~(address : string)
116116
let transport = SSL(SSL.make (), address, !https_port) in
117117
with_transport transport (
118118
with_http request (fun (response, fd) ->
119-
try Rrd.to_fd rrd fd
119+
try Rrd_unix.to_fd rrd fd
120120
with e -> log_backtrace ()
121121
)
122122
);
@@ -139,7 +139,7 @@ let archive_rrd ?(save_stats_locally = Pool_role_shared.is_master ()) ~uuid
139139
Unixext.mkdir_safe Constants.rrd_location 0o755;
140140
let base_filename = Constants.rrd_location ^ "/" ^ uuid in
141141
Unixext.atomic_write_to_file (base_filename ^ ".gz") 0o644
142-
(fun fd -> Gzip.compress fd (Rrd.to_fd rrd));
142+
(fun fd -> Gzip.compress fd (Rrd_unix.to_fd rrd));
143143
(* If there's an uncompressed one hanging around, remove it. *)
144144
Unixext.unlink_safe base_filename
145145
end else begin

0 commit comments

Comments
 (0)