Using a SPECTRUM Event Procedure to assert event based on time (Legacy KB ID CNC TS31063 )

Document ID : KB000051985
Last Modified Date : 14/02/2018
Show Technical Document Details
Related Issues/Questions:
Using a SPECTRUM Event Procedure to assert event based on time

Problem Environment:
Event Procedure
A customer had the following requirement:

If the event occurred between 8:00 AM and 5:00 PM, assert event X, otherwise default to event Z.

Causes of this problem:
The following is a sample Event Procedure that will check the current time when event 0xffff0000 is asserted. If the time is between 8:00 AM and 5:00 PM (0800 - 1700), event 0xffff0001 will be created. If not, event 0xffff0002 will be created. The times use the 24 hour clock time and can be changed to meet individual needs.

0xffff0000 P " \
  If( \
    And ( \
        GreaterOrEqual( GetHour( GetCurrentTime() ), \
                                 { U 8 } ),                     \
        LessOrEqual( GetHour( GetCurrentTime() ),    \
                                { U 17 } ) ),                   \
    CreateEvent( { C CURRENT_MODEL },       \
                       { H 0xffff0001 } ),                   \
    CreateEvent( { C CURRENT_MODEL },      \
                       { H 0xfffff0002 } )"

In the above example, no additional varbinds are in these events. You would have to use CreateEventWithAttributes() if you want some varbinds as well, and supply a third parameter  (e.g. GetEventAttributeList() to get a copy of the current event?s varbind values.

Please refer to the SPECTRUM 9.0 Event Configuration User Guide for more information on the use of Event Procedures.


(Legacy KB ID CNC TS31063 )