Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-42182 Add CLI tool on xe and rrd-cli to enable saving of rrds to local host #129

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ()
Loading