Daemon monitor and live status
Recently I added 2 new functionnalities to the Licorn® daemon and the CLI interface. The first is a simple extension of the existing get status. There is now a -m CLI switch, which implies that the CLI process stays connected to the daemon, and updates the status on the terminal. The refresh delay and various parameters (fixed refresh count / maximum refresh time / clear screen between outputs) are configurable via other cli switches; see get status --help for details. Just remember this command:
get status -m
Default parameters are cool anyway (refresh time: 1 second, clear screen: yes, refresh count: infinite, max. refresh time: infinite). Just hit Control-C to stop the status updates when you're done.
The second functionnality could be seen as an internal sniffer, in the daemon. It's called monitor mode. With a new CLI command (get events, not to name it), you can access any internal event, decision or message generated in the daemon. This monitor mode will eventually supersede the LTRACE facility, but it's not very clear at this point because the monitor could impact the daemon performance much more than LTRACE (it's always compiled in, whereas LTRACE is usable only when the Python interpreter is in debug mode).
You use the monitor mode like you use LTRACE (levels are the same for both). E.g. to display std (standard) events:
get events
Or to dump only the inotifier related events:
get events -f inotifier
You can combine them to your liking, just the same you would do with LTRACE:
get events -f 'core^system|daemon^threads'
The bonus is the full sniffing mode: just add 'logging' to the facilities you want to follow, and every output message sent by the daemon to any other CLI command (run by you or by others) will be pushed to your local monitor session:
get events -f 'core|logging'
The bonus: you can even monitor a remote daemon from your local machine. Just set the special environment variable before launching the command:
export LICORN_SERVER='IP_or_hostname' get events
And you're done! Happy monitoring, and remember: these things can easily flood your terminal!
NOTE: currently, only inotifier and logging are fully converted to monitor mode. Other parts will soon follow. The rest of the code still uses the LTRACE facility.
Daemon status available
In my last patch I added the availability to query daemon status, in two ways:
- the get status command, which can be called with argument --full. This command is complemented by get users --dump, get groups --dump and so on, which help debugging daemon internal data structures without stopping it. This method for getting the daemon status is independent from its state (forked into background or not).
- when the daemon is attached to the terminal (launched with -D), you can now type uni-letters commands to query it:
- 'f' or 'l' will toggle between normal and full status.
- [Enter] will just display a newline (usefull for manually marking spaces between different operations.
- Ctrl-L will clear the screen, like in a normal terminal.
- Ctrl-T will display the current status of the daemon (full status depends on wether you activated it before or not, beiing disabled by default and remembered across the daemon session when you set it, until terminate or restart).
- Ctrl-Y (or space) will do the same, but will clear the same first. Typing repeatedly on space will emulate a top-like behaviour, permitting to monitor the daemon status, even if it is very active.
- Ctrl-R will reload the daemon (by sending it an USR1 signal). Very useful when you modified daemon or core code, just hit R in your daemon terminal and you're done with the new code reloaded.
- Ctrl-C will break and terminate, as expected.
- Ctrl-U will terminate the daemon with a traditionnal signal 15 (similating a normal kill or killall).
- (Caution) Ctrl-K will send a real KILL signal, when the daemon is stuck.
In some rare cases (when the interactor thread is crashed, which never happens ;-) ), you will not be able to use these commands and will need to operate "à l'ancienne" (Ctrl-Z, bg, sudo killall -r licornd and al.).

rss