mon: Add command line livestatus wrappersv2.1.1-beta7
commit55c111a8bf23567525f4660d1dd680be3cd382e9
authorPhilip Eklöf <peklof@op5.com>
Fri, 7 Mar 2014 11:30:00 +0000 (7 12:30 +0100)
committerPhilip Eklöf <peklof@op5.com>
Fri, 7 Mar 2014 12:17:29 +0000 (7 13:17 +0100)
treee4558954cb6943ea18df8780359ccf32e2794e1d
parentd027dc84ada3c98336655bdb7b5266d9045f331b
mon: Add command line livestatus wrappers

This adds two brand new sub modules to the mon command called "mon api ls"
and "mon api lsq". Both scripts are handling livestatus queries via the
command line, but in different ways.

"mon api lsq" is a tiny wrapper of the unixcat program. The wrapper
accepts a raw livestatus query either at stdin or as the first command
line argument. This means that an LS query that previously was run like:
 printf 'GET hosts\n...' | unixcat /opt/monitor/var/rw/live

Can now be run as simply as this:
 mon api lsq $'GET hosts\n...'

"mon api ls" on the other hand, is a much larger script that accepts
ordinary command line switches to generate an LS query for you. The
script also allows you to list the available tables and describe the
columns of a table. Specifying filter definitions can be done in two
different ways, the quick LQL-style syntax or the Shell-style syntax
that is much safer for command line usage. Have a look at "--help".

These wrappers comes in very handy as troubleshooting utils. One
might send an email to a customer in a support case, asking them
to run an LS query on all of their nodes at the same time, such as:

 mon node ctrl --self -- mon api ls hostgroups -c name,num_hosts

The same thing using printf etc. would need some additional quoting,
a pipe, and so on. Those things are always quite error-prone.

And, yup. It's all bash. Haters gonna hate. If you can't deal with it,
just rewrite it later into something else that still accepts the same
command line arguments.

Change-Id: I834f5a234aa8b70c4b74c3b94f04dda9d1aeb3d6
Signed-off-by: Philip Eklöf <peklof@op5.com>
apps/libexec/api.ls.sh [new file with mode: 0755]
apps/libexec/api.lsq.sh [new file with mode: 0755]
apps/libexec/helpfiles/api.ls.txt [new file with mode: 0644]
apps/libexec/helpfiles/api.lsq.txt [new file with mode: 0644]