Hello,
Also ran into this, so I patched nagiosgraph to calculate the heartbeat value on a per service basis (= 3 times the interval between the first 2 service checks). I tried to post this on the nagiosgraph forum but for some strange reason I couldn't log in. Normally this patch works fine but there might be situations where a wrong heartbeat gets calculated. For example when a user reschedules a Nagios service check. The ideal solution would be a Nagios macro/environment variable that tells us the normal_check_interval for a service.
I hope someone puts this into the official version of nagiosgraph.

Regards,
Stijn




Frost, Mark {PBG} schreef:
I had this same issue at first. I later discovered that that's what the heartbeat parameter (really an RRD parameter) in the nagiosgraph config file is about. I found the default value to be way too short for the variety of checks we ran. I read about what it did and turned the interval up considerably and we've had nice graphs for everything we've got for many months now. I do with there was some way with Nagiosgraph to define per-check-type heartbeat intervals rather than one interval for everything that runs in Nagiosgraph. Mark

    ------------------------------------------------------------------------
    *From:* [EMAIL PROTECTED]
    [mailto:[EMAIL PROTECTED] *On Behalf Of
    *Jeffrey Lensen
    *Sent:* Monday, May 14, 2007 2:52 AM
    *To:* nagios-users
    *Subject:* Re: [Nagios-users] ngraph sometimes not display graph

    My experience with having Nagios creating graphs, is the problem
    that checks don't manage to finish in time, which creates faulty
    data in the RRD database. RRD has to receive new data at a certain
    time-interval in order to create proper RRD files. Since the
    execution time of Nagios checks can be somewhat unpredictable at
    times, it tends to not be able to do this in time.

    Ofcourse I don't know your Nagios setup, but that's my experience
    with a Nagios setup with over 150 hosts and 7000 checks ;)

    -----------------------------------
    Jeffrey Lensen
    System Administrator Hyves
    hyves page: http://skyler.hyves.nl
    mail/msn:   [EMAIL PROTECTED]


    Hugo van der Kooij wrote:
    On Thu, 10 May 2007, hendro budianto wrote:

    I'have a problem with nagiosgraph display.
    Some times the graph is display (have a data) but
    after a  few minutes there are no data to display.It's
    something wrong with my nagios setting ?
    I've check the ngraph.log but everything is OK, the
    REGEX grub the result to rrd file.
    Any suggestions ?

    Not much to go. So this question is unanswerable.

But about a year ago I wrote about a number of things which seem to have an impact on the proper working of ngraph.

    Hugo.


------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
------------------------------------------------------------------------

_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null


**** DISCLAIMER ****
http://www.schaubroeck.be/maildisclaimer.htm
#!/usr/bin/perl

# File:    $Id: insert.pl,v 1.1.1.1 2007/05/14 11:46:51 sg Exp $
# Author:  (c) Soren Dossing, 2005
# License: OSI Artistic License
#          http://www.opensource.org/licenses/artistic-license.php

# Modification: instead of reading a fixed rrdfile heartbeat from configfile,
# the heartbeat is calculated per service (= 3 times the interval between
# the first 2 service checks)
# -- Stijn Gruwier

use strict;
use RRDs;

# Configuration
my $configfile = '/etc/nagios/nagiosgraph.cfg';

# Main program - change nothing below

my %Config;

# Read in config file
#
sub readconfig {
  die "config file not found" unless -r $configfile;

  # Read configuration data
  open FH, $configfile;
    while (<FH>) {
      s/\s*#.*//;    # Strip comments
      /^(\w+)\s*=\s*(.*?)\s*$/ and do {
        $Config{$1} = $2;
        debug(5, "INSERT Config $1:$2");
      };
    }
  close FH;

  # Make sure log file can be written to
  die "Log file $Config{logfile} not writable" unless -w $Config{logfile};

  # Make sure rrddir exist and is writable
  unless ( -w $Config{rrddir} ) {
    mkdir $Config{rrddir};
    die "rrd dir $Config{rrddir} not writable" unless -w $Config{rrddir};
  }
}

# Parse performance data from input
#
sub parseinput {
  my $data = shift;
  #debug(5, "INSERT perfdata: $data");
  my @d = split( /\|\|/, $data);
  return ( lastcheck    => $d[0],
           hostname     => $d[1],
           servicedescr => $d[2],
           output       => $d[3],
           perfdata     => $d[4],
         );
}

# Write debug information to log file
#
sub debug { 
  my($l, $text) = @_;
  if ( $l <= $Config{debug} ) {
    $l = qw(none critical error warn info debug)[$l];
    $text =~ s/(\w+)/$1 $l:/;
    open LOG, ">>$Config{logfile}";
      print LOG scalar localtime;
      print LOG " $text\n";
    close LOG;
  }
}

# Dump to log the files read from Nagios
#
sub dumpperfdata {
  my %P = @_;
  for ( keys %P ) {
    debug(4, "INSERT Input $_:$P{$_}");
  }
}

# URL encode a string
#
sub urlencode {
  $_[0] =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
  return $_[0];
}

