Configuration Guide Vol. 1


21.4.3 Configuring the Event Monitor Feature

This section describes how to use eventmonitor module to register, remove, and receive events.

Eventmonitor module supports the function to notify the scripts that are starting status changes (events) of the monitored target in combination with monitoring of the status of the device and the network. The following table lists the functions related to the event monitor facility.

Table 21-18: List of functions related to the event monitor facility

Capability

Function Name

Description

Event Registration

regist_sysmsg

Register operation messages to be monitored.

regist_cron_timer

Register cron timer.

regist_interval_timer

Register interval timer.

Delete Event

event_delete

Delete the registered event.

Event reception

event_receive

An event is received when an event occurs.

<Structure of this section>

(1) Script File Example

(a) Example of monitoring operational messages as events

The following is an example of registering an event that monitors operational messages as events.

Figure 21-24: Example of script description 1
import sys
import extlib.eventmonitor                                                      ..1
 
try:
    event_sysmsg=extlib.eventmonitor.regist_sysmsg(event_level="E7",
    message_id=0xabcd1234,message_text="(Error|error)")                         ..2
except Exception as e:                                                          ..3
    print('ERROR!! regist_sysmsg()',e)
    sys.exit()
 
while 1:
    dict = extlib.eventmonitor.event_receive(extlib.eventmonitor.BLOCK_ON, 0)   ..4
 
    if dict['event_id']== event_sysmsg:                                         ..5
        print('EVENT OCCURRED!!')
  1. Import the module.

  2. Register the event. Monitors the output of operation messages that satisfy the following conditions:

    • Event-Level E7

    • Message identifier abcd1234

    • The message text contains the string "Error" or "error"

  3. Checks whether the event has been registered. If registration fails, output the log and exit.

  4. Calls an event reception function.

  5. Check the return value to see if it was intended.

(b) Monitoring Events with cron Timer

The following shows an example of registering an event for monitoring an event by cron timer.

Figure 21-25: Script description example 2
import sys
import extlib.eventmonitor                                                      ..1
 
try:
    event_cron_timer = extlib.eventmonitor.regist_cron_timer('0 23 * * *')      ..2
except Exception as e:                                                          ..3
    print('ERROR!! regist_cron_timer ()',e)
    sys.exit()
 
while 1:
    dict = extlib.eventmonitor.event_receive(extlib.eventmonitor.BLOCK_ON, 0)   ..4
 
    if dict['event_id']== event_cron_timer:                                     ..5
        print('EVENT OCCURRED!!')
  1. Import the module.

  2. Registers events that occur every day at 23:00.

  3. Checks whether the event has been registered. If registration fails, output the log and exit.

  4. Calls an event reception function.

  5. Check the return value to see if it was intended.

(c) Monitoring Events with interval Timer

The following shows an example of registering an event for monitoring an event by interval timer.

Figure 21-26: Example of script description 3
import sys
import extlib.eventmonitor                                                      ..1
 
try:
    event_interval_timer = extlib.eventmonitor.regist_interval_timer(1800)      ..2
except Exception as e:                                                          ..3
    print('ERROR!! regist_interval_timer()',e)
    sys.exit()
 
while 1:
    dict = extlib.eventmonitor.event_receive(extlib.eventmonitor.BLOCK_ON, 0)   ..4
 
    if dict['event_id']== event_interval_timer:                                 ..5
        print('EVENT OCCURRED!!')
  1. Import the module.

  2. Registers events that occur every 1800 seconds.

  3. Checks whether the event has been registered. If registration fails, output the log and exit.

  4. Calls an event reception function.

  5. Check the return value to see if it was intended.

(d) Example of deleting registered events

The following is an example of deleting registered events.

Figure 21-27: Example of script description 4
import sys
import extlib.eventmonitor                                                      ..1
 
try:
    event_cron_timer = extlib.eventmonitor.regist_cron_timer('0 23 * * *')      ..2
except Exception as e:                                                          ..3
    print('ERROR!! regist_cron_timer ()',e)
    sys.exit()
 
try:
    result_dict = extlib.eventmonitor.event_delete(event_cron_timer)            ..4
    print('EVENT DELETE!!')
except:                                                                         ..5
    print('ERROR!! event_delete()')
  1. Import the module.

  2. Register the event.

  3. Checks whether the event has been registered. If registration fails, output the log and exit.

  4. Specifies the monitoring event ID of the registered event, and stops monitoring.

  5. If the stop fails, the log is output.

(e) Example of receiving events

The following example shows how to receive an event:

Figure 21-28: Example of scripting 5
import sys
import extlib.eventmonitor                                                      ..1
 
try:
    event_cron_timer = extlib.eventmonitor.regist_cron_timer('0 23 * * *')      ..2
except Exception as e:                                                          ..3
    print('ERROR!!  event_cron_timer()',e)
    sys.exit()
 
dict = extlib.eventmonitor.event_receive(extlib.eventmonitor.BLOCK_ON , 0)      ..4
 
if dict['event_id']== event_cron_timer:                                         ..5
    print('EVENT OCCURRED!! ')
  1. Import the module.

  2. Register the event.

  3. Checks whether the event has been registered. If registration fails, output the log and exit.

  4. Calls an event reception function. Received in blocking mode without receive timeout.

  5. Check the return value to see if it was intended.

(2) Discarding notification information

If the monitoring event occurs frequently, it may be discarded before the event occurrence notification is notified to the script. The following figure shows the event generation notification flow. Discard occurs when the notification reception queues in steps 1 and 2 in the figure become full.

Figure 21-29: Flow of event generation notification

[Figure Data]

  1. Queue overflow threshold of 1024 messages per priority

  2. Queue overflow threshold is 1024 messages per script

The number of discarded events (discard) displayed in the operation-command show event manager monitor can be used to check whether discarding occurred or not.