Alerts and Holidays

Clovertech Forums Cloverleaf Alerts and Holidays

  • Creator
    Topic
  • #121493
    Eddie
    Participant

      I am setting up alerts for our environment but there are some that need to be set with some specific date ranges Monday – Friday time: 8-17. I would like to disable certain alerts within the file if possible, during holidays. How would I set that up? If not, could I run hcistitectl -k a -A “a=name of alert.alrt” with all the alerts that would be affected by holidays?

    Viewing 1 reply thread
    • Author
      Replies
      • #121496
        Peter Heggie
        Participant

          I am very interested in any responses to your question. We have been struggling with false positives on holidays and wanted a simple way to turn off or turn on sets of alerts that should not be running on a holiday.

          We looked at using the AND alert type, to connect a “normal” alert and a holiday alert (which could be a TCL alert that would look at a calendar file and figure out if today was a holiday), but we would need to do this for every normal alert, so we could easily end up with double the number of existing alerts.

          i was hoping for an additional function contained in each alert that allows me to callout to a TCL and get a 0 or 1 return code – this would be in additional to all the other attributes of an alert.

          So…  you may have to create an alternate alert file that you would load via the command line, that has the right alerts for that holiday.

          I think this is the syntax??
          <p class=”- topic/p p”>Use this format to run a specific alert. In this example, the alert file is named foo.alert:</p>

          <pre class=”+ topic/pre pr-d/codeblock pre codeblock”><code>hcisitectl -s a -A “<var class=”+ topic/keyword sw-d/varname keyword varname”>a</var>=-cl foo.alert”</code></pre>
          We played with this once and could not get the command line command to work so hopefully you will figure it out.

          Peter Heggie

        • #121497
          David Barr
          Participant

            I’m not sure what you’re using as your alert action. You could potentially not put the holiday check in your alert rules but add it to the alert action. So if you have a script you’re calling to deliver the alert (email, calling a service, etc.), you could add something to that script to check for holidays before delivering the alert.

            I’ve got a script that automatically calculates the holidays for our organization. I don’t use this from within alerts, but we have a separate thread that can send messages to staff through a secure messenger app. There are some checks in that process to see if it’s a holiday.

            • #121498
              Eddie
              Participant
                • Yeah, I would like to see that script.
              • #121499
                David Barr
                Participant
                  Here’s the code to check if the date is a holiday.
                  # Memorial Day – (Last Monday in may)
                  # Labor Day – (First Monday in September)
                  # Thanksgiving – (4th Thursday in November)
                  # New Year’s Day – (January 1st)
                  # Independence Day – (July 4th)
                  # Christmas Eve – (December 24th)
                  # Christmas Day – (December 25th)
                  proc vmc_holidays { year } {
                      set res {}
                      # Memorial day, labor day, Thanksgiving
                      foreach { month dow lim ind } {
                          05 1 31 end
                          09 1 30 0
                          11 4 30 3
                      } {
                          set s2 {}
                          # get the numeric day of the week for the first of the month
                          set s [clock format [clock scan [format “%s%s01” $year $month]] -format %w]
                          # find the day of month of the first monday or thurs
                          set day [expr (7+$dow-$s)%7+1]
                          while { $day <= $lim } {
                              # add the date of each matching day of the week in the month to a list
                              lappend s2 [format “%s%s%02d” $year $month $day]
                              incr day 7
                          }
                          # pick out just date specified by “ind” above
                          lappend res [lindex $s2 $ind]
                      }
                      # new years, independence, christmas & eve, new years observed
                      foreach x { 0101 0704 1225 1231 } {
                          set d “$year$x”
                          set s [clock scan $d]
                          set dow [clock format $s -format %a]
                          if { $x eq “1231” && $dow ne “Fri” } {
                              # new years day observed on Fri, 12/31
                              continue
                          }
                          if { $x eq “1225” } {
                              # compute where christmas and christmas eve fall
                              if { $dow eq “Sat” } {
                                  lappend res [clock format [clock add $s -2 days] -format %Y%m%d]
                                  set s [clock add $s -1 day]
                              } elseif { $dow eq “Sun” } {
                                  lappend res [clock format [clock add $s -2 days] -format %Y%m%d]
                                  set s [clock add $s 1 day]
                              } elseif { $dow eq “Mon” } {
                                  lappend res [clock format [clock add $s 1 days] -format %Y%m%d]
                              } else {
                                  lappend res [clock format [clock add $s -1 days] -format %Y%m%d]
                              }
                          } elseif { $dow eq “Sat” } {
                              if { $x eq “0101” } {
                                  # this was observed last year
                                  continue
                              }
                              set s [clock add $s -1 day]
                          } elseif { $dow eq “Sun” } {
                              set s [clock add $s 1 day]
                          }
                          lappend res [clock format $s -format %Y%m%d]
                      }
                      return [lsort $res]
                  }
                  proc is_vmc_holiday { date } {
                      # see if the first 8 digits of the date or date/time stamp are in the list of holidays generated by the year portion of the date
                      return [expr [lsearch -exact [vmc_holidays [string range $date 0 3]] [string range $date 0 7]] >= 0]
                  }
                  • This reply was modified 6 months ago by David Barr.
            Viewing 1 reply thread
            • You must be logged in to reply to this topic.