Xymon Mailing List Archive search

How to run an arbitary script on the client end?

18 messages in this thread

list Dave Haertig · Fri, 8 Jun 2007 14:06:41 -0600 ·
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!
list Charles Jones · Fri, 08 Jun 2007 13:48:59 -0700 ·
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
quoted from Dave Haertig

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!
list Dave Haertig · Fri, 8 Jun 2007 15:12:45 -0600 ·
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!
quoted from Charles Jones


From: Charles Jones [mailto:user-e86b4aeade4e@xymon.invalid] 
Sent: Friday, June 08, 2007 2:49 PM
To: user-ae9b8668bcde@xymon.invalid
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" <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!
list Dave Haertig · Fri, 8 Jun 2007 15:41:04 -0600 ·
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`
quoted from Dave Haertig


From: Haertig, David F (Dave) [mailto:user-68874b735d77@xymon.invalid] 
Sent: Friday, June 08, 2007 3:13 PM
To: user-ae9b8668bcde@xymon.invalid
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:user-e86b4aeade4e@xymon.invalid] 
Sent: Friday, June 08, 2007 2:49 PM
To: user-ae9b8668bcde@xymon.invalid
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" <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!
list Charles Jones · Fri, 08 Jun 2007 14:44:53 -0700 ·
Heh, I'm guessing Henrik included some sort of sanitizing of the log directive so that you couldn't do things like that.
quoted from Dave Haertig

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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:13 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 2:49 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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!
list Dave Haertig · Fri, 8 Jun 2007 18:36:06 -0600 ·
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!
quoted from Charles Jones


From: Charles Jones [mailto:user-e86b4aeade4e@xymon.invalid] 
Sent: Friday, June 08, 2007 3:45 PM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid] 
	Sent: Friday, June 08, 2007 3:13 PM
	To: user-ae9b8668bcde@xymon.invalid
	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:user-e86b4aeade4e@xymon.invalid] 
	Sent: Friday, June 08, 2007 2:49 PM
	To: user-ae9b8668bcde@xymon.invalid
	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" <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!
list Dave Haertig · Sat, 9 Jun 2007 14:37:49 -0600 ·
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!
quoted from Dave Haertig


From: Haertig, David F (Dave) [mailto:user-68874b735d77@xymon.invalid] 
Sent: Friday, June 08, 2007 6:36 PM
To: user-ae9b8668bcde@xymon.invalid
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:user-e86b4aeade4e@xymon.invalid] 
Sent: Friday, June 08, 2007 3:45 PM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid] 
	Sent: Friday, June 08, 2007 3:13 PM
	To: user-ae9b8668bcde@xymon.invalid
	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:user-e86b4aeade4e@xymon.invalid] 
	Sent: Friday, June 08, 2007 2:49 PM
	To: user-ae9b8668bcde@xymon.invalid
	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" <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!
list Rolf Schrittenlocher · Mon, 11 Jun 2007 08:05:34 +0200 ·
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
quoted from Dave Haertig
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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 6:36 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:45 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:13 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 2:49 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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: (XX) XX - XXX XXXXX   Fax: (XX) XX XXX XXXXX
LBS: user-1e39a1813094@xymon.invalid
Persoenlich: user-6ea8e907e200@xymon.invalid
list Dave Haertig · Mon, 11 Jun 2007 07:28:21 -0600 ·
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!  ;-)
quoted from Rolf Schrittenlocher


-----Original Message-----
From: Rolf Schrittenlocher [mailto:user-af137d856faa@xymon.invalid] Sent: Monday, June 11, 2007 12:06 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 6:36 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:45 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:13 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 2:49 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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: (XX) XX - XXX XXXXX   Fax: (XX) XX XXX XXXXX
LBS: user-1e39a1813094@xymon.invalid
Persoenlich: user-6ea8e907e200@xymon.invalid
list Dave Haertig · Mon, 11 Jun 2007 12:01:25 -0600 ·
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. 
quoted from Dave Haertig
-----Original Message-----
From: Haertig, David F (Dave) [mailto:user-68874b735d77@xymon.invalid] Sent: Monday, June 11, 2007 7:28 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-af137d856faa@xymon.invalid]
Sent: Monday, June 11, 2007 12:06 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 6:36 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:45 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:13 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 2:49 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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: (XX) XX - XXX XXXXX   Fax: (XX) XX XXX XXXXX
LBS: user-1e39a1813094@xymon.invalid
Persoenlich: user-6ea8e907e200@xymon.invalid
list Henrik Størner · Mon, 11 Jun 2007 22:13:31 +0200 ·
quoted from Dave Haertig
On Mon, Jun 11, 2007 at 07:28:21AM -0600, Haertig, David F (Dave) wrote:
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!  ;-)
You're obviously doing your best to get that award. If you persist,
I might even make it official :-)


The problem you're having is that Hobbit's log monitoring tries very
hard to send only the new log entries across to the Hobbit server. So it
stores the size that the logfile has from one client cycle to the next,
and only the data that is appended is actually transferred.

So if you were continuously appending data to the logfile, it would 
probably work the way you wanted it to. I.e. you should have

   log:`date >>/tmp/dirMon.out; ...

