Zenoss daemon status in bash prompt
written by Ian McCracken
at Wednesday, February 10, 2010
Seeing as how I bring Zenoss processes up and down forty times a day, I can get confused about what's running, and zenoss status
gives me a bunch of stuff I don't care about. So I wrote this bash function to output a simple string representing my running daemons.
zends () { RESULT="" OUTPUT="`ps aux | grep $ZENHOME`" SEARCHFOR="zeoctl:z (zopectl|Startup/run.py):Z zenhub:h zenjobs:j" for f in $SEARCHFOR; do if [ -n "`echo \"$OUTPUT\" | egrep \"${f%:*}\"`" ]; then RESULT=${RESULT}${f#*:} fi done echo $RESULT }
This iterates over
regex:letter
pairs and checks the ps
output to see if a process matches. If so, it appends the letter to the string.Then I added it into my prompt in
~/.bashrc
:PS1="[...snip...]$(zends)[...snip...] $"
Now my prompt looks like this:
ian | zhj | 10.42.1.7 | core/Products (devdetail) $
And I can tell at a glance that ZEO, zenhub and zenjobs are running, but not Zope.