Skip to content

Commit

Permalink
Merge pull request #129 from lindig/1.33-lcm
Browse files Browse the repository at this point in the history
CP-42182 Add CLI tool on xe and rrd-cli to enable saving of rrds to local host
  • Loading branch information
lindig authored Nov 3, 2023
2 parents 065744d + 7482db2 commit 17e55a7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ build:

install:
install -D _build/install/default/bin/xcp-rrdd $(DESTDIR)$(SBINDIR)/xcp-rrdd
install -D _build/install/default/bin/rrd-cli $(DESTDIR)$(SBINDIR)/rrd-cli

uninstall:
rm -f $(DESTDIR)$(SBINDIR)/xcp-rrdd
rm -f $(DESTDIR)$(SBINDIR)/rrd-cli

clean:
dune clean
Expand Down
12 changes: 12 additions & 0 deletions cli/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(executable
(name rrd_cli)
(public_name rrd-cli)
(package xapi-rrdd)
(modules rrd_cli)
(libraries
cmdliner
rpclib.cmdliner
rpclib.markdown
xapi-idl.rrd
))

27 changes: 27 additions & 0 deletions cli/rrd_cli.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(* Rrd CLI *)

module Cmds = Rrd_interface.RPC_API (Cmdlinergen.Gen ())

let version_str description =
let maj, min, mic = description.Idl.Interface.version in
Printf.sprintf "%d.%d.%d" maj min mic

let default_cmd =
let doc =
String.concat ""
[
"A CLI for the Db monitoring API. This allows scripting of the Rrd \
daemon "
; "for testing and debugging. This tool is not intended to be used as an "
; "end user tool"
]
in
( Cmdliner.Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ()))
, Cmdliner.Term.info "rrd-cli" ~version:(version_str Cmds.description) ~doc )

let cli () =
let rpc = Rrd_client.rpc in
Cmdliner.Term.eval_choice default_cmd
(List.map (fun t -> t rpc) (Cmds.implementation ()))

let _ = cli ()

0 comments on commit 17e55a7

Please sign in to comment.