where you append data instead of truncating the dirMon.out file with
each run of the client. 

It's OK to truncate the file once in a while, as long as Hobbit can see 
that the new file is smaller than the old one it should work. My guess is 
that the file doesn't change in size from one cycle to the next, and
then Hobbit considers it to be unchanged and doesn't send any data.


I suppose it might be an idea to have the possibility of having "add-on"
modules to the Hobbit client, which you can control through the
client-local.cfg file. So a new feature for the Hobbit client would be
to support something like
   addon:/usr/local/bin/myHobbitAddon.sh:foo
which would run the myHobbitAddon.sh script and put the output into a 
[foo] section in the client data. Does that sound ok ?


Regards,
Henrik
list Dave Haertig · Mon, 11 Jun 2007 14:14:03 -0600 ·
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.
quoted from Dave Haertig

-----Original Message-----
From: Haertig, David F (Dave) [mailto:user-68874b735d77@xymon.invalid] Sent: Monday, June 11, 2007 12:01 PM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid]
Sent: Monday, June 11, 2007 7:28 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-af137d856faa@xymon.invalid]
Sent: Monday, June 11, 2007 12:06 AM
To: user-ae9b8668bcde@xymon.invalid
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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 6:36 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:45 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-68874b735d77@xymon.invalid]
*Sent:* Friday, June 08, 2007 3:13 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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:user-e86b4aeade4e@xymon.invalid]
*Sent:* Friday, June 08, 2007 2:49 PM
*To:* user-ae9b8668bcde@xymon.invalid
*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: (XX) XX - XXX XXXXX   Fax: (XX) XX XXX XXXXX
LBS: user-1e39a1813094@xymon.invalid
Persoenlich: user-6ea8e907e200@xymon.invalid
list Thomas Kern · Mon, 11 Jun 2007 16:22:08 -0400 ·
Would this new ADDON feature be configured at the server side or on each
client? 
I have a gut reaction against some other server being able to
arbitrarily execute commands on my systems, but I know who runs our
hobbit server. I am also against having to modify each hobbit client
that I run if I come up with a new nifty ADDON. I have not looked into
the update/upgrade mechanism since I know the hobbit-server admin, but
is there some authentication of the updates/upgrades/new_ADDONs that can
be done so that they only come from a trusted source?

/Thomas Kern
/XXX-XXX-XXXX  
-----Original Message-----
From: user-ce4a2c883f75@xymon.invalid [mailto:user-ce4a2c883f75@xymon.invalid] Subject: Re: [hobbit] How to run an arbitary script on the client end?
quoted from Henrik Størner

You're obviously doing your best to get that award. If you persist,
I might even make it official :-)


The problem you're having is that Hobbit's log monitoring tries very
hard to send only the new log entries across to the Hobbit server. So it
stores the size that the logfile has from one client cycle to the next,
and only the data that is appended is actually transferred.

