Xymon Mailing List Archive search

xymond_filestore - appending to files?

3 messages in this thread

list John Horne · Fri, 20 Apr 2012 17:51:13 +0100 ·
Hello,

I would like to use the 'xymond_filestore' command to append to files
when receiving information from a 'data' channel.

As far as I can see it cannot do this, but the code in
xymond/xymond_filestore.c shows that 'data' messages are appended to a
temporary file (in Xymon 4.3.7, xymond_filestore line 59). The file mode
is passed as 'a', whereas for other information types (status, notes
etc) it is 'w'.

Unfortunately the temporary file is later renamed as the live file (line
78). Since the temporary file no longer exists, it cannot be appended to
next time (so is created as a new file). The overall effect is that the
information in the data files is overwritten by any new message.

I am not sure why the file mode is 'a' in this instance when the file is
later just renamed. Should perhaps the temporary file be 'copied' to the
live file instead if the mode is 'a'? This would then allow appending to
work, but would also require some mechanism for removing the file
otherwise it might get large.

I'm also unsure how the expiry time is suppose to work. I can see that
it gets set on the file, but what then? Is there some process that later
checks the times and removes 'expired' files?


Thanks,

John.

-- 
John Horne                   Tel: +XX (X)XXXX XXXXXX
Plymouth University, UK      Fax: +XX (X)XXXX XXXXXX
list Henrik Størner · Fri, 20 Apr 2012 22:51:59 +0200 ·
Hi John,
quoted from John Horne
I would like to use the 'xymond_filestore' command to append to
files when receiving information from a 'data' channel.
[snip description of how it works]

As the man-page says, "[xymond_filestore] receives xymond messages from a xymond channel via stdin, and stores these in the filesystem in a manner that is compatible with the Big Brother daemon, bbd."

So it's a module that was written for compatibility with the way Big Brother works, and it isn't really intended for anything but that one purpose. And to be honest, I no longer remember the exact details of how Big Brother processed these messages; the last time I had a look at how BB worked was almost 10 years ago.

Going back to your original request: Having the data from "data" messages appended to a file. Like the other Xymon channels, information sent via the "data" channel is easily available to any server-side module you can think of. Just run a task out of tasks.cfg that picks up the data-channel messages:

    xymond_channel --channel=data mymodule.pl

and then write your "mymodule.pl" program to do what you like. It doesn't have to be Perl; feel free to use whatever scripting tool you fancy. I just used Perl as an example, because there is a little Perl program included with Xymon that shows how to do that - look at the xymond/xymond_rootlogin.pl program. The header-line of a "data" message is different from the "client" header that rootlogin.pl handles, but not very much so you should be able to work it out. You can see the messages by running

    xymoncmd xymond_channel --channel=data cat

while logged in as the Xymon user.

And feel free to use xymond_filestore as a starting point for writing your own data-handling program :-)


Regards,
Henrik
list John Horne · Sat, 21 Apr 2012 00:20:59 +0100 ·
quoted from Henrik Størner
On Fri, 2012-04-20 at 22:51 +0200, Henrik Størner wrote:
Hi John,
I would like to use the 'xymond_filestore' command to append to
files when receiving information from a 'data' channel.
[snip description of how it works]
Going back to your original request: Having the data from "data" messages appended to a file. Like the other Xymon channels, information sent via the "data" channel is easily available to any server-side module you can think of. Just run a task out of tasks.cfg that picks up the data-channel messages:

    xymond_channel --channel=data mymodule.pl

and then write your "mymodule.pl" program to do what you like.
Given that what I want to do is store the data, and xymond_filestore
stores data, I used that as a starting point rather than re-inventing
the wheel :-)
 It doesn't have to be Perl; feel free to use whatever scripting tool you fancy. I just used Perl as an example, because there is a little Perl program included with Xymon that shows how to do that - look at the xymond/xymond_rootlogin.pl program.
Yes, I noticed the 'xymond_rootlogin.pl' program. Thanks, it was
helpful.
quoted from Henrik Størner
 The header-line of a "data" message is different from the "client"
header that rootlogin.pl handles, but not very much so you should be
able to work it out. You can see the messages by running

    xymoncmd xymond_channel --channel=data cat
Interesting. I used the '--debug' options of xymond_channel and
xymond_filestore to dump out to the log files what they were doing. It
did show what was being sent/received, so again it was helpful in seeing
what was going on.
And feel free to use xymond_filestore as a starting point for writing your own data-handling program :-)
I suspect that will be the way I go, probably coupled with the 'usermsg'
channel so as to avoid problems with other programs using the other
channels.

Many thanks for the explanations.


John.

-- 
John Horne, Plymouth University, UK
Tel: +XX (X)XXXX XXXXXX    Fax: +XX (X)XXXX XXXXXX