oamAlertNotify

Broadcasts a specified NMS OAM alert message to all client applications registered for alert notification.

Prototype

DWORD oamAlertNotify ( CTAHD ctahd, const OAM_MSG *pMsg )

Argument

Description

ctahd

[in] Context handle.

pMsg

[in] Pointer to OAM_MSG structure containing the message to broadcast:

typedef struct oam_msg_tag
{
    DWORD dwMsgLen;       // Message length, including        //
                          // appended name and message strings//
    DWORD dwCode;         // Message code                     //
    DWORD dwSeverity;     // Message severity                 //
    DWORD dwOfsSzName;    // Offset to name string of         //
                          // source managed object            //
    DWORD dwOfsSzMessage; // Offset to text message string    //
    // (String data is appended here) //
} OAM_MSG;


Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_ARGUMENT

pMsg is NULL or 0.

CTAERR_SVR_COMM

Natural Access Server is not running.

OAMERR_FILE_WRITE_ERROR

Error writing to database or file.

OAMERR_SERVER_NOT_RUNNING

Supervisor is shut down.


Details

Use oamAlertNotify to generate an alert notification that is received by all registered client applications on the same Natural Access Server. An application can use oamAlertNotify even if it is not registered for alert notification.

To generate a notification, the client application constructs an OAM_MSG structure for the notification and invokes oamAlertNotify to broadcast the message. With the function invocation, the application passes the context handle to the NMS OAM service and a pointer to the OAM_MSG structure. All registered client applications on the same Natural Access Server (including the sender) receive an event.

To receive events from the NMS OAM service and from installed EMCs (such as Hot Swap and Clock Management), a client application must register with the OAM service using oamAlertRegister.

See also

oamAlertUnregister

Example

DWORD sendAlert( CTAHD ctahd, const char *pMsg, const char *pName )
{
    DWORD    ret;
    char     msgBuf[ 256 ];
    OAM_MSG *pOamMsg;
    int      nSizeMsg, nSizeName;
    char    *pc;
       
    pOamMsg = (OAM_MSG *) msgBuf;
    pOamMsg->dwCode      = OAMEVN_ALERT;
    pOamMsg->dwSeverity  = CTA_TRACE_SEVERITY_INFO;

    /* point to text space after NMS OAM message information */
    pc = (char*) pOamMsg + sizeof(OAM_MSG);
       
    /* Copy object name and message into text buffer */ 
    nSizeName = strlen( pName ) + 1;
    nSizeMsg = strlen( pMsg ) + 1;
    
    strcpy( pc, pName );
    pc += nSizeName;
    strcpy( pc, pMsg );

    /* Set up offsets to various fields within the message */
    pOamMsg->dwOfsSzName = sizeof(OAM_MSG);
    pOamMsg->dwOfsSzMessage = sizeof(OAM_MSG) + nSizeName;
    pOamMsg->dwMsgLen = sizeof(OAM_MSG) + nSizeName + nSizeMsg;

    ret = oamAlertNotify( ctahd, pOamMsg );
    if ( ret != SUCCESS )
        printf( "Can't send alert message\n" );
    
    return ret;
}