I’m playing with it now and finding that it is not quite what I hoped I could do.
If I have a thread last read alert, to trigger every 5 minutes, when no messages are received, with an email action, I will get the email every 5 minutes.
If I create a tcl alert that checks the holiday file and finds that today is not a holiday, it will fire an alert.
If I create an AND alert that combines the two, it will fire an alert if the combined condition is true.
I guess what I wanted is for the thread last read alert to only fire if the AND condition is true ( no messages and no holiday).
To do that, I need to remove the ACTION on the thread last read alert (or set the action to NONE) and put the desired ACTION on the AND thread.
So thats fine, it accomplishes the goal, but it also means that for every ‘real’ alert, like a thread last read alert, I also need a separate AND alert to also check the holiday file.
So the result is doubling the number of alerts defined, plus the holiday tcl alert (or any other special alert, like an ‘outage’ alert).
Is it a lot to ask for an enhancement to Alerts to add the AND function right into an existing alert instead of creating a separate class of alerts?
I will post the code for the holiday alert here:
######################################################################
#
# Name: alerts_holiday_check
# Purpose: return a 1 if today is a holiday and a 0 if it is not
#
# UPoC type: alert tcl
#
# Returns: 1 for yes or 0 for no
#
# History: 2014/12/15 PCH created
#
proc alerts_holiday_check { args } {
set debug 1
set module “alerts_holiday_check:”
if {$debug > 1} {echo “$module debug”}
# read holiday file
set directory [hcitbllookup “alert_parms” “alerts_override_directory”]
set holidayfile [hcitbllookup “alert_parms” “holiday_file”]
set holidaypath “$directory/$holidayfile”
if {$debug > 1} {echo “$module holidaypath: $holidaypath”}
# read in holiday file
set hfile [open $holidaypath r]
set filedata [read $hfile]
close $hfile
set today [clock format [clock seconds] -f “%Y-%m-%d”]
if {$debug > 1} {echo “$module today: $today”}
set lines [split “$filedata” “n”]
foreach line $lines {
if {$debug > 2} {echo “$module line: $line”}
set date [string range “$line” 0 9]
if {$date eq $today} {
set holiday [string range “$line” 11 end]
if {$debug} {echo “[gts] $module today is a holiday: $holiday”}
set returnList {} ; lappend returnList “VALUE 1” ; return $returnList
}
}
if {$debug > 1} {echo “[gts] $module today is not a holiday”}
set returnList {} ; lappend returnList “VALUE 0” ; return $returnList
}
Here is a holiday file sample:
2014-12-15 petes day
2014-12-25 Christmas
2015-01-01 New Years Day
Here is a sample alert_parms.tbl table:
# Translation lookup table
#
prologue
who: peterheggie
date: December 16, 2014 1:38:27 PM EDT
outname: output
inname: input
bidir: 0
type: tbl
version: 4.0
end_prologue
#
dflt_passthrough=0
dflt=
dflt_encoded=false
#
debug
1
encoded=0,0
#
env
Live
encoded=0,0
#
email_from
cloverleaf@crouse.org
encoded=0,0
#
alerts_override_directory
../../data/alerts
encoded=0,0
#
outage_file
outage
encoded=0,0
#
holiday_file
holidays
encoded=0,0
#
Peter