Changeset 1759

Show
Ignore:
Timestamp:
12/03/08 12:18:36 (1 month ago)
Author:
ton
Message:

Nagconfgen now only looks in the new RRD directory for
performance data

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/DEV-opsview3/opsview-core/bin/nagconfgen.pl

    r1682 r1759  
    683683                                # Restrict to Active because perfdata only on active at the moment 
    684684                                # We use notes_url in Runtime::Searches to know if a service has perfdata or not 
    685                                 if ( ($s->checktype->id == 1 or $s->checktype->id == 5) && ($s->supports_performance(host=>$h, rrddir=>Opsview::Config->root_dir."/var/rrd") == 1)) { 
     685                                if ( ($s->checktype->id == 1 or $s->checktype->id == 5) && ($s->supports_performance(host=>$h) == 1)) { 
    686686                                        unless ($test) {  
    687687                                                print OUTFILE  
     
    797797                        if ($monitoringserver->is_master) { 
    798798                                print OUTFILE " notes   ".$snmp_interfaces_defaults->servicegroup->name.':'.$snmp_interfaces_defaults->description."\n"; 
    799                                 if ($snmp_interfaces_defaults->supports_performance(host=>$h, rrddir=>Opsview::Config->root_dir."/var/rrd", name => $service_name ) == 1) { 
     799                                if ($snmp_interfaces_defaults->supports_performance(host=>$h, name => $service_name ) == 1) { 
    800800                                        unless ($test) { 
    801801                                                print OUTFILE  
  • branches/DEV-opsview3/opsview-core/lib/Opsview/ServiceBase.pm

    r1711 r1759  
    2424package Opsview::ServiceBase; 
    2525use strict; 
     26use Opsview::Config; 
     27use Utils::Nagiosgraph; 
    2628 
    2729=item $obj->notifications_enabled  
     
    3739} 
    3840 
    39 =item $self->supports_performance( host=>$host, rrddir=>"$dir" ) 
     41=item $self->supports_performance( host=>$host ); 
    4042 
    41 Checks filesystem for an rrd in rrddir of name $host->name."_".$self->name."_"*
     43Checks filesystem for a directory "$rrddir/$hostname/$servicename", which is the name from the new-style RRDs
    4244If found, returns 1. 
    4345 
    4446=cut 
    4547 
    46 # Copied from nagiosgraph 
    47 sub urlencode { 
    48         $_[0] =~ s/([\W])/"%" . uc(sprintf("%2.2x", ord($1)))/eg; 
    49         return $_[0]; 
    50 
    51  
    52 # We cache the rrdfiles in the directory. This is okay because supports_performance is 
    53 # only called from nagconfgen 
    54 my @rrdfiles; 
     48my $rrddir = Opsview::Config->root_dir."/var/rrd"; 
    5549sub supports_performance { 
    5650        my $self = shift; 
     
    5852        my $name = $args{name} || $self->name; 
    5953 
    60         unless (@rrdfiles) { 
    61                 opendir D, $args{rrddir} or die "Cannot open rrddir: $args{rrddir}"; 
    62                 @rrdfiles = readdir D; 
    63                 closedir D; 
    64         } 
    65         my $f = urlencode($args{host}->name."_".$name); 
    66         foreach $_ (@rrdfiles) { 
    67                 next unless /^${f}_/; 
     54        if (-e "$rrddir/". urlencode($args{host}->name). "/". urlencode($name) ) { 
    6855                return 1; 
    6956        }