Page 2 of 3
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 3:09 pm
by questrad
Yes, it is there
Thanks for pointing it.
But there is another question stay open:
Why it add already added services?
For example there is Service Group A. In this service group is services AB, AC, AD
I did Recurring Downtime for Servicegroup A for every monday at 2AM.
I can see this in Scheduled Downtime->Scheduled Service Downtime, everything is fine.
After 1 hours I see that is another additional downtimed services AB,AC,AD with different "Entry Time" but for same "Start Time End Time Type Duration".
Regards,
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 3:59 pm
by slansing
You can overlap downtime, as dictated by the Scheduled Downtime section in:
http://nagios.sourceforge.net/docs/3_0/downtime.html
It says:
If you schedule overlapping periods of downtime for a host or service (in this case the periods were 7:40pm-9:30pm and 9:20pm-1:30am), Nagios will wait until the last period of scheduled downtime is over before it allows notifications to be sent out for that host or service. In this example notifications would be suppressed for host A until 1:30am Tuesday morning.
I believe this is what you are referring to correct? If not I apologize.
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 4:08 pm
by questrad
No, I did not adding anything additional.
I do just Recurring Downtime for Service Group.
First look - fine.
But after hours the same services coming in again and again.
I can try to add it now and next time will provide the screen shot.
Thanks
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 4:34 pm
by lmiltchev
A picture is worth a thousand words.

