[hobbit] How to run an arbitary script on the client end?

Haertig, David F (Dave) haertig at avaya.com
Mon Jun 11 22:14:03 CEST 2007


OK.  I see the issue now.  I perused through the source file logfetch.c
and see that it seeks forward in the logfile based on saved positions
from previous runs.  So for a logfile that is static in size, after a
few runs the client will always be seeking to the end of the logfile
before reading.  Therefore finding nothing.  logfetch.c is not looking
for the files contents to have changed, but for its length to have
increased.  That's my problem ... my logfiles length does not increase.
Its contents are simply overwritten, usually with the exact same
contents as before, so its length is fixed.

-----Original Message-----
From: Haertig, David F (Dave) [mailto:haertig at avaya.com] 
Sent: Monday, June 11, 2007 12:01 PM
To: hobbit at hswn.dk
Subject: RE: [hobbit] How to run an arbitary script on the client end?

Unfortunately, this didn't work either.  The logfile's contents are now
changing on every invokation because I'm adding the date/time to the
file, but it's still not being uploaded. 

-----Original Message-----
From: Haertig, David F (Dave) [mailto:haertig at avaya.com]
Sent: Monday, June 11, 2007 7:28 AM
To: hobbit at hswn.dk
Subject: RE: [hobbit] How to run an arbitary script on the client end?

Thanks for that info.  I'll try sticking the date in the logfile to give
it unique contents, and see it that works.

log:`date >/tmp/dirMon.out; /tmp/dirMon.ksh 2>&1 >>/tmp/dirMon.out; echo
/tmp/dirMon.out`:1000 

p.s. - It looks like I'm trying to win "The best abuse of an unintended
'feature' award" with this hack.  Wish me luck!  ;-)


-----Original Message-----
From: Rolf Schrittenlocher [mailto:Schrittenlocher at rz.uni-frankfurt.de]
Sent: Monday, June 11, 2007 12:06 AM
To: hobbit at hswn.dk
Subject: Re: [hobbit] How to run an arbitary script on the client end?

Hi Dave,

the problem is some kind of optimization in the LOG mechanism. It will
only show changes (and present the output from your script only in such
case). If there are no changes for - I think - 30 minutes, then nothing
is presented. So either you have to modify your script in a way that the
contents is identified as new by the LOG mechanism or you have to use it
as external script. I took the second choice.