# Create new rrd databases if necessary
#
sub createrrd {
  my($host,$service,$start,$labels) = @_;
  my($f,$v,$t,$ds,$db);
  my($RRA_1min, $RRA_6min, $RRA_24min, $RRA_288min);

  if ( defined $Config{RRA_1min} ) {
    $RRA_1min = $Config{RRA_1min};
  } else {
    $RRA_1min = 600;
  }
  if ( defined $Config{RRA_6min} ) {
    $RRA_6min = $Config{RRA_6min};
  } else {
    $RRA_6min = 700;
  }
  if ( defined $Config{RRA_24min} ) {
    $RRA_24min = $Config{RRA_24min};
  } else {
    $RRA_24min = 775;
  }
  if ( defined $Config{RRA_288min} ) {
    $RRA_288min = $Config{RRA_288min};
  } else {
    $RRA_288min = 797;
  }

  $db = shift @$labels;
  $f = urlencode("${host}_${service}_${db}") . '.rrd';

  # vars and file for calculating the rrd-DS heartbeat 
  my($previous, $timefile);
  $timefile = urlencode("${host}_${service}_${db}") . '.time';

  debug(5, "INSERT Checking $Config{rrddir}/$f");
  unless ( -e "$Config{rrddir}/$f" ) {
  # calculating the rrd-DS heartbeat 
  if (-e "$Config{rrddir}/$timefile"){
       open(FILE, "$Config{rrddir}/$timefile") or die "nagiosgraph - insert.pl: 
can't read from timefile $!\n";
               $previous = <FILE>;
       close FILE;
       $Config{heartbeat} = ($start - $previous)*7;
       unlink "$Config{rrddir}/$timefile"
  }
  else{
       open(FILE, ">$Config{rrddir}/$timefile") or die "nagiosgraph - 
insert.pl: can't write to timefile $!\n";
               print FILE "$start\n";
       close FILE;
       exit 0;
  }
    $ds = "$Config{rrddir}/$f --start $start";
    for ( @$labels ) {
      ($v,$t) = ($_->[0],$_->[1]);
      my $u = $t eq 'DERIVE' ? '0' : 'U' ;
      $ds .= " DS:$v:$t:$Config{heartbeat}:$u:U";
    }
    $ds .= " RRA:AVERAGE:0.5:1:" . $RRA_1min;
    $ds .= " RRA:AVERAGE:0.5:6:" . $RRA_6min;
    $ds .= " RRA:AVERAGE:0.5:24:" . $RRA_24min;
    $ds .= " RRA:AVERAGE:0.5:288:" . $RRA_288min;
debug(1, "DS = $ds");

    my @ds = split /\s+/, $ds;
    debug(4, "INSERT RRDs::create $ds");
    RRDs::create(@ds);
    debug(2, "INSERT RRDs::create ERR " . RRDs::error) if RRDs::error;
  }
  return $f;
}

# Use RRDs to update rrd file
#
sub rrdupdate {
  my($file,$time,$values) = @_;
  my($ds,$c);

  $ds = "$Config{rrddir}/$file $time";
  for ( @$values ) {
    $_->[2] ||= 0;
    $ds .= ":$_->[2]";
  }

  my @ds = split /\s+/, $ds;
  debug(4, "INSERT RRDs::update ". join ' ', @ds);
  RRDs::update(@ds);
  debug(2, "INSERT RRDs::update ERR " . RRDs::error) if RRDs::error;
}

# See if we can recognize any of the data we got
#
sub parseperfdata {
  my %P = @_;

  $_="servicedescr:$P{servicedescr}\noutput:$P{output}\nperfdata:$P{perfdata}";
  evalrules($_);
}

# Check that we have some data to work on
#
sub inputdata {
  my @inputlines;
  if ( $ARGV[0] ) {
    @inputlines = $ARGV[0];
  } elsif ( defined $Config{perflog} ) {
    open PERFLOG, $Config{perflog};
      @inputlines = <PERFLOG>;
    close PERFLOG
  }

  # Quit if there are no data to process
  unless ( @inputlines ) {
    debug(4, 'INSERT No inputdata. Exiting.');
    exit 1;
  }
  return @inputlines;
}

# Process all input performance data
#
sub processdata {
  my @perfdatalines = @_;
  for my $l ( @perfdatalines ) {
    debug(5, "INSERT processing perfdata: $l");
    my %P = parseinput($l);
    dumpperfdata(%P);
    my $S = parseperfdata(%P);
    for my $s ( @$S ) {
      my $rrd = createrrd($P{hostname}, $P{servicedescr}, $P{lastcheck}-1, $s);
      rrdupdate($rrd, $P{lastcheck}, $s);
    }
  }
}

### Main loop
#  - Read config and input
#  - Update rrd files
#  - Create them first if necesary.

readconfig();
debug(5, 'INSERT nagiosgraph spawned');
my @perfdata = inputdata();

# Read the map file and define a subroutine that parses performance data
my($rules);
undef $/;
open FH, $Config{mapfile};
  $rules = <FH>;
close FH;
$rules = '
sub evalrules {
  $_=$_[0];
  my @s;
  no strict "subs";
' . $rules . '
  use strict "subs";
  debug(3, "INSERT perfdata not recognized") unless @s;
  return [EMAIL PROTECTED];
}';
undef $@;
eval $rules;
debug(2, "INSERT Map file eval error: $@") if $@;

processdata( @perfdata );
debug(5, 'INSERT nagiosgraph exited');
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to