So if you were continuously appending data to the logfile, it would probably work the way you wanted it to. I.e. you should have

   log:`date >>/tmp/dirMon.out; ...

where you append data instead of truncating the dirMon.out file with
each run of the client. 
It's OK to truncate the file once in a while, as long as Hobbit can see that the new file is smaller than the old one it should work. My guess is that the file doesn't change in size from one cycle to the next, and
then Hobbit considers it to be unchanged and doesn't send any data.


I suppose it might be an idea to have the possibility of having "add-on"
modules to the Hobbit client, which you can control through the
client-local.cfg file. So a new feature for the Hobbit client would be
to support something like
   addon:/usr/local/bin/myHobbitAddon.sh:foo
which would run the myHobbitAddon.sh script and put the output into a [foo] section in the client data. Does that sound ok ?
list Dave Haertig · Mon, 11 Jun 2007 14:25:11 -0600 ·
Thanks for the reply.  Looks like my previous post and yours just
crossed.  as you were emaling, I was looking at logfetch.c and finding
out for myself exactly what you it is you were saying.

"... addon ... Does that sound ok ?"

You don't have to add a new feature just for me!  You do enough work on
this fantastic product!  (Do you ever sleep???!!!)

It might not be a terribly involved addition, I'd just hack into that
existing logfetch.c code and dummy up the call that tells it to process
the file from the beginning if the logfiles size has shrunk.

Thanks!
quoted from Thomas Kern

-----Original Message-----
From: Henrik Stoerner [mailto:user-ce4a2c883f75@xymon.invalid] 
Sent: Monday, June 11, 2007 2:14 PM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] How to run an arbitary script on the client end?

On Mon, Jun 11, 2007 at 07:28:21AM -0600, Haertig, David F (Dave) wrote:
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!  ;-)
You're obviously doing your best to get that award. If you persist, I
might even make it official :-)


The problem you're having is that Hobbit's log monitoring tries very
hard to send only the new log entries across to the Hobbit server. So it
stores the size that the logfile has from one client cycle to the next,
and only the data that is appended is actually transferred.

So if you were continuously appending data to the logfile, it would
probably work the way you wanted it to. I.e. you should have

   log:`date >>/tmp/dirMon.out; ...

where you append data instead of truncating the dirMon.out file with
each run of the client. 

It's OK to truncate the file once in a while, as long as Hobbit can see
that the new file is smaller than the old one it should work. My guess
is that the file doesn't change in size from one cycle to the next, and
then Hobbit considers it to be unchanged and doesn't send any data.


I suppose it might be an idea to have the possibility of having "add-on"
modules to the Hobbit client, which you can control through the
client-local.cfg file. So a new feature for the Hobbit client would be
to support something like
   addon:/usr/local/bin/myHobbitAddon.sh:foo
which would run the myHobbitAddon.sh script and put the output into a
[foo] section in the client data. Does that sound ok ?


Regards,
Henrik
list Henrik Størner · Mon, 11 Jun 2007 22:48:03 +0200 ·
quoted from Thomas Kern
On Mon, Jun 11, 2007 at 04:22:08PM -0400, Kern, Thomas wrote:
Would this new ADDON feature be configured at the server side or on each
client? 
Server-side, in the client-local.cfg file.
quoted from Thomas Kern
I have a gut reaction against some other server being able to
arbitrarily execute commands on my systems
I agree. When I wrote the client, I actually did think about doing 
something like this, but decided against it for that very reason.

And if you're the only one who wants it, then I'll probably NOT 
implement it.
quoted from Thomas Kern
but I know who runs our
hobbit server. I am also against having to modify each hobbit client
that I run if I come up with a new nifty ADDON. I have not looked into
the update/upgrade mechanism since I know the hobbit-server admin, but
is there some authentication of the updates/upgrades/new_ADDONs that can
be done so that they only come from a trusted source?
Updates are only downloaded from the Hobbit server. But apart from that,
there's no authentication of the new client code.


Regards,
Henrik
list Dave Haertig · Mon, 11 Jun 2007 15:19:30 -0600 ·
It doesn't matter to me if you add this new feature or not.  It might be
nice, but it's not a deal-breaker.

However, the ability to run arbitrary commands on the client as directed
from the server end is already there.  Via the backticks in the log
directive.  A new "addon" directive might make this easier to access an
dgive it more visibility, but the ability to do remote damage already
exists. 
quoted from Henrik Størner

-----Original Message-----
From: Henrik Stoerner [mailto:user-ce4a2c883f75@xymon.invalid] 
Sent: Monday, June 11, 2007 2:48 PM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] How to run an arbitary script on the client end?

On Mon, Jun 11, 2007 at 04:22:08PM -0400, Kern, Thomas wrote:
Would this new ADDON feature be configured at the server side or on 
each client?
Server-side, in the client-local.cfg file.
I have a gut reaction against some other server being able to 
arbitrarily execute commands on my systems
I agree. When I wrote the client, I actually did think about doing
something like this, but decided against it for that very reason.

And if you're the only one who wants it, then I'll probably NOT
implement it.
but I know who runs our
hobbit server. I am also against having to modify each hobbit client 
that I run if I come up with a new nifty ADDON. I have not looked into
the update/upgrade mechanism since I know the hobbit-server admin, but
is there some authentication of the updates/upgrades/new_ADDONs that 
can be done so that they only come from a trusted source?
Updates are only downloaded from the Hobbit server. But apart from that,
there's no authentication of the new client code.


Regards,
Henrik
list Charles Jones · Mon, 11 Jun 2007 14:44:12 -0700 ·
I had a similar idea to this once:  see http://www.hswn.dk/hobbiton/2006/09/msg00537.html
It could be handy to be able to specify running an external command, the interval to run it at, and a tag name for it in client-data (and/or perhaps option for the output to be added to a specified column on the Hobbit display).

As for executing remote commands being a security risk, other monitoring programs like Nagios do this (over ssh), and as pointed out it is already possible via using backticks in the log directive.  Honestly if someone roots your hobbit server they wouldn't need much help getting into everything else. You should be running the hobbit clients as a non-privledged user, and could even put them in a chroot jail if you want to sleep better at night :)
quoted from Dave Haertig

-Charles

Haertig, David F (Dave) wrote:
It doesn't matter to me if you add this new feature or not.  It might be
nice, but it's not a deal-breaker.

However, the ability to run arbitrary commands on the client as directed
from the server end is already there.  Via the backticks in the log
directive.  A new "addon" directive might make this easier to access an
dgive it more visibility, but the ability to do remote damage already
exists. 
-----Original Message-----
From: Henrik Stoerner [mailto:user-ce4a2c883f75@xymon.invalid] Sent: Monday, June 11, 2007 2:48 PM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] How to run an arbitary script on the client end?

On Mon, Jun 11, 2007 at 04:22:08PM -0400, Kern, Thomas wrote:
  
Would this new ADDON feature be configured at the server side or on each client?
    
Server-side, in the client-local.cfg file.

  
I have a gut reaction against some other server being able to arbitrarily execute commands on my systems
    
I agree. When I wrote the client, I actually did think about doing
something like this, but decided against it for that very reason.

And if you're the only one who wants it, then I'll probably NOT
implement it.

  
but I know who runs our
hobbit server. I am also against having to modify each hobbit client that I run if I come up with a new nifty ADDON. I have not looked into
    
the update/upgrade mechanism since I know the hobbit-server admin, but
    
is there some authentication of the updates/upgrades/new_ADDONs that can be done so that they only come from a trusted source?
    
Updates are only downloaded from the Hobbit server. But apart from that,
there's no authentication of the new client code.


Regards,
Henrik

list Rolf Schrittenlocher · Tue, 12 Jun 2007 08:12:52 +0200 ·
Hi Henrik
quoted from Dave Haertig
...
I suppose it might be an idea to have the possibility of having "add-on"
modules to the Hobbit client, which you can control through the
client-local.cfg file. So a new feature for the Hobbit client would be
to support something like
   addon:/usr/local/bin/myHobbitAddon.sh:foo
which would run the myHobbitAddon.sh script and put the output into a [foo] section in the client data. Does that sound ok ?
  
I had the same issue as Dave. I'd like to have this feature in case it is easy for you to implement it. It is no urgent need as I've workarounds now.

Thanks for all the good work you are doing here!
Rolf
quoted from Dave Haertig

-- 
Mit freundlichen Gruessen
Rolf Schrittenlocher

HRZ/BDV, Senckenberganlage 31, 60054 Frankfurt
Tel: (XX) XX - XXX XXXXX   Fax: (XX) XX XXX XXXXX
LBS: user-1e39a1813094@xymon.invalid
Persoenlich: user-6ea8e907e200@xymon.invalid