I guess I should probably set the default time period for 24 hours and not just
12 hours. I think that would be something like hr {12am-11am}. Looking at the
documentation for time::period, it covers up to the 59th minute of the hour
when doing an hour followed by am or pm.
Also, what are the thoughts of having the configuration option be exclusive
instead of inclusive? So instead of defining when it sends emails, define when
it will not send email? Its easy enough of a change.
anthony
Anthony Ciaravalo wrote:
> i just realized a mistake in my previous email
>
> the default emailalertperiod is actually set for
> wd {Mon-Sun} hr {12am-12pm}
>
> and not
> wd {Mon-Fri} hr {12am-12pm}
>
> I just put it incorrectly in my email and since i copied and pasted into the
> email from the help section of the patch that is also wrong, but the variable
> in the script is set correctly, so it still defaults to alerting 7 days a
> week. If its patched into the tree, it needs to be corrected in the
> help section.
>
> anthony
>
>
> Anthony Ciaravalo wrote:
>> I wrote a small patch against the latest (as of yesterday) unreleased tree
>> in the mercurial repository.
>>
>> It requires another CPAN dependency. The Time::Period perl module is used
>> for defining the time period(s) for sending email alerts.
>>
>> It currently only a per service option
>> The configuration option is emailalertperiod.
>>
>> if not defined it has a default of
>> wd {Mon-Fri} hr {12am-12pm}
>>
>> period configuration options are explained in the Time::Period man page.
>> or you can check them out here
>> http://search.cpan.org/~pryan/Period-1.20/Period.pm
>>
>> I did some testing and it seems to work correctly. Let me know what you
>> think.
>>
>>
>> anthony
>>
>>
>>
>>
>>
>> --- ldirectord 2009-11-10 04:42:45.000000000 -0500
>> +++ ldirectord.new 2009-11-11 01:09:36.000000000 -0500
>> @@ -260,6 +260,14 @@
>> Default: 0
>>
>>
>> +B<emailalertperiod = >I<time period>
>> +
>> +A valid time period as specified by the Time::Period perl module for sending
>> +email alerts.
>> +
>> +Default: wd {Mon-Fri} hr {12am-12pm}
>> +
>> +
>> B<emailalertstatus =
>> >B<all>|B<none>|B<starting>|B<running>|B<stopping>|B<reloading>,...
>>
>> Comma delimited list of server states in which email alerts should be sent.
>> @@ -737,6 +745,7 @@
>> $FORKING
>> $EMAILALERT
>> $EMAILALERTFREQ
>> + $EMAILALERTPERIOD
>> $EMAILALERTSTATUS
>> $EMAILALERTFROM
>> $SMTP
>> @@ -811,6 +820,7 @@
>> use Pod::Usage;
>> #use English;
>> #use Time::HiRes qw( gettimeofday tv_interval );
>> +use Time::Period;
>> use Socket;
>> use Socket6;
>> use Sys::Hostname;
>> @@ -1229,6 +1239,7 @@
>> $EMAILALERT = "";
>> $EMAILALERTFREQ = 0;
>> $EMAILALERTFROM = undef;
>> + $EMAILALERTPERIOD = "wd {Mon-Sun} hr {12am-12pm}";
>> $EMAILALERTSTATUS = $DAEMON_STATUS_ALL;
>> $FAILURECOUNT = 1;
>> $FALLBACK = undef;
>> @@ -1257,6 +1268,7 @@
>> &config_error(0, "can not open file $CONFIG");
>> my $line = 0;
>> my $linedata;
>> + my $alertperiod;
>> while(<CFGFILE>) {
>> $line++;
>> $linedata = $_;
>> @@ -1510,6 +1522,10 @@
>> } elsif ($rcmd =~
>> /^emailalertfreq\s*=\s*(\d*)/) {
>> $1 =~ /(\d+)/ or
>> &config_error($line, "invalid email alert frequency");
>> $vsrv{emailalertfreq} = $1;
>> + } elsif ($rcmd =~
>> /^emailalertperiod\s*=\s*(.*)/) {
>> + $alertperiod=$1;
>> + (inPeriod(time, $alertperiod) !=
>> "-1") or &config_error($line, "invalid email alert period");
>> + $vsrv{emailalertperiod} = $1;
>> } elsif ($rcmd =~
>> /^emailalertstatus\s*=\s*(.*)/) {
>> $vsrv{emailalertstatus} =
>> &parse_emailalertstatus($line, $1);
>> } elsif ($rcmd =~
>> /^monitorfile\s*=\s*\"(.*)\"/ or
>> @@ -1643,6 +1659,11 @@
>> $1 =~ /(\d+)/ or &config_error($line,
>> "invalid email alert frequency");
>> $EMAILALERTFREQ = $1;
>> + } elsif ($linedata =~ /^emailalertperiod\s*=\s*(.*)/) {
>> + $alertperiod=$1;
>> + (inPeriod(time, $alertperiod) != "-1") or
>> &config_error($line,
>> + "invalid email alert period");
>> + $EMAILALERTPERIOD = $1;
>> } elsif ($linedata =~ /^emailalertstatus\s*=\s*(.*)/) {
>> $EMAILALERTSTATUS = &parse_emailalertstatus($line,
>> $1);
>> } elsif ($linedata =~ /^emailalertfrom\s*=\s*(.*)/) {
>> @@ -4193,11 +4214,18 @@
>> my $status = 0;
>> my $to_addr;
>> my $frequency;
>> + my $alertperiod;
>> my $virtual_str;
>> my $id;
>> my $statusfilter;
>> my $smtp_server;
>>
>> + $alertperiod = defined $v->{emailalertperiod} ?
>> + $v->{emailalertperiod} : $EMAILALERTPERIOD;
>> + if (inPeriod(time, $alertperiod) != "1" ){
>> + &ld_log("skipping email alert - alert period:".$alertperiod);
>> + return 0;
>> + }
>> $frequency = defined $v->{emailalertfreq} ? $v->{emailalert} :
>> $EMAILALERTFREQ;
>>
>> @@ -4226,7 +4254,7 @@
>> $smtp_server = defined $v->{smtp} ? $v->{smtp} :
>> $SMTP;
>>
>> - &ld_log("emailalert: $subject");
>> + &ld_log("emailalert($alertperiod): $subject");
>> if (defined $smtp_server) {
>> $status = &ld_emailalert_net_smtp($smtp_server, $to_addr,
>> $subject);
>> }
>>
>>
>> _______________________________________________
>> Please read the documentation before posting - it's available at:
>> http://www.linuxvirtualserver.org/
>>
>> LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
>> Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
>> or go to http://lists.graemef.net/mailman/listinfo/lvs-users
>
> _______________________________________________
> Please read the documentation before posting - it's available at:
> http://www.linuxvirtualserver.org/
>
> LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
> Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
> or go to http://lists.graemef.net/mailman/listinfo/lvs-users
_______________________________________________
Please read the documentation before posting - it's available at:
http://www.linuxvirtualserver.org/
LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
or go to http://lists.graemef.net/mailman/listinfo/lvs-users
|