Xymon Mailing List Archive search

flushing rrd files

3 messages in this thread

list Martin Sperl · Fri, 25 Apr 2014 12:29:05 +0000 ·
Hi!

Is there a means to flush the rrd files filled in from xymond_rrd say via the "xymon"  command?

As an alternative is it possible to use the generic RRDCACHED as a replacement for the caching?
Any experience with that?

Thanks,
                                Martin


This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement,
you may review at http://www.amdocs.com/email_disclaimer.asp
list Jeremy Laidman · Tue, 29 Apr 2014 12:33:23 +1000 ·
I think work would need to be done to integrate with rrdcached.

The RRD stats are cached by xymond_rrd.  The showgraph.cgi binary sends a
flush command to the xymond_rrd instances, via UNIX sockets, requesting a
cache flush, so that graphs are up-to-date.  You could probably emulate
this by running showgraph.cgi from the command-line.  Like so:

SCRIPT_NAME=showgraph.sh REQUEST_METHOD=GET QUERY_STRING="host=
hostname.example.com&service=conn" /usr/lib/xymon/server/bin/showgraph.cgi
/dev/null
In this case, the "conn" is not used for anything (all RRD files are
flushed), but has to be a (I think) valid RRD filename (without the
extension) or graph name (defined in graphs.cfg).

Also, if you can send a string directly to the two UNIX sockets, you can
cause a flush.  The format is simply the hostname in slashes, like "/
hostname.example.com" and so you can probably achieve this using modern
versions netcat or socat, or other things that can write to sockets.

And just for fun, here's an implementation in Perl.

Cheers
Jeremy

#!/usr/bin/perl -Tw

my $hostname=shift;
die "Specify hostname\n" unless defined($hostname);

my $socketdir=$ENV{XYMONTMP};
die "XYMONTMP not defined, run from xymoncmd\n" unless $socketdir;

use Socket;
socket(SOCK, AF_UNIX, SOCK_DGRAM, 0)  or die "socket: $!\n";
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
my $flags = fcntl(SOCK, F_SETFL, O_NONBLOCK) or die "fcntl: $!\n";

opendir(DIR,$socketdir) or die "$!: $socketdir\n";
while(my $socketfile=readdir(DIR)) {
        next unless substr($socketfile,0,7) eq "rrdctl.";
        my $socketpath="$socketdir/$socketfile";
        if (! -e $socketpath) {
                warn "not found: $socketpath\n";
                next;
        }
        if (! -w $socketpath) {
                warn "not writeable: $socketpath\n";
                next;
        }
        if (! -S $socketpath) {
                warn "not a socket: $socketpath\n";
                next;
        }

        $socketaddr=sockaddr_un($socketpath);

        if (defined(send(SOCK, "/$hostname/", 0, $socketaddr))) {
                print "Flush command for '$hostname' sent to $socketfile\n";
        } else {
                warn "Flush command for '$hostname' failed to send to
socket $socketfile\n";
quoted from Martin Sperl
        }
}


On 25 April 2014 22:29, Martin Sperl <user-bff3440e3bef@xymon.invalid> wrote:
 Hi!


Is there a means to flush the rrd files filled in from xymond_rrd say via
the "xymon"  command?


As an alternative is it possible to use the generic RRDCACHED as a
replacement for the caching?

Any experience with that?


Thanks,

                                Martin


 This message and the information contained herein is proprietary and
confidential and subject to the Amdocs policy statement, you may review at
http://www.amdocs.com/email_disclaimer.asp

list Martin Sperl · Tue, 29 Apr 2014 11:02:47 +0000 ·
Thanks - the problem is that those sockets change so you have to "guess" their path and see if it is functional (as with your perl example - in my case there are actually 16 socket files in temp and I have to iterate over all of them to find the 2 that are actually working - slightly stupid...)

Obviously this also does not work from a remote node which only has access to the rrd files via NFS...
Meaning I have to write a http proxy for that...

So I was wondering if xymond_rrd with the --no-cache would use the RRDCache if set in the environment.
My guess would be I need to use a different env file which has RRDCACHED_ADDRESS set correctly (which rrdtool makes use of automatically if the ENV is set) and then configure xymond_rrd to use that environment instead....
If that works then that rrd-specific caching could get removed as a whole - with the exception of the need for

I just want to avoid testing this on our live system, so I was asking if anyone has experience with this...

Martin
quoted from Jeremy Laidman

From: Jeremy Laidman [mailto:user-71895fb2e44c@xymon.invalid]
Sent: Dienstag, 29. April 2014 04:33
To: Martin Sperl
Cc: xymon at xymon.com
Subject: Re: [Xymon] flushing rrd files

I think work would need to be done to integrate with rrdcached.

The RRD stats are cached by xymond_rrd.  The showgraph.cgi binary sends a flush command to the xymond_rrd instances, via UNIX sockets, requesting a cache flush, so that graphs are up-to-date.  You could probably emulate this by running showgraph.cgi from the command-line.  Like so:

SCRIPT_NAME=showgraph.sh REQUEST_METHOD=GET QUERY_STRING="host=hostname.example.com<http://hostname.example.com>&service=conn"; /usr/lib/xymon/server/bin/showgraph.cgi >/dev/null

In this case, the "conn" is not used for anything (all RRD files are flushed), but has to be a (I think) valid RRD filename (without the extension) or graph name (defined in graphs.cfg).

Also, if you can send a string directly to the two UNIX sockets, you can cause a flush.  The format is simply the hostname in slashes, like "/hostname.example.com<http://hostname.example.com>"; and so you can probably achieve this using modern versions netcat or socat, or other things that can write to sockets.
quoted from Jeremy Laidman

And just for fun, here's an implementation in Perl.

Cheers
Jeremy

#!/usr/bin/perl -Tw

my $hostname=shift;
die "Specify hostname\n" unless defined($hostname);

my $socketdir=$ENV{XYMONTMP};
die "XYMONTMP not defined, run from xymoncmd\n" unless $socketdir;

use Socket;
socket(SOCK, AF_UNIX, SOCK_DGRAM, 0)  or die "socket: $!\n";
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
my $flags = fcntl(SOCK, F_SETFL, O_NONBLOCK) or die "fcntl: $!\n";

opendir(DIR,$socketdir) or die "$!: $socketdir\n";
while(my $socketfile=readdir(DIR)) {
        next unless substr($socketfile,0,7) eq "rrdctl.";
        my $socketpath="$socketdir/$socketfile";
        if (! -e $socketpath) {
                warn "not found: $socketpath\n";
                next;
        }
        if (! -w $socketpath) {
                warn "not writeable: $socketpath\n";
                next;
        }
        if (! -S $socketpath) {
                warn "not a socket: $socketpath\n";
                next;
        }

        $socketaddr=sockaddr_un($socketpath);

        if (defined(send(SOCK, "/$hostname/", 0, $socketaddr))) {
                print "Flush command for '$hostname' sent to $socketfile\n";
        } else {
                warn "Flush command for '$hostname' failed to send to socket $socketfile\n";
        }
}


On 25 April 2014 22:29, Martin Sperl <user-bff3440e3bef@xymon.invalid<mailto:user-bff3440e3bef@xymon.invalid>> wrote:
Hi!

Is there a means to flush the rrd files filled in from xymond_rrd say via the "xymon"  command?

As an alternative is it possible to use the generic RRDCACHED as a replacement for the caching?
Any experience with that?

Thanks,
                                Martin


This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp