Typical flow of monitoring an event

The steps in monitoring an event is described in this topic.

  1. A process attempts to open or create a monitor file.
  2. AIX® Event Infrastructure passes the pathname of the monitor file to the appropriate event producer. The event producer verifies that the monitor file represents a valid event and that the process has access to monitor the event.
  3. The process writes information to the file specifying:
    1. The wait type (WAIT_TYPE=WAIT_IN_READ or WAIT_TYPE=WAIT_IN_SELECT). The default wait type is WAIT_IN_SELECT.
    2. When to be notified. For state change events, the user must specify CHANGED=YES. For threshold value events, the user may specify THRESH_HI=<value>, THRESH_LO=<value>, or both, depending on the capabilities of the associated event producer. There is no default for this specification, and CHANGED=YES and THRESH_*=<value> may not both be specified.
  4. AIX Event Infrastructure will then allocate the per-process block to store this information if one does not already exist for this process and fill it with the information written by the user.
  5. The process issues select() or a blocking read() on the monitor file
  6. AIX Event Infrastructure will call ahafs_evprods to check that the thresholds specified are valid for this particular event. For example, the utilFs event producer does not allow values of > 100%. If the threshold is not valid, the select() or read() call will return RC_FROM_EVPROD and upon a read of the monitor file will be EINVAL returned.
  7. For threshold value event producers, only one value is sent to the event producer for each threshold (hi or lo) for monitoring. At select() or blocking read() time, AIX Event Infrastructure will register this new threshold with the event producer if one of the following is true:
    1. If no other process is monitoring this event, the threshold (s) specified by this consumer are registered with the event producer.
    2. If there are other processes monitoring this event, then if the THRESH_LO specified by the consumer is higher than the currently monitored low threshold OR if the THRESH_HI specified by the consumer is lower than the currently monitored high threshold AIX Event Infrastructure calls into the ahafs_evprods kernel service to update the currently monitored threshold.
  8. Upon return from ahafs_evprods kernel service, the actual value of the event is returned (in some cases). If the actual value returned has already met or exceeded either threshold, the read() or select() call will return immediately and the RC_FROM_EVPROD logged in the event buffer will be EALREADY. The read() or select() calls will return 0.
  9. For state change event producers, the ahafs_evprods function is always called to register the event.
  10. Upon a successful registration, AIX Event Infrastructure sets up notification. For consumers waiting in select(), the notification is set up through selreg(). For consumers blocking in a read() call, the thread is put to sleep with e_sleep_thread().
  11. Once an event producer detects that an event has occurred, it will notify AIX Event Infrastructure with information regarding the event (i.e. information about the process triggering the event, the current value, the return code, etc.).
  12. During this callback from the event producer, AIX Event Infrastructure will:
    1. Determine the ahaNode corresponding to the event
    2. Search the list of waiting consumers to determine whose thresholds have been met or exceeded to notify with the selnotify() or e_wakeup() call. All consumers waiting on a state change event will be notified.
  13. Once the process is notified of the event, it reads from the monitor file to obtain event data. An example of output from an event is below.

    An example output for a state change event producer who has specified that a stack trace should be taken:

    BEGIN_EVENT_INFO
    TIME_tvsec=1269377315
    TIME_tvnsec=955475223
    SEQUENCE_NUM=0
    PID=2490594
    UID=0
    UID_LOGIN=0
    GID=0
    PROG_NAME=cat
    RC_FROM_EVPROD=1000
    END_EVENT_INFO

    An example for a threshold value event:

    BEGIN_EVENT_INFO
    TIME_tvsec=1269378095
    TIME_tvnsec=959865951
    SEQUENCE_NUM=0
    CURRENT_VALUE=2
    RC_FROM_EVPROD=1000
    END_EVENT_INFO
Note: Due to the asynchronous nature of process notification, the current value returned may be stale by the time a process reads the monitor file. Users are notified when the threshold is first met or exceeded, but other operations which may alter the values being monitored will not be blocked.