Re: [Nagios-devel] Deletion of the performance data log files.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Deletion of the performance data log files.

Post by Guest »

Ton,

I like the work you have done.

I have no problem working in this way. It does give instant data to the
analysis program. It is in the end a simpler solution.

I am slightly worried about the extra load on the system. My code (for
example) does extensive analysis of the data. Later stages may make
upwards of 100 calls to SQL for each line of data. (Basically, lots of
pre-processing to make analysis reporting fast.)

If option #2 is used, this can be called nightly and therefore not
effect day users trying to use Nagios as it is. Another advantage is
that being a file, the processing can be completed on other machines.
As long as a way to pass a signal to another machine to tell it to parse
can be found, and the log directory is shared.

In both cases, leaving the Nagios machine to be Nagios. Without
cludging the CPU trying to do advanced statistical analysis on the data...

I dare not mention it, since two standard methods already exist, and I
know people are patching the code to make even more methods. But can
both these new methods also be supported?

Or, make an adapter for *any* method:

Pipe the variables to a generic deamon in all and every case in a
standard format. It would then be very simple to rewrite the deamon, or
select a pre-written deamon from my self, Ton, or given with the Nagios
package...

Ben


Voon, Ton wrote:

> In my installation, I use 1. This works very well. It just reads the pipe
> and then enters the data into a database - a patch is required to open the
> perf file with "w", not "a":
>
> *** xpdfile.c Sun Jun 30 20:58:35 2002
> --- xpdfile.c.ton Fri Mar 7 14:25:55 2003
> ***************
> *** 92,98 ****
> /* open the service performance data file for writing */
> if(xpdfile_service_perfdata_file!=NULL){
>
> !
> xpdfile_service_perfdata_fp=fopen(xpdfile_service_perfdata_file,"a");
>
> if(xpdfile_service_perfdata_fp==NULL){
> snprintf(buffer,sizeof(buffer),"Warning: File '%s'
> could not be opened for w
> riting - service performance data will not be
> processed!\n",xpdfile_service_perfdata_file);
> --- 92,98 ----
> /* open the service performance data file for writing */
> if(xpdfile_service_perfdata_file!=NULL){
>
> !
> xpdfile_service_perfdata_fp=fopen(xpdfile_service_perfdata_file,"w");
>
> if(xpdfile_service_perfdata_fp==NULL){
> snprintf(buffer,sizeof(buffer),"Warning: File '%s'
> could not be opened for w
> riting - service performance data will not be
> processed!\n",xpdfile_service_perfdata_file);
>
> The daemon basically does this:
>
> # Daemonize
> my $pid = fork;
> exit if $pid;
> die "Couldn't fork: $!" unless defined $pid;
> use POSIX;
> POSIX::setsid() or die "Cannot daemonize";
>
> use lib "/opt/perl/lib/perl5/site_perl","/opt/perl/lib/site_perl";
> use DBI();
>
> print "Started insert_perfdatad daemon($$)",$/;
>
> my $dbh = DBI->connect("DBI:mysql:database=$nagios;host=localhost",
> "nagios", "burn0ut",
> {'RaiseError' => 1, AutoCommit => 1 }
> );
>
> open PIPE, " serviceperf.log";
>
> my ($sth, $time, $host, $service, $perfinfo, $hsid);
> while () {
> chop;
> ($time, $host, $service, $perfinfo) = split ("\t", $_);
> next unless ($perfinfo);
> $perfinfo =~ s/(\w)= *([\d.])/$1=$2/g; # Strip leading
> spaces
>
> $sth = $dbh->prepare("SELECT hsid from hostservice where
> host='$host' and service='$service'
> ");
> $sth->execute();
> $hsid = $sth->fetchrow;
> $sth->finish();
>
> if ($hsid) {
> $hsid = "'$hsid'";
> } else {
> $dbh->do("insert into hostservice (host, service) values
> ('$host', '$service')");
> $hsid = "LAST_INSERT_ID()";
> }
>
> $dbh->do("insert into perfdata (datetime, hsid, perfinfo) values
> (from_unixtime($time), $hsi
> d, '$perfinfo')");
> }
> close PIPE;
>
> So

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: Ben@clewett.org.uk
Locked