19.4.4 Get script startup trigger
This section explains how to use the get_exec_trigger() function of eventmonitor module to acquire the cause of its own activation (event generation in the case of an event activation script) from a running script.
- <Structure of this section>
(1) Script File Example
The following is an example of a script file that acquires the activation factor (occurrence event) of an event activation script.
import sys
import extlib.eventmonitor ..1
dict = extlib.eventmonitor.get_exec_trigger () ..2
if dict['type'] == extlib.eventmonitor.APPLET : ..3
# applet
if dict['applet']['type'] == extlib.eventmonitor.TIMER_EVT : ..4
# Timer Events
if dict['applet']['condition'][extlib.eventmonitor.TIMER_TYPE] == \
extlib.eventmonitor.CRON :
# cron timer
# Display the string of cron monitoring conditions
print("[condition]",file=sys.stderr)
print(dict['applet']['condition'][extlib.eventmonitor.CRON],file=sys.stderr)
elif dict['applet']['condition'][extlib.eventmonitor.TIMER_TYPE] == \
extlib.eventmonitor.INTERVAL :
# interval timer
# Display the string of interval monitoring condition
print("[condition]",file=sys.stderr)
print(dict['applet']['condition'][extlib.eventmonitor.INTERVAL],
file=sys.stderr)
elif dict['applet']['type'] == extlib.eventmonitor.SYSMSG_EVT : ..5
# Operation Message Event
## Display the string of operation message monitoring conditions
print("[condition]",file=sys.stderr)
## Event Level
print("SYSMSG_EVENT_LEVEL:" + str(dict['applet']['condition']
[extlib.eventmonitor.SYSMSG_EVENT_LEVEL]),file=sys.stderr)
## Display the operational message of the event occurrence cause
print("[trigger system message]",file=sys.stderr)
## Occurrence time
print("SYSMSG_TIME:" + dict['applet']['trigger']
[extlib.eventmonitor.SYSMSG_TIME],file=sys.stderr)
## Message identifier
print("SYSMSG_MSG_ID:" + str(hex(dict['applet']['trigger']
[extlib.eventmonitor.SYSMSG_MSG_ID])),file=sys.stderr)
sys.exit() |
-
Import the module.
-
Calls a function to acquire the activation factor (occurrence event).
-
Determines whether the script activation factor is the applet function (event startup script).
-
Obtains the monitoring condition when the activation factor is timer monitoring.
-
Obtains the monitoring conditions when the activation factor is the operation message monitoring and information about the operation message that caused the activation.