diff --git a/doc/docs/getting_started/examples_bluechictl.md b/doc/docs/getting_started/examples_bluechictl.md index f1006c1ad7..119f3c5466 100644 --- a/doc/docs/getting_started/examples_bluechictl.md +++ b/doc/docs/getting_started/examples_bluechictl.md @@ -17,7 +17,7 @@ laptop |bluechi-agent.service pi |bluechi-agent.service | active| running ``` -## Monitoring of units and nodes +## Monitoring of units The `bluechictl monitor ` command enables to view changes in real-time. For example, to monitor all state changes of `cow.service` on `pi` the following command can be issued: @@ -48,10 +48,12 @@ Subscribing to node '*' and unit '*' This enables an observer to do the necessary re-queries since state changes could have happened while the node was disconnected. +## Monitoring of nodes + In addition to monitoring units, BlueChi's APIs can be used to query and monitor the node connection states: ```bash -$ bluechictl monitor node-connection +$ bluechictl status NODE | STATE | LAST SEEN ========================================================================= @@ -68,6 +70,18 @@ laptop | online | now pi | online | 2023-10-06 08:38:20,000+0200 ``` +It is also possible to show the status of a specific node + +```bash +$ bluechictl status laptop + +NODE | STATE | LAST SEEN +========================================================================= +laptop | online | now +``` + +In addition, a flag `-w/--watch` can be used with `bluechictl status` to continuously display the nodes status, refreshing on node status change. + ## Operations on units The `bluechictl start` command can be used to start systemd units on managed nodes: @@ -114,3 +128,16 @@ $ bluechictl freeze pi cow.service # revert the previous freeze $ bluechictl thaw pi cow.service ``` + +## Print unit status + +The `bluechictl status ` will print the specific unit info and status + +```bash +$ bluechictl status laptop httpd.service + +UNIT | LOADED | ACTIVE | SUBSTATE | FREEZERSTATE | ENABLED | +--------------------------------------------------------------------------------- +httpd.service | loaded | active | running | running | enabled | + +``` diff --git a/doc/man/bluechictl.1.md b/doc/man/bluechictl.1.md index d52022df0c..c52b3e56e3 100644 --- a/doc/man/bluechictl.1.md +++ b/doc/man/bluechictl.1.md @@ -30,21 +30,44 @@ Print current bluechictl version Performs one of the listed lifecycle operations on the given systemd unit for the `bluechi-agent`. -### **bluechictl** [*enable|disable*] [*agent*] [*unit1*,*...*] +### **bluechictl** [*enable*] [*agent*] [*unit1*,*...*] -Enable/Disable the list of systemd unit files for the `bluechi-agent`. +Enable the list of systemd unit files for the `bluechi-agent`. + + +**Options:** + +**--force**, **-f** + Override existing symlinks + +**--runtime** + Enable unit files temporarily until next reboot + +**--no-reload** + Don't reload daemon after enabling unit files + +### **bluechictl** [*disable*] [*agent*] [*unit1*,*...*] + +Disable the list of systemd unit files for the `bluechi-agent`. + + +**Options:** + +**--no-reload** + Don't reload daemon after disabling unit files ### **bluechictl** *list-units* [*agent*] Fetches information about all systemd units on the bluechi-agents. If [bluechi-agent] is not specified, all agents are queried. -### **bluechictl** *monitor* [*agent*] [*unit1*,*unit2*,*...*] +**Options:** -Creates a monitor on the given agent to observe changes in the specified units. Wildcards **\*** to match all agents and/or units are also supported. +**--filter** + Use glob filter for the unit names -### **bluechictl** *monitor* *node-connection* +### **bluechictl** *monitor* [*agent*] [*unit1*,*unit2*,*...*] -Creates a monitor to observe connection state changes for all nodes. +Creates a monitor on the given agent to observe changes in the specified units. Wildcards **\*** to match all agents and/or units are also supported. **Example:** @@ -59,6 +82,25 @@ bluechictl monitor \\\* dbus.service,apache2.service Performs `daemon-reload` for the `bluechi-agent`. -### **bluechictl** [*status*] [*agent*] [*unit1*,*...*] +### **bluechictl** *status* [*agent*] + +Fetches the status of all the agents or a specific agent: state (online/offline) and when was it last seen + + +**Options:** + +**--watch**, **-w** + Continuously display agent(s) status, updating when state change update received + + +**Example:** + +bluechictl status + +bluechictl status rpi + +bluechictl status -w + +### **bluechictl** *status* [*agent*] [*unit1*,*...*] Fetches the status of the systemd units for the `bluechi-agent`. diff --git a/src/client/main.c b/src/client/main.c index 8e574f0fcb..a2339baa06 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -40,7 +40,7 @@ const Method methods[] = { { "monitor", 0, 2, OPT_NONE, method_monitor, usage_bluechi}, { "metrics", 1, 1, OPT_NONE, method_metrics, usage_bluechi}, { "enable", 2, ARG_ANY, OPT_FORCE | OPT_RUNTIME | OPT_NO_RELOAD, method_enable, usage_bluechi}, - { "disable", 2, ARG_ANY, OPT_NONE, method_disable, usage_bluechi}, + { "disable", 2, ARG_ANY, OPT_NO_RELOAD, method_disable, usage_bluechi}, { "daemon-reload", 1, 1, OPT_NONE, method_daemon_reload, usage_bluechi}, { "status", 0, ARG_ANY, OPT_WATCH, method_status, usage_bluechi}, { "set-loglevel", 1, 2, OPT_NONE, method_set_loglevel, usage_bluechi},