Thanks!
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 6:19 pm
by questrad
Please see attached screen shot
Thanks
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 7:09 pm
by questrad
I think I found issue in /usr/local/nagiosxi/cron/recurringdowntime.pl.
I did changes in
.
Because in
Code: Select all
sub schedule_servicegroup($$$$$$) {
in here:
Code: Select all
foreach $sr ( @{$servicegroups{$sg}} ) {
print "$sr:$s\n";
it has following output:
Code: Select all
Scheduling servicegroup Prod_SC_CitrixFarm
SQ5VPMXENAPP003;Citrix_App_MetaFRAME_Load_Level:1368683940
It has ";" instead of ":"
But in
readdowntime2 it add following string:
Code: Select all
SQ5VPMXENAPP003:Citrix_App_MetaFRAME_Load_Level:1368683940
Here is my readdowntime2 sub (the bold is my changes):
Code: Select all
sub readdowntime2 {
my($hd,$sd,$start,$a);
my($f) = $DOWNDAT;
my($dtid);
$f = $STATUSDAT if(!$f or ! -r $f);
$f = $RETENTIONDAT if(!$f or ! -r $f);
if(!$f or ! -r $f) { readdowntime; return; }
print "Reading downtime information from $f ..." if($DEBUG);
$a = 0;
open DD, "<$f" or return;
while ( <DD> ) {
if( /^\s*hostdowntime/ ) {
$a = 1; $hd = $dtid = ""; $start = 0;
print "Hostdowntime found\n";
} elsif( /^\s*servicedowntime/ ) {
$a = 2; $hd = $sd = $dtid = ""; $start = 0;
print "Servicedowntime found\n";
} elsif( $a and /^\s*}/ ) {
if($a == 1) {
$downtime{"$hd:$start"} = 1;
print "Adding host $hd:$start:$dtid\n" if($DEBUG);
} elsif($a == 2) {
$downtime{"$hd;$sd:$start"} = 1; # here I made changes, instead of ":" I added ";"
#$downtime{"$hd:$sd:$start"} = 1;
print "Adding service $hd:$sd:$start:$dtid\n" if($DEBUG);
}
$a = 0;
} elsif( $a ) {
if( /^\s*host_name\s*=\s*(.*\S)/ ) { $hd = $1; }
elsif( /^\s*service_description\s*=\s*(.*\S)/ ) { $sd = $1; }
elsif( /^\s*start_time\s*=\s*(\d+)/ ) { $start = $1; }
elsif( /^\s*downtime_id\s*=\s*(\d+)/ ) { $dtid = $1; }
}
}
close DD;
print "Done.\n" if($DEBUG);
}
Re: Deleting Recurring Downtime Doesn't Work
Posted: Tue May 14, 2013 9:51 pm
by questrad
So, additional information.
I found following.
Some how in this variable "@{$servicegroups{$sg}}" the collect services twice from the same service group.
I did couple of changes, will provide script tomorrow after testing.
Thanks
Update:
Here is diff that i did:
Code: Select all
[root@sq5vplnagios001 ~]# diff -u /usr/local/nagiosxi/cron/recurringdowntime.pl.orig /usr/local/nagiosxi/cron/recurringdowntime.pl
--- /usr/local/nagiosxi/cron/recurringdowntime.pl.orig 2013-04-20 12:05:18.000000000 -0400
+++ /usr/local/nagiosxi/cron/recurringdowntime.pl 2013-05-14 22:47:08.000000000 -0400
@@ -195,6 +195,7 @@
sub readdowntime2 {
my($hd,$sd,$start,$a);
my($f) = $DOWNDAT;
+ my($dtid);
$f = $STATUSDAT if(!$f or ! -r $f);
$f = $RETENTIONDAT if(!$f or ! -r $f);
if(!$f or ! -r $f) { readdowntime; return; }
@@ -203,22 +204,25 @@
open DD, "<$f" or return;
while ( <DD> ) {
if( /^\s*hostdowntime/ ) {
- $a = 1; $hd = ""; $start = 0;
+ $a = 1; $hd = $dtid = ""; $start = 0;
+ print "Hostdowntime found\n";
} elsif( /^\s*servicedowntime/ ) {
- $a = 2; $hd = $sd = ""; $start = 0;
+ $a = 2; $hd = $sd = $dtid = ""; $start = 0;
+ print "Servicedowntime found\n";
} elsif( $a and /^\s*}/ ) {
if($a == 1) {
$downtime{"$hd:$start"} = 1;
- print "Adding $hd:$start\n" if($DEBUG);
+ print "Adding host $hd:$start:$dtid\n" if($DEBUG);
} elsif($a == 2) {
- $downtime{"$hd:$sd:$start"} = 1;
- print "Adding $hd:$sd:$start\n" if($DEBUG);
+ $downtime{"$hd;$sd:$start"} = 1;
+ print "Adding service $hd:$sd:$start:$dtid\n" if($DEBUG);
}
$a = 0;
} elsif( $a ) {
if( /^\s*host_name\s*=\s*(.*\S)/ ) { $hd = $1; }
elsif( /^\s*service_description\s*=\s*(.*\S)/ ) { $sd = $1; }
elsif( /^\s*start_time\s*=\s*(\d+)/ ) { $start = $1; }
+ elsif( /^\s*downtime_id\s*=\s*(\d+)/ ) { $dtid = $1; }
}
}
close DD;
@@ -257,6 +261,7 @@
return $rv;
}
sub schedule_service($$$$$$) {
+ print "chedule_service\n";
my($h,$svc,$s,$d,$u,$c) = @_;
my($rv);
$u = "Automatic" if(!$u);
@@ -314,6 +319,9 @@
return $rv;
}
sub schedule_servicegroup($$$$$$) {
+#schedule_servicegroup($sref->{servicegroup_name} ,$next,$sref->{duration},$sref->{user},$sref->{comment},$sref->{svcalso});
+# sg s d u c sa
+ print "chedule_servicegroup\n";
my($sg,$s,$d,$u,$c,$sa) = @_;
my($rv,$sr);
$u = "Automatic" if(!$u);
@@ -325,11 +333,26 @@
print "Scheduling servicegroup $sg\n" if($DEBUG);
$rv = 0;
return "Servicegroup $sg not recognised!" if(!defined $servicegroups{$sg}) ;
+ print @{$servicegroups{$sg}};
+ print "\n";
foreach $sr ( @{$servicegroups{$sg}} ) {
+ print "$sr:$s - ";
+ my $test_v = $downtime{"$sr:$s"};
+ print "$test_v\n";
+ print "sa - $sa\n";
+ #my @test_v = %downtime;
+ #print "@test_v";
+
if( !defined $downtime{"$sr:$s"} ) {
# $rv = sendcmd "SCHEDULE_SVC_DOWNTIME;$sr;$s;".($s+($d*60)).";1;0;$u;$c";
$rv = sendcmd "SCHEDULE_SVC_DOWNTIME;$sr;$s;".($s+($d*60)).";1;0;".($d*60).";$u;$c";
+ if (!$rv){
+ print "Adding added downtime";
+ $downtime{"$sr:$s"} = 1;
+ };
+ print "rv - $rv";
if($sa) {
+ print "if sa";
# $rv = sendcmd "SCHEDULE_SVC_DOWNTIME;$sr;$s;".($s+($d*60)).";1;0;$u;$c" if(!$rv);
$rv = sendcmd "SCHEDULE_SVC_DOWNTIME;$sr;$s;".($s+($d*60)).";1;0;".($d*60).";$u;$c" if(!$rv);
}
@@ -380,8 +403,10 @@
}
}
close CFG;
+ print "@schedules\n";
return 0;
}
+
sub numerically { $a<=>$b; }
my %dow = ( mon=>1, tue=>2, wed=>3, thu=>4, fri=>5, sat=>6, sun=>0 );
sub parse_days($) {
@@ -409,9 +434,11 @@
# Identify 'now'.
@lt = localtime($T);
($dow,$h,$min,$d,$m,$y) = ($lt[6],$lt[2],$lt[1],$lt[3],$lt[4],$lt[5]);
-print "\n now: $dow,$h,$min,$d,$m,$y \n";
+ print "\n now: $dow,$h,$min,$d,$m,$y \n";
# Loop through all known schedules, find their next due time
foreach $sref ( @schedules ) {
+ print "Loop through all known schedules, find their next due time";
+ print "$sref\n";
if($DEBUG) {
if(defined $sref->{comment}) {
print $sref->{comment} .": ";
Re: Deleting Recurring Downtime Doesn't Work
Posted: Wed May 15, 2013 2:43 pm
by abrist
Thanks. Let us know.
Re: Deleting Recurring Downtime Doesn't Work
Posted: Wed May 15, 2013 2:44 pm
by slansing
Interesting, how are the changes working out for you?
Re: Deleting Recurring Downtime Doesn't Work
Posted: Wed May 15, 2013 3:06 pm
by questrad
Perfect.
it works us expected - no any doubled services from Recc Down timed service group.
Of course - most of added line is for debug purposes.
This issue happened when we have migrated from 2011 to 2012 version.
In 2011 everything was fine, without any issues.
Regards,