move conn_metrics to Vmm_core
This commit is contained in:
parent
13edb22db3
commit
866cd9041a
|
@ -3,23 +3,6 @@
|
||||||
open Astring
|
open Astring
|
||||||
open Vmm_core
|
open Vmm_core
|
||||||
|
|
||||||
let conn_metrics kind =
|
|
||||||
let s = ref (0, 0) in
|
|
||||||
let open Metrics in
|
|
||||||
let doc = "connection statistics" in
|
|
||||||
let data () =
|
|
||||||
Data.v [
|
|
||||||
int "active" (fst !s) ;
|
|
||||||
int "total" (snd !s) ;
|
|
||||||
] in
|
|
||||||
let tags = Tags.string "kind" in
|
|
||||||
let src = Src.v ~doc ~tags:Tags.[ tags ] ~data "connections" in
|
|
||||||
(fun action ->
|
|
||||||
(match action with
|
|
||||||
| `Open -> s := (succ (fst !s), succ (snd !s))
|
|
||||||
| `Close -> s := (pred (fst !s), snd !s));
|
|
||||||
Metrics.add src (fun x -> x kind) (fun d -> d ()))
|
|
||||||
|
|
||||||
open Lwt.Infix
|
open Lwt.Infix
|
||||||
|
|
||||||
let process =
|
let process =
|
||||||
|
|
|
@ -66,7 +66,7 @@ let open_fifo name =
|
||||||
|
|
||||||
let t = ref String.Map.empty
|
let t = ref String.Map.empty
|
||||||
|
|
||||||
let fifos = Albatross_cli.conn_metrics "fifo"
|
let fifos = Vmm_core.conn_metrics "fifo"
|
||||||
|
|
||||||
let add_fifo id =
|
let add_fifo id =
|
||||||
let name = Vmm_core.Name.to_string id in
|
let name = Vmm_core.Name.to_string id in
|
||||||
|
@ -159,7 +159,7 @@ let handle s addr =
|
||||||
Vmm_lwt.safe_close s >|= fun () ->
|
Vmm_lwt.safe_close s >|= fun () ->
|
||||||
Logs.warn (fun m -> m "disconnected")
|
Logs.warn (fun m -> m "disconnected")
|
||||||
|
|
||||||
let m = Albatross_cli.conn_metrics "unix"
|
let m = Vmm_core.conn_metrics "unix"
|
||||||
|
|
||||||
let jump _ influx =
|
let jump _ influx =
|
||||||
Sys.(set_signal sigpipe Signal_ignore) ;
|
Sys.(set_signal sigpipe Signal_ignore) ;
|
||||||
|
|
|
@ -159,7 +159,7 @@ let handle mvar ring s addr =
|
||||||
end >>= fun () ->
|
end >>= fun () ->
|
||||||
Vmm_lwt.safe_close s
|
Vmm_lwt.safe_close s
|
||||||
|
|
||||||
let m = Albatross_cli.conn_metrics "unix"
|
let m = Vmm_core.conn_metrics "unix"
|
||||||
|
|
||||||
let jump _ file influx =
|
let jump _ file influx =
|
||||||
Sys.(set_signal sigpipe Signal_ignore) ;
|
Sys.(set_signal sigpipe Signal_ignore) ;
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
(* (c) 2017, 2018 Hannes Mehnert, all rights reserved *)
|
(* (c) 2017, 2018 Hannes Mehnert, all rights reserved *)
|
||||||
|
|
||||||
|
let conn_metrics kind =
|
||||||
|
let s = ref (0, 0) in
|
||||||
|
let open Metrics in
|
||||||
|
let doc = "connection statistics" in
|
||||||
|
let data () =
|
||||||
|
Data.v [
|
||||||
|
int "active" (fst !s) ;
|
||||||
|
int "total" (snd !s) ;
|
||||||
|
] in
|
||||||
|
let tags = Tags.string "kind" in
|
||||||
|
let src = Src.v ~doc ~tags:Tags.[ tags ] ~data "connections" in
|
||||||
|
(fun action ->
|
||||||
|
(match action with
|
||||||
|
| `Open -> s := (succ (fst !s), succ (snd !s))
|
||||||
|
| `Close -> s := (pred (fst !s), snd !s));
|
||||||
|
Metrics.add src (fun x -> x kind) (fun d -> d ()))
|
||||||
|
|
||||||
open Astring
|
open Astring
|
||||||
|
|
||||||
let tmpdir = Fpath.(v "/var" / "run" / "albatross")
|
let tmpdir = Fpath.(v "/var" / "run" / "albatross")
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
(* (c) 2018 Hannes Mehnert, all rights reserved *)
|
(* (c) 2018 Hannes Mehnert, all rights reserved *)
|
||||||
|
|
||||||
|
val conn_metrics : string -> [ `Close | `Open ] -> unit
|
||||||
|
|
||||||
type service = [ `Console | `Log | `Stats | `Vmmd ]
|
type service = [ `Console | `Log | `Stats | `Vmmd ]
|
||||||
|
|
||||||
val socket_path : service -> string
|
val socket_path : service -> string
|
||||||
|
|
|
@ -64,7 +64,7 @@ let timer () =
|
||||||
Vmm_lwt.safe_close s)
|
Vmm_lwt.safe_close s)
|
||||||
outs
|
outs
|
||||||
|
|
||||||
let m = Albatross_cli.conn_metrics "unix"
|
let m = Vmm_core.conn_metrics "unix"
|
||||||
|
|
||||||
let jump _ interval influx =
|
let jump _ interval influx =
|
||||||
Sys.(set_signal sigpipe Signal_ignore) ;
|
Sys.(set_signal sigpipe Signal_ignore) ;
|
||||||
|
|
|
@ -46,7 +46,7 @@ let rec wrap f arg =
|
||||||
Logs.err (fun m -> m "exception %s" (Printexc.to_string e)) ;
|
Logs.err (fun m -> m "exception %s" (Printexc.to_string e)) ;
|
||||||
None
|
None
|
||||||
|
|
||||||
let vmmapi = Albatross_cli.conn_metrics "vmmapi"
|
let vmmapi = conn_metrics "vmmapi"
|
||||||
|
|
||||||
let remove_vmid t vmid =
|
let remove_vmid t vmid =
|
||||||
Logs.info (fun m -> m "removing vmid %a" Vmm_core.Name.pp vmid) ;
|
Logs.info (fun m -> m "removing vmid %a" Vmm_core.Name.pp vmid) ;
|
||||||
|
|
|
@ -7,7 +7,7 @@ let () =
|
||||||
(library
|
(library
|
||||||
(name albatross_stats)
|
(name albatross_stats)
|
||||||
(public_name albatross.stats)
|
(public_name albatross.stats)
|
||||||
(libraries albatross albatross.cli)
|
(libraries albatross)
|
||||||
(wrapped false)
|
(wrapped false)
|
||||||
(c_names albatross_stats_stubs)
|
(c_names albatross_stats_stubs)
|
||||||
(modules albatross_stats_pure))
|
(modules albatross_stats_pure))
|
||||||
|
|
Loading…
Reference in a new issue