funcshell — A Shell Interface to Func
funcshell is a shell interface to Func which provides some useful features for managing a large number of machines.
Features
- advanced client selection (you can use + and – to add/remove hosts/groups)
- tab completion
- persistent history
- a command sub-shell
- quick help (just hit the “?” key)
funcshell took a similar approach to features as Func; it allows developers to easily extend and customize its functionality using a plugin system. It also assumes the most useful commands will be the ones you write yourself. That being said, funcshell currently comes with both the command and service module.
Here are some things you can do with funcshell.
Get a list of all clients (not very useful if you have hundreds):
funcshell> set clients * funcshell> get clients webapp001.example.net webapp002.example.net webapp003.example.net webstatic001.example.net webstatic002.example.net
Assuming webapp00[1-3].example.net are in the app and bpstatic00[1-2].example.net are in the static groups; remove some clients and restart a service:
funcshell> set clients - @static;webapp001* funcshell> get clients webapp002.example.net webapp003.example.net funcshell> service httpd restart ==> webapp003.example.net <== True ==> webapp002.example.net <== True
Run a command and get the results:
funcshell> set clients - webapp003*
funcshell> set clients + webstatic002*
funcshell> command run grep MemTotal /proc/meminfo | awk '{ print $2/1024 }'
==> webstatic002.example.net :: 0 <==
4099.44
==> webapp002.example.net :: 0 <==
8198.88
Get help:
funcshell> command <TAB><TAB> exists run shell funcshell> command ? exists Check if a command exists run Run a command shell Run a command shell
Run a couple of commands in a row:
funcshell> set c<TAB> @static funcshell> command shell > du -sh /tmp ==> webstatic002.example.net :: 0 <== 7.2M /tmp ==> webstatic001.example.net :: 0 <== 3.4M /tmp > cp -r /tmp /tmp ==> webstatic002.example.net :: 1 <== cp: cannot copy a directory, `/tmp', into itself, `/tmp/tmp' ==> webstatic001.example.net :: 1 <== cp: cannot copy a directory, `/tmp', into itself, `/tmp/tmp' > asdf ==> webstatic002.example.net :: 127 <== /bin/sh: asdf: command not found ==> webstatic001.example.net :: 127 <== /bin/sh: asdf: command not found > <CTRL-D> funcshell> exit