greetings
Rolf
> After even more testing, it only works SOMETIMES.  :-(
>  
> The "logfile" section in the clientlog always shows the file with 
> correct timestamps.  But the "msgs" section only occassionally shows 
> the contents of the file.  Usually it doesn't.  I verified the file is

> being created and has content (all ASCII text, about 300 bytes).  I 
> was logged into the server looking manually when the Hobbit client 
> ran.  The file was recreated with a new timestamp (the actual contents

> typically don't change - which is normal for what I'm monitoring 
> here).  Even though I see the file with new timestamps and valid 
> contents, those contents don't always make it up to the Hobbit server,

> but the file's metadata always does.
>  
> Here's the entry from client-local.cfg that runs the script:
>  
> ######################
>  
> [skmsp01]
> file:/var/log/mail_statistics
> log:/var/adm/messages:10240
> log:`/home/a/prems/hobbit/helper_scripts/dirMon.ksh 2>&1
> >/tmp/dirMon.out; echo /tmp/dirMon.out`:1000
>  
> ######################
>
> And here's what shows up in the relevent sections of clientlog (the 
> msgs section being blank):
>  
> ######################
> [msgs:/tmp/dirMon.out]
>
> [logfile:/tmp/dirMon.out]
> type:100000 (file)
> mode:640 (-rw-r-----)
> linkcount:1
> owner:14171 (prems)
> group:14171 (prems)
> size:302
> clock:1181419858 (2007/06/09-14:10:58)
> atime:1181419858 (2007/06/09-14:10:58)
> ctime:1181419856 (2007/06/09-14:10:56)
> mtime:1181419856 (2007/06/09-14:10:56) ######################
>  
> Here's details on a typical /tmp/dirMon.out file:
>  
> ######################
>  
> skmsp01 /tmp > ls -l /tmp/dirMon.out
> -rw-r-----   1 prems    prems        302 Jun  9 14:20 /tmp/dirMon.out
> skmsp01 /tmp > cat /tmp/dirMon.out
> ReplicaDn   Consumer                  Supplier                  Delay
> o=domain.com skmsp02.eng.domain.com:389 skmsp01.eng.domain.com:389 0
> ReplicaDn   Consumer                  Supplier                  Delay
> o=domain.com skmsp01.eng.domain.com:389 skmsp02.eng.domain.com:389 0
> skmsp01 /tmp >
>  
> ######################
>  
> The hobbit client runs as userid 'prems', so everything looks to have 
> adequate permissions.
>  
> Any ideas on how to make this work reliably?  I tried adding a 2 
> second sleep right before the echo in the log: entry in 
> client-local.cfg.  I didn't really expect that to help, and it didn't.
>  
> Thanks in advance for any ideas!
>
> ----------------------------------------------------------------------
> --
> *From:* Haertig, David F (Dave) [mailto:haertig at avaya.com]
> *Sent:* Friday, June 08, 2007 6:36 PM
> *To:* hobbit at hswn.dk
> *Subject:* RE: [hobbit] How to run an arbitary script on the client
end?
>
> Actually, on furhter testing, it DID work!
>  
> It just takes quite a while to show up.  I run the client scripts on 
> the standard 5 minute interval, so I gave it two cycles plus (about 12
> minutes) during my testing - and nothing showed up in that interval.  
> I walked away and about 25 minutes later came back and found my data 
> in the clientlog.  Yeah!
>
> ----------------------------------------------------------------------
> --
> *From:* Charles Jones [mailto:jonescr at cisco.com]
> *Sent:* Friday, June 08, 2007 3:45 PM
> *To:* hobbit at hswn.dk
> *Subject:* Re: [hobbit] How to run an arbitary script on the client
end?
>
> Heh, I'm guessing Henrik included some sort of sanitizing of the log 
> directive so that you couldn't do things like that.
>
> Haertig, David F (Dave) wrote:
>> Hmmm...  Didn't seem to like my first test attempt (see below).  
>> Nothing showed up in my clientlog.
>>  
>> [skmsp01]
>> file:/var/log/mail_statistics
>> log:/var/adm/messages:10240
>> log:`/tmp/dirMon.ksh 2>&1 >/tmp/dirMon.log; echo /tmp/dirMon.log`
>>
>> ---------------------------------------------------------------------
>> ---
>> *From:* Haertig, David F (Dave) [mailto:haertig at avaya.com]
>> *Sent:* Friday, June 08, 2007 3:13 PM
>> *To:* hobbit at hswn.dk
>> *Subject:* RE: [hobbit] How to run an arbitary script on the client
end?
>>
>> Thanks.  Your suggestion triggered an idea on how to do this.  
>> client-local.cfg supports backticks to run a program to generate a 
>> logfile name dynamically.  So I'll try to make use of that and do 
>> something like this (haven't tested it yet):
>>  
>> Add to client-local.cfg
>> ================
>>  
>> log:`/path/to/the/program 2>&1 1>/path/to/the/logfile; echo 
>> /path/to/the/logfile`
>>  
>> If this exact syntax won't work, it should be easy to use some 
>> similar concept.  The built-in backtick processing of the log:
>> directive being the key point.
>>  
>> Thanks!
>>
>> ---------------------------------------------------------------------
>> ---
>> *From:* Charles Jones [mailto:jonescr at cisco.com]
>> *Sent:* Friday, June 08, 2007 2:49 PM
>> *To:* hobbit at hswn.dk
>> *Subject:* Re: [hobbit] How to run an arbitary script on the client
end?
>>
>> As far as I know there is no built-in functionality to dynamically 
>> execute remote scripts and get their output. Others may have better 
>> suggestions, but one way of doing it, is you could set the 
>> client-side script to be launched by the hobbit client every X 
>> minutes, (via clientlaunch.cfg). I'm not sure of the best way to get 
>> the script output back to the hobbit server though. I guess you could

>> have the script output to a logfile , and then have the hobbit server

>> monitor that log via the normal log monitoring mechanism .
>> -Charles
>>
>> Haertig, David F (Dave) wrote:
>>> Is there a way to confgure a client, via client-local.cfg or 
>>> otherwise, to run some arbitrary command on the client and send it's

>>> stdout/stderr back to the hobbit server?  I have a few simple shell 
>>> scripts that exist on some clients that it would be nice to invoke 
>>> and then read their results on the server end using the 
>>> "$BBHOME/bin/bb localhost clientlog..." method.  Similar to the way 
>>> a "file:path_to_file" directive will collect a file's metadata?  I 
>>> want something like "runprogram:path_to_program"
>>>  
>>> I am doing this currently using a server-side script that ssh'es to 
>>> the client machine and runs what it needs.  I would rather have the 
>>> normal Hobbit client collect the data output by the client-side 
>>> program, upload that, and my server-side script would parse that 
>>> resulting clientlog rather than going and collecting it's own data.
>>> If this is possible.
>>>  
>>> Thanks!
>>
>


--
Mit freundlichen Gruessen
Rolf Schrittenlocher

HRZ/BDV, Senckenberganlage 31, 60054 Frankfurt
Tel: (49) 69 - 798 28908   Fax: (49) 69 798 28817
LBS: lbs-f at mlist.uni-frankfurt.de
Persoenlich: schritte at rz.uni-frankfurt.de 


To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk

To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk

To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk



More information about the Xymon mailing list