After you subscribe to timer events and a timer event is triggered, the system executes the ops_execute() function in the Python script.
This API can only be used in the ops_condition() function of the maintenance assistant script.
# Timer event defined in the Linux cron timer description format
opsObj.timer.cron(tag, crontime)
# Cyclic timer, triggered at a specified interval
opsObj.timer.relative(tag, timelength)
# Timer triggered after a specified number of seconds elapses since zero hour of the year of 1970
opsObj.timer.absolute(tag, timelength)
# Timer triggered after a specified number of seconds elapses since a timer event is subscribed
opsObj.timer.countdown(tag, timelength)
Method |
Description |
---|---|
opsObj |
Specifies an OPS object. It is obtained through ops.ops() instantiation. |
tag |
Specifies a condition ID. The value is a string of 1 to 8 case-sensitive characters that starts with a letter and contains letters, digits, and underscores (_). Enter double quotation marks ("") or None for the only one condition. tag cannot be set to and, or, or not. |
crontime |
Specifies a cron timer description. The value is a character string. For example, * * * * * indicates that the timer is triggered every second. |
timelength |
Specifies a timer value, in seconds. |
test.py import ops def ops_condition(_ops): _ops.timer.countdown("con11", 5) _ops.correlate("con11") def ops_execute(_ops): _ops.syslog("Record an informational syslog.") return 0
A timer event is triggered 5s after the timer event is subscribed.