[Mon-commit] mon mon,1.16,1.17
Brought to you by:
trockij
From: David N. <vi...@us...> - 2005-10-11 10:58:50
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16088 Modified Files: mon Log Message: Added experimental support for a global exclude_period Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mon 31 Jul 2005 16:20:02 -0000 1.16 --- mon 11 Oct 2005 10:58:57 -0000 1.17 *************** *** 419,505 **** # if (!$STOPPED) { ! foreach my $group (keys %watch) { ! foreach my $service (keys %{$watch{$group}}) { ! ! my $sref = \%{$watch{$group}->{$service}}; ! my $t = $tm - $lasttm; ! $t = 1 if ($t <= 0); ! # ! # trap timer ! # ! if ($sref->{"traptimeout"}) { ! $sref->{"_trap_timer"} -= $t; ! if ($sref->{"_trap_timer"} <= 0 && ! $tm - $sref->{"_last_trap"} > $sref->{"traptimeout"}) ! { ! $sref->{"_trap_timer"} = $sref->{"traptimeout"}; ! handle_trap_timeout ($group, $service); } - } - - # - # trap duration timer - # - if (defined ($sref->{"_trap_duration_timer"})) { - $sref->{"_trap_duration_timer"} -= $t; ! if ($sref->{"_trap_duration_timer"} <= 0) { ! set_op_status ($group, $service, $STAT_OK); ! undef $sref->{"_trap_duration_timer"}; } - } ! # ! # polling monitor timer ! # ! if ($sref->{"interval"} && $sref->{"_timer"} <= 0 && !$running{"$group/$service"}) ! { ! if (!$CF{"MAXPROCS"} || $procs < $CF{"MAXPROCS"}) ! { ! if (defined $sref->{"exclude_period"} ! && $sref->{"exclude_period"} ne "" && ! inPeriod (time, $sref->{"exclude_period"})) ! { ! debug (1, "not running $group,$service because of exclude_period\n"); ! } ! ! elsif (($sref->{"dep_behavior"} eq "m" && ! defined $sref->{"depend"} && $sref->{"depend"} ne "") ! || (defined $sref->{"monitordepend"} && $sref->{"monitordepend"} ne "")) ! { ! if (dep_ok ($sref, 'm')) { ! run_monitor ($group, $service); } ! else { ! debug (1, "not running $group,$service because of depend\n"); } ! } ! ! else ! { ! run_monitor ($group, $service); ! } ! } else ! { ! syslog ('info', "throttled at $procs processes"); ! } ! } ! ! else ! { ! $sref->{"_timer"} -= $t; ! if ($sref->{"_timer"} < 0) ! { ! $sref->{"_timer"} = 0; ! } } } --- 419,511 ---- # if (!$STOPPED) { ! if (defined $CF{"EXCLUDE_PERIOD"} ! && $CF{"EXCLUDE_PERIOD"} ne "" && ! inPeriod (time, $CF{"EXCLUDE_PERIOD"})) { ! debug (1, "not running monitors because of global exclude_period\n"); ! } else { ! foreach my $group (keys %watch) { ! foreach my $service (keys %{$watch{$group}}) { ! my $sref = \%{$watch{$group}->{$service}}; ! my $t = $tm - $lasttm; ! $t = 1 if ($t <= 0); ! # ! # trap timer ! # ! if ($sref->{"traptimeout"}) { ! $sref->{"_trap_timer"} -= $t; ! ! if ($sref->{"_trap_timer"} <= 0 && ! $tm - $sref->{"_last_trap"} > $sref->{"traptimeout"}) ! { ! $sref->{"_trap_timer"} = $sref->{"traptimeout"}; ! handle_trap_timeout ($group, $service); ! } } ! # ! # trap duration timer ! # ! if (defined ($sref->{"_trap_duration_timer"})) { ! $sref->{"_trap_duration_timer"} -= $t; ! ! if ($sref->{"_trap_duration_timer"} <= 0) { ! set_op_status ($group, $service, $STAT_OK); ! undef $sref->{"_trap_duration_timer"}; ! } } ! # ! # polling monitor timer ! # ! if ($sref->{"interval"} && $sref->{"_timer"} <= 0 && !$running{"$group/$service"}) ! { ! if (!$CF{"MAXPROCS"} || $procs < $CF{"MAXPROCS"}) { ! if (defined $sref->{"exclude_period"} ! && $sref->{"exclude_period"} ne "" && ! inPeriod (time, $sref->{"exclude_period"})) ! { ! debug (1, "not running $group,$service because of exclude_period\n"); ! } ! ! elsif (($sref->{"dep_behavior"} eq "m" && ! defined $sref->{"depend"} && $sref->{"depend"} ne "") ! || (defined $sref->{"monitordepend"} && $sref->{"monitordepend"} ne "")) ! { ! if (dep_ok ($sref, 'm')) ! { ! run_monitor ($group, $service); ! } ! ! else ! { ! debug (1, "not running $group,$service because of depend\n"); ! } ! } ! ! else ! { ! run_monitor ($group, $service); ! } } ! else { ! syslog ('info', "throttled at $procs processes"); } ! } else ! { ! $sref->{"_timer"} -= $t; ! if ($sref->{"_timer"} < 0) ! { ! $sref->{"_timer"} = 0; ! } ! } } } *************** *** 1152,1155 **** --- 1158,1168 ---- $new_CF{"MONREMOTE"} = $2; + } elsif ($1 eq "exclude_period") { + if (inPeriod (time, $2) == -1) + { + close (CFG); + return "cf error: malformed exclude_period '$2' (the specified time period is not valid as per Time::Period::inPeriod), line $line_num"; + } + $new_CF{"EXCLUDE_PERIOD"} = $2; } else { close (CFG); |