====== who.sh ====== ^ Author | [[ goldfndr@gmail.com | Richard Finegold ]] | ^ Compatibility | Xymon 4.2 | ^ Requirements | who column status from BBWin clients | ^ Download | None | ^ Last Update | 2012-05-03 | ===== Description ===== This gathers all of the logins on monitored hosts into one listing. Quickly see if you left yourself logged into machines! ===== Installation ===== * Copy the script into your $BBEXT directory. * Change the KNOWNCONSOLE and KNOWNCONSOLEDESC values to match your network's setup; many monitored hosts won't have a perpetual console logon. * Try running it directly, see if it gives any output. * Call it from a launcher line; send output to www/who.html, for example. * Add resulting file to your menu.js. ===== Source ===== ==== who.sh ==== # "who" report, for bbwin clients in Xymon/Hobbit/Big Brother COLUMN=who KNOWNCONSOLE=15 #If expected console logons, sum here and describe below KNOWNCONSOLEDESC="user@example, 14× xxx-dept@xxx-host" [ "$BBHOME" ] || { BBHOME=..; . ../etc/hobbitserver.cfg; BB=echo; } LOGFILE=/tmp/$COLUMN.$$.log #Filter out some totals echo "Who's on What

Who's on What

" FILTER=' /console *[0-4] /d / 0 Disc rdpwd/d /^[0-9] Idle /d /^[0-9] Down /d /^rdp-tcp *6553[67] Listen rdpwd/d /^ica-tcp *6553[67] Listen wdica/d #Server 2008 adds a couple more /^rdp-tcp *65536 Listen *$/d /^.\+services *0 Disc *$/d ' #http://support.microsoft.com/kb/186592 # Other possibilities than Idle|Listen|Active|Disc: Conn, ConnQ, Shadow, Down, Init. Servers=0 Conns=0 Console=0 Disc=0 Idle=0 icatcp=0 rdptcp=0 for S in `$BBHOME/bin/bb localhost "hobbitdboard test=$COLUMN" | sed 's/|.*//'`; do #The output of this is essentially identical to what one would get if `cat`-ing the $BBLOGS if # "hobbitd_filestore --status" was launched. $BBHOME/bin/bb localhost "hobbitdlog $S.$COLUMN" | tail -n +2 | sed "1,2d $FILTER" | sed ' #align all text flush right on a 76-column width, from sed1line #resulting columns: 1/19/44/48/56 (or 0/18/43/47/55, or 18|25|4|8|6 :a s/^.\{1,75\}$/ &/ ta ' | sed 's/^.//;s/>/\>/g' > $LOGFILE #Last sed: strip off first character and trailing spaces, HTML entity for > if [ ! -s $LOGFILE ]; then continue fi #sed 's/^\(.\{17\}\) \(.\{24\}\) \(.\{3\}\) \(.\{7\}\) \(.\{5\}\)/" cat $LOGFILE | sed "s/^\(.\{17\}\) \(.\{24\}\) \(.\{3\}\) \(.\{7\}\) \(.*\)/
Grouped by host
Host
SESSIONNAME       USERNAME                 ID  STATE   TYPE 
\1\2\3\4\5/' > $LOGFILE #http://support.microsoft.com/kb/186592 Servers=$(($Servers + 1)) Conns=$(($Conns + `wc -l < $LOGFILE`)) Disc=$(($Disc + `sed '/ Disc /!d' < $LOGFILE | wc -l`)) #Disc=$(($Disc + `sed '/ Disc$/!d' < $LOGFILE | wc -l`)) Idle=$(($Idle + `sed '/ Idle/!d' < $LOGFILE | wc -l`)) Console=$(($Console + `sed '/^console /!d' < $LOGFILE | wc -l`)) icatcp=$(($icatcp + `sed '/^ica-tcp/!d' < $LOGFILE | wc -l`)) rdptcp=$(($rdptcp + `sed '/^rdp-tcp/!d' < $LOGFILE | wc -l`)) [ "`echo $S | sed /-lic/d`" ] || { Lics=$(($Lics + 1)); } #echo $S $L $M | sed 's/^/
/;s/ //g;s/$/<\/tr>/' echo "
$S
`sed 's/ *$//' < $LOGFILE`
$S\1\2\3\4\5/" >> $LOGFILE.$$ done echo "
" rm $LOGFILE #This file never gets big because it's continually overwritten with each status log echo "
" echo "" cat $LOGFILE.$$ echo "
Fully sortable
HostSessionName UserName ID State Type


" rm $LOGFILE.$$ unknowns=$(($Conns - $Disc - $Idle - $Console - $icatcp - $rdptcp)) if [ "0" -eq $Idle ]; then Idle=""; else Idle=", $idle idle"; fi if [ 0 -eq $unknowns ]; then unknowns=""; else unknowns=", $unknowns unknown"; fi Console=$(($Console - $KNOWNCONSOLE)) echo "

$Servers hosts have $Conns user connections ($Disc disconnected$Idle, $KNOWNCONSOLE+$Console console, $rdptcp rdp-tcp, $icatcp ica-tcp$unknowns) as of `date`

" #echo "

As of `date`

" echo "" echo "" echo ""
===== Known Bugs and Issues ===== Probably needs translation from Xymon 4.2 to Xymon 4.3. ===== To Do ===== ===== Credits ===== ===== Changelog ===== * **2012-05-03** * Initial release