You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying out different ways to handle alerting in Production environment. This is to handle
grouping alerts and mail to different mailing groups ie basically grouping Includes and Excludes for certain Email ids. This way the config1.txt would handle multiple lines of EMAIL and its corresponding Includes/Excludes, even in case a null value is passed for EMAIL.
Following where done to achieve the same:
@@ -404,7 +404,8 @@ my $fileinfo = $opt{file}[$filenumber];
}
We're done parsing the message, send an email if needed
-process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
+#process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
+invoke_process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
@@ -614,6 +615,8 @@ sub parse_config_file {
## Store locally so we can easily populate %opt at the end
my %localopt;
my $mail; # variable to keep the email for each section, parse from EMAIL: (mailid)
my %seen_mailid; # to avoid duplicate (mailid + entry)
$mail = $1 if (/^EMAIL: (.+)/); # parsing mailid whenever we read a new section
@@ -637,7 +642,8 @@ sub parse_config_file {
## If the exact same line shows up more than once ignore it.
## Failing to do so will confuse the comment hash
if (/^[\w]/ and $seenit{$_}++) {
$seen_mailid{$mail}++ if $mail;
if (/^[\w]/ and $seenit{$_}++ and !$seen_mailid{$mail}++) {
@@ -718,7 +724,11 @@ sub parse_config_file {
}
## Who to send emails to for this file
elsif (/^EMAIL:\s_(.+?)\s_$/) {
push @{$localopt{email}}, $1;
# push @{$localopt{email}}, $1;
my $m = $1;
$localopt{email_hash}{$m} = {};
@{$localopt{include}} = ();
@{$localopt{exclude}} = ();
@@ -774,7 +784,8 @@ sub parse_config_file {
}
## Which lines to exclude from the report
elsif (/^EXCLUDE:\s_(.+?)\s_$/) {
push @{$localopt{exclude}}, $1;
#push @{$localopt{exclude}}, $1;
push @{$localopt{email_hash}{$mail}->{exclude}}, $1 if $mail; # global exclude --> mailid based exclude
## Which lines to include in the report
elsif (/^INCLUDE:\s*(.+)/) {
push @{$localopt{include}}, $1;
#push @{$localopt{include}}, $1;
push @{$localopt{email_hash}{$mail}->{include}}, $1 if $mail; # global include --> mailid based include
@@ -1981,6 +1993,22 @@ sub process_line {
} ## end of process_line
+# Invoke_process_report
+# invoking process_report subroutine for each sections separately
+# ie: looping through email_hash and get each emailids and corresponding includes and excludes,
+# make a call to the original process_report after overriding global include/exclude with mailid specific include/exclude
+sub invoke_process_report {
next if ! exists $opt{configfile}{"include.$include"};
add_comments("INCLUDE: $include");
print "INCLUDE: $include\n";
}
for my $exclude (@{$opt{exclude}}) {
next if ! exists $opt{configfile}{"exclude.$exclude"};
add_comments("EXCLUDE: $exclude");
print "EXCLUDE: $exclude\n";
}
for my $m (keys %{$opt{email_hash}}) {
add_comments("EMAIL: $m");
print "\nEMAIL: $m\n";
for my $include (@{$opt{email_hash}->{$m}->{include}}) {
add_comments("INCLUDE: $include");
print "INCLUDE: $include\n";
}
for my $exclude (@{$opt{email_hash}->{$m}->{exclude}}) {
add_comments("EXCLUDE: $exclude");
print "EXCLUDE: $exclude\n";
}
}
+# for my $include (@{$opt{include}}) {
+# next if ! exists $opt{configfile}{"include.$include"};
+# add_comments("INCLUDE: $include");
+# print "INCLUDE: $include\n";
+# }
+# for my $exclude (@{$opt{exclude}}) {
+# next if ! exists $opt{configfile}{"exclude.$exclude"};
+# add_comments("EXCLUDE: $exclude");
+# print "EXCLUDE: $exclude\n";
+# }
This works as expected but downside is it parses through the pg_logs every time line EMAIL is mentioned in the cfg file. Please let me know if this can be avoided.
Regards
The text was updated successfully, but these errors were encountered:
Hi,
Trying out different ways to handle alerting in Production environment. This is to handle
grouping alerts and mail to different mailing groups ie basically grouping Includes and Excludes for certain Email ids. This way the config1.txt would handle multiple lines of EMAIL and its corresponding Includes/Excludes, even in case a null value is passed for EMAIL.
Following where done to achieve the same:
@@ -404,7 +404,8 @@ my $fileinfo = $opt{file}[$filenumber];
}
We're done parsing the message, send an email if needed
-process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
+#process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
+invoke_process_report() if $opt{grand_total} or $arg{mailzero} or $opt{mailzero};
@@ -614,6 +615,8 @@ sub parse_config_file {
## Store locally so we can easily populate %opt at the end
my %localopt;
@@ -629,6 +632,8 @@ sub parse_config_file {
$in_standard_comments = 0;
}
@@ -637,7 +642,8 @@ sub parse_config_file {
@@ -718,7 +724,11 @@ sub parse_config_file {
}
## Who to send emails to for this file
elsif (/^EMAIL:\s_(.+?)\s_$/) {
@@ -774,7 +784,8 @@ sub parse_config_file {
}
## Which lines to exclude from the report
elsif (/^EXCLUDE:\s_(.+?)\s_$/) {
@@ -1981,6 +1993,22 @@ sub process_line {
} ## end of process_line
+# Invoke_process_report
+# invoking process_report subroutine for each sections separately
+# ie: looping through email_hash and get each emailids and corresponding includes and excludes,
+# make a call to the original process_report after overriding global include/exclude with mailid specific include/exclude
+sub invoke_process_report {
@@ -2414,10 +2447,10 @@ sub lines_of_interest {
|| ($a->{line} <=> $b->{line});
}
elsif ($sorttype eq 'count') {
@@ -2780,16 +2813,29 @@ sub final_cleanup {
add_comments("INHERIT: $inherit");
print "INHERIT: $inherit\n";
}
+# for my $include (@{$opt{include}}) {
+# next if ! exists $opt{configfile}{"include.$include"};
+# add_comments("INCLUDE: $include");
+# print "INCLUDE: $include\n";
+# }
+# for my $exclude (@{$opt{exclude}}) {
+# next if ! exists $opt{configfile}{"exclude.$exclude"};
+# add_comments("EXCLUDE: $exclude");
+# print "EXCLUDE: $exclude\n";
+# }
This works as expected but downside is it parses through the pg_logs every time line EMAIL is mentioned in the cfg file. Please let me know if this can be avoided.
Regards
The text was updated successfully, but these errors were encountered: