[hobbit] Who Test

Henrik Stoerner henrik at hswn.dk
Sat Jan 27 09:29:12 CET 2007


On Fri, Jan 26, 2007 at 05:51:49PM -0600, Richard Leon wrote:
> I have noticed that the client collects all of the data and then the server
> "tests" the condition.
> 
> How would I go about writing a who script that would tell me when someone is
> logged in as root?

For a server-side script, you'll be hooking into the Hobbit "client"
channel. You do that by running

   hobbitd_channel --channel=client MYSCRIPT

through an extra section in the hobbitlaunch.cfg file. You can also run
it by hand (eg for testing your script), then you must be logged in as
the "hobbit" user and then run it via "bbcmd" like this:

   bbcmd hobbitd_channel --channel=client MYSCRIPT

Your script will be getting the full client message, which looks like
this:

@@client#660157/osiris.hswn.dk|1169886036.071499|172.28.50.141|osiris.hswn.dk|linux|linux
[uptime]
 09:21:06 up 4 days,  6:53,  1 user,  load average: 0.03, 0.06, 0.01
[date]
Sat Jan 27 09:21:15 CET 2007
[who]
henrik   :0           2007-01-23 04:04
<lots more section>
@@

(Just to see what it looks like, try running 
   bbcmd hobbitd_channel --channel=client cat
 which just dumps the client data to the terminal).

Each message begins with a line with "@@client...." and ends with a
"@@" line. In between those two is a series of sections marked with
"[SECTION]", you just need to grab the "[who]" section and scan it for a
"root" login. When you've scanned a section, generate a status message
(green or red) and send it to Hobbit - the hostname of the client reporting 
this data is in the "@@client..." line, as the fourth field (delimited 
by '|' signs). For someone familiar with Perl, I think it should be
fairly straight-forward.


Regards,
Henrik




More information about the Xymon mailing list