avoid dependency on mirage-solo5, conflict with mirage-solo5/mirage-xen that do not include the Memory.metrics
This commit is contained in:
parent
8bcf3adfe8
commit
98ef5cc436
4 changed files with 12 additions and 26 deletions
|
@ -16,11 +16,14 @@ depends: [
|
||||||
"metrics-influx" {>= "0.2.0"}
|
"metrics-influx" {>= "0.2.0"}
|
||||||
"mirage-time" {>= "2.0.0"}
|
"mirage-time" {>= "2.0.0"}
|
||||||
"tcpip" {>= "7.0.0"}
|
"tcpip" {>= "7.0.0"}
|
||||||
"mirage-solo5" {>= "0.9.0"}
|
|
||||||
"mirage-runtime" {>= "4.3.0"}
|
"mirage-runtime" {>= "4.3.0"}
|
||||||
"memtrace-mirage" {>= "0.2.1.2.2"}
|
"memtrace-mirage" {>= "0.2.1.2.2"}
|
||||||
"mirage-clock" {>= "4.0.0"}
|
"mirage-clock" {>= "4.0.0"}
|
||||||
]
|
]
|
||||||
|
conflicts: [
|
||||||
|
"mirage-solo5" {< "0.9.2"}
|
||||||
|
"mirage-solo5" {< "8.0.2"}
|
||||||
|
]
|
||||||
build: [
|
build: [
|
||||||
["dune" "subst"] {dev}
|
["dune" "subst"] {dev}
|
||||||
["dune" "build" "-p" name "-j" jobs]
|
["dune" "build" "-p" name "-j" jobs]
|
||||||
|
|
2
src/dune
2
src/dune
|
@ -3,4 +3,4 @@
|
||||||
(public_name mirage-monitoring)
|
(public_name mirage-monitoring)
|
||||||
(wrapped false)
|
(wrapped false)
|
||||||
(libraries logs metrics metrics-lwt metrics-influx mirage-time mirage-clock
|
(libraries logs metrics metrics-lwt metrics-influx mirage-time mirage-clock
|
||||||
memtrace-mirage tcpip mirage-solo5 mirage-runtime))
|
memtrace-mirage tcpip mirage-runtime))
|
||||||
|
|
|
@ -31,20 +31,6 @@ let counter_metrics ~f name =
|
||||||
|
|
||||||
let vmname = Metrics.field ~doc:"name of the virtual machine" "vm" Metrics.String
|
let vmname = Metrics.field ~doc:"name of the virtual machine" "vm" Metrics.String
|
||||||
|
|
||||||
let memory_metrics ~quick ~tags =
|
|
||||||
let open Metrics in
|
|
||||||
let doc = "Memory counters" in
|
|
||||||
let stat = Solo5_os.Memory.(if quick then quick_stat else stat) in
|
|
||||||
let data () =
|
|
||||||
let stat = stat () in
|
|
||||||
Data.v
|
|
||||||
[ uint "memory heap words" stat.heap_words
|
|
||||||
; uint "memory live words" stat.live_words
|
|
||||||
; uint "memory stack words" stat.stack_words
|
|
||||||
; uint "memory free words" stat.free_words ]
|
|
||||||
in
|
|
||||||
Src.v ~doc ~tags ~data "memory"
|
|
||||||
|
|
||||||
let get_log_levels s =
|
let get_log_levels s =
|
||||||
let qs = String.split_on_char ',' s in
|
let qs = String.split_on_char ',' s in
|
||||||
let srcs = Logs.Src.list () in
|
let srcs = Logs.Src.list () in
|
||||||
|
@ -261,8 +247,8 @@ module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6)
|
||||||
Lwt.return_unit) >>= fun () ->
|
Lwt.return_unit) >>= fun () ->
|
||||||
S.TCP.close f)
|
S.TCP.close f)
|
||||||
|
|
||||||
let create ?(interval = 10) ?(quick = true) ?hostname dst ?(port = 8094)
|
let create ?(interval = 10) ?hostname dst ?(port = 8094) ?(listen_port = 2323)
|
||||||
?(listen_port = 2323) ?(memtrace_port = 4242) ?(sampling_rate = 1e-4) stack =
|
?(memtrace_port = 4242) ?(sampling_rate = 1e-4) stack =
|
||||||
S.TCP.listen (S.tcp stack) ~port:memtrace_port
|
S.TCP.listen (S.tcp stack) ~port:memtrace_port
|
||||||
(fun f ->
|
(fun f ->
|
||||||
(* only allow a single tracing client *)
|
(* only allow a single tracing client *)
|
||||||
|
@ -282,7 +268,6 @@ module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6)
|
||||||
Metrics.set_reporter reporter;
|
Metrics.set_reporter reporter;
|
||||||
Metrics.enable_all ();
|
Metrics.enable_all ();
|
||||||
Metrics_lwt.init_periodic (fun () -> T.sleep_ns (Duration.of_sec interval));
|
Metrics_lwt.init_periodic (fun () -> T.sleep_ns (Duration.of_sec interval));
|
||||||
Metrics_lwt.periodically (memory_metrics ~quick ~tags:Metrics.Tags.[]);
|
|
||||||
let host = match hostname with None -> [] | Some host -> [vmname host] in
|
let host = match hostname with None -> [] | Some host -> [vmname host] in
|
||||||
Lwt.async (timer_loop get_cache host interval stack (dst, port));
|
Lwt.async (timer_loop get_cache host interval stack (dst, port));
|
||||||
create_listener stack listen_port
|
create_listener stack listen_port
|
||||||
|
|
|
@ -7,17 +7,15 @@ val vmname : string -> Metrics.field
|
||||||
|
|
||||||
module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6) : sig
|
module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6) : sig
|
||||||
|
|
||||||
val create : ?interval:int -> ?quick:bool -> ?hostname:string -> Ipaddr.t ->
|
val create : ?interval:int -> ?hostname:string -> Ipaddr.t -> ?port:int ->
|
||||||
?port:int -> ?listen_port:int -> ?memtrace_port:int ->
|
?listen_port:int -> ?memtrace_port:int -> ?sampling_rate:float -> S.t ->
|
||||||
?sampling_rate:float -> S.t -> unit
|
unit
|
||||||
(** [create ~interval ~quick ~hostname ip ~port ~listen_port ~memtrace_port ~sampling_rate stack]
|
(** [create ~interval ~hostname ip ~port ~listen_port ~memtrace_port ~sampling_rate stack]
|
||||||
initiates monitoring on [stack] for the unikernel. The metrics are reported
|
initiates monitoring on [stack] for the unikernel. The metrics are reported
|
||||||
every [interval] (defaults to 10) seconds to [ip] on [port] (defaults to
|
every [interval] (defaults to 10) seconds to [ip] on [port] (defaults to
|
||||||
8094) via TCP using the influxd wire protocol. On [listen_port] (defaults
|
8094) via TCP using the influxd wire protocol. On [listen_port] (defaults
|
||||||
to 2323) a TCP connection can be initiated to adjust the log level and
|
to 2323) a TCP connection can be initiated to adjust the log level and
|
||||||
enable and disable metrics sources. On [memtrace_port] (defaults to 4242)
|
enable and disable metrics sources. On [memtrace_port] (defaults to 4242)
|
||||||
a single TCP client can connect simultaneously to receive a [Gc.Memprof]
|
a single TCP client can connect simultaneously to receive a [Gc.Memprof]
|
||||||
trace. The [sampling_rate] defaults to [1e-4]. If [quick] is provided
|
trace. The [sampling_rate] defaults to [1e-4]. *)
|
||||||
and [false] (defaults to [true]), [Solo5_os.Memory.stat] is used,
|
|
||||||
otherwise [Solo5_os.Memory.quick_stat] is used. *)
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue