Changeset 1759
- Timestamp:
- 12/03/08 12:18:36 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/DEV-opsview3/opsview-core/bin/nagconfgen.pl
r1682 r1759 683 683 # Restrict to Active because perfdata only on active at the moment 684 684 # 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)) { 686 686 unless ($test) { 687 687 print OUTFILE … … 797 797 if ($monitoringserver->is_master) { 798 798 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) { 800 800 unless ($test) { 801 801 print OUTFILE branches/DEV-opsview3/opsview-core/lib/Opsview/ServiceBase.pm
r1711 r1759 24 24 package Opsview::ServiceBase; 25 25 use strict; 26 use Opsview::Config; 27 use Utils::Nagiosgraph; 26 28 27 29 =item $obj->notifications_enabled … … 37 39 } 38 40 39 =item $self->supports_performance( host=>$host , rrddir=>"$dir" )41 =item $self->supports_performance( host=>$host ); 40 42 41 Checks filesystem for a n rrd in rrddir of name $host->name."_".$self->name."_"*.43 Checks filesystem for a directory "$rrddir/$hostname/$servicename", which is the name from the new-style RRDs. 42 44 If found, returns 1. 43 45 44 46 =cut 45 47 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; 48 my $rrddir = Opsview::Config->root_dir."/var/rrd"; 55 49 sub supports_performance { 56 50 my $self = shift; … … 58 52 my $name = $args{name} || $self->name; 59 53 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) ) { 68 55 return 1; 69 56 }
