Doc:latest/evalguide/csa105

Revision as of 03:28, 27 August 2010 by Senthilk (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Contents

csa105 Software Alarm Management and Provisioning

Objective

The goal of this sample application is to show

  • how provisioning and alarm libraries work together to achieve a simple software alarm management
  • how COR change notification is utilized

What You Will Learn

You will learn how the Clovis Object Manager (OM) is used to achieve interactions between the alarm and provisioning libraries. In addition, two ways to report an alarm is introduced: COR change notification and fault reporting.

Code

The code in csa105 is a bit different than our previous examples. csa105 contains two components instead of one. The first component (csa105Comp) is much like the other examples. It runs within a loop printing out 'Hello World' and with each iteration it increments a counter value. Once this counter value meets or exceeds a defineable threshold, the component raises an alarm. The second component (csa105AlmLstnerComp) registers itself with SAFplus Platform as an alarm subscriber or listener. Once our first component raises the alarm our second component receives notification of this and prints some information out to a log file so that we can see.

There is also a new source file that you will see. This file is clcsa105CompalarmMetaStruct.c. This file contains definitions for the counter threshold crossing alarm. Everything in this file is generated by the IDE. We will not be customizing it.

The code can be found within the following directories

<project-area_dir>/eval/src/app/csa105Comp
<project-area_dir>/eval/src/app/csa105AlmLstner

This example is built on top of the csa104 example. We will only look at the code that has been added for this example. First we will look at the code in <project-area_dir>/eval/src/app/csa105Comp.

clCompAppMain.c
ClUint32T counter_threshold   = 55; // the value determining the counter threshold.
...
static ClRcT raise_alarm_on_counter(ClCorMOIdT, ClNameT, ClUint32T);
  

First we define and initialize the counter threshold. This is the value our counter will be compared against to determine if an alarm should be raised.
Next we declare the function that will be called to raise the alarm.

clCompAppMain.c
clCompAppInitialize():

    ...

    if (counter_threshold <= counter)
    {
        clCorMoIdServiceSet(&moId, CL_COR_SVC_ID_ALARM_MANAGEMENT);
        if (( rc = raise_alarm_on_counter (moId, appName, counter)) != CL_OK)
        {
            clprintf(CL_LOG_SEV_ERROR,"%s: Error [0x%x]: Alarm raise has failed. Exiting. ",
                        appname, rc);
            counter = 0;
            break;
        }
        counter = 0;
        continue;
    }
    ...

  

The clCompAppInitialize() function is where our main loop runs that prints 'Hello World' and increments our counter. Each time through the loop we will now compare our counter value against the threshold value. If the counter is equal to or greater than this threshold we will call our raise_alarm_on_counter function. We also set the counter back to 0.

clCompAppMain.c
static ClRcT
raise_alarm_on_counter (ClCorMOIdT moId , ClNameT compName, ClUint32T counter)
{
    ClRcT           rc = CL_OK;
    static ClUint32T       iterator = 0, lastCounter = 0;
    ClCharT str [80] = {0};
    ClAlarmInfoT *pAlarmInfo = {0};
    ClAlarmHandleT alarmHandle = {0};
    ClUint8T * pBuf = NULL;
    ClUint32T size = 0;
    ClAlarmUtilPayLoadListPtrT pPayloadList = NULL;

    
    if (lastCounter != counter)
    {
        lastCounter = counter;
        iterator = 0;
    }


    pPayloadList = clHeapAllocate(sizeof(ClAlarmUtilPayLoadListT));
    if (pPayloadList == NULL)
    {
        clprintf(CL_LOG_SEV_ERROR,"Failed to allocate the memory for the alarm payload list.");
        return CL_ERR_NO_MEMORY;
    }

    pPayloadList->numPayLoadEnteries = 1;
    pPayloadList->pPayload = clHeapAllocate(sizeof(ClAlarmUtilPayLoadT));
    if (NULL == pPayloadList->pPayload)
    {
        clprintf(CL_LOG_SEV_ERROR,"Failed while allocating payload array.");
        clHeapFree(pPayloadList);
        return CL_ERR_NO_MEMORY;
    }

    pPayloadList->pPayload[0].numTlvs = 1;
    clCorMoIdClone(&moId, &pPayloadList->pPayload[0].pMoId);

    pPayloadList->pPayload[0].pTlv = clHeapAllocate(sizeof(ClAlarmUtilTlvT));
    if (NULL == pPayloadList->pPayload[0].pTlv)
    {
        clprintf(CL_LOG_SEV_ERROR,"Failed while allocating the pTlv array. ");
        clAlarmUtilPayloadListFree(pPayloadList);
        return CL_ERR_NO_MEMORY;
    }

    sprintf(str, "[%s]: The Alarm has been raised as the counter became [%d] for [%d] time", 
            appname, counter, ++iterator);

    pPayloadList->pPayload[0].pTlv[0].type = CL_COR_UINT8;
    pPayloadList->pPayload[0].pTlv[0].value = clHeapAllocate(strlen(str) + 1);
    if (NULL == pPayloadList->pPayload[0].pTlv[0].value)
    {
        clprintf(CL_LOG_SEV_ERROR,"Failed while allocating the value for the attribute.");
        clAlarmUtilPayloadListFree(pPayloadList);
        return CL_ERR_NO_MEMORY;
    }

  
clCompAppMain.c

    pPayloadList->pPayload[0].pTlv[0].length = strlen(str) + 1;

    memset(pPayloadList->pPayload[0].pTlv[0].value, 0, strlen(str) + 1);

    memcpy(pPayloadList->pPayload[0].pTlv[0].value, str, strlen(str));


    rc = clAlarmUtilPayloadFlatten(pPayloadList, &size, &pBuf);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]. Failed while getting the flat buffer for the payload. rc[0x%x]", 
                appname, rc);
        return rc;
    }

    pAlarmInfo = clHeapAllocate (sizeof(ClAlarmInfoT) + size);
    if (NULL == pAlarmInfo)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]: Failed to allocate the memory for alarm information. ", appname);
        clAlarmUtilPayloadListFree(pPayloadList);
        clAlarmUtilPayloadBufFree(pBuf);
        return CL_ERR_NO_MEMORY;
    }

    pAlarmInfo->moId = moId;
    pAlarmInfo->probCause = CL_ALARM_PROB_CAUSE_THRESHOLD_CROSSED; 
    pAlarmInfo->severity = CL_ALARM_SEVERITY_WARNING;
    memcpy (&pAlarmInfo->compName, &compName, sizeof(ClNameT));
    pAlarmInfo->alarmState = CL_ALARM_STATE_ASSERT;
    pAlarmInfo->len = size;

    memcpy(pAlarmInfo->buff, pBuf, pAlarmInfo->len);

    clAlarmUtilPayloadListFree(pPayloadList);
    clAlarmUtilPayloadBufFree(pBuf);

    clprintf(CL_LOG_SEV_ERROR,"[%s]: Raising the alarm as the counter threashold has reached. ", appname); 

    rc = clAlarmRaise (pAlarmInfo, &alarmHandle);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"%s: [0x%x]: The alarm raise has failed. ", appname, rc);
        clHeapFree(pAlarmInfo);
        return rc;
    }  

    pAlarmInfo->alarmState = CL_ALARM_STATE_CLEAR;
    rc = clAlarmRaise (pAlarmInfo, &alarmHandle);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"%s: [0x%x]: The alarm clear has failed. ", appname, rc);
        clHeapFree(pAlarmInfo);
        return rc;
    }
        
    clHeapFree(pAlarmInfo);
    return rc;
}
  

The raise_alarm_on_counter function receives some information when called such as the application name and the counter value. It creates an ClAlarmInfoT structure and fills it with some useful information. It then calls the clAlarmRaise api twice. The first call is to raise the alarm and the second call is to clear the alarm. (Notice that the alarm state is set to CL_ALARM_STATE_ASSERT for the first call and CL_ALARM_STATE_CLEAR for the second call). The reason for this is that a given alarm is only raised once unless it is cleared. This is to avoid an alarm continually being sent.

clcsa105CompOAMPConfig.c
    ClOmClassControlBlockT pAppOmClassTbl[] =
    {
        {  
        CSA105COMP_CSA105RES_ALARM_CLASS_NAME,
        sizeof(CL_OM_ALARM_CSA105RES_CLASS),
        CL_OM_ALARM_CLASS_TYPE,
        clcsa105CompCSA105RESAlarmConstructor, 
        clcsa105CompCSA105RESAlarmDestructor,
        NULL,
        CSA105COMP_CSA105RES_ALARM_CLASS_VERSION,
        0,
        CL_MAX_OBJ,
        0,
        CSA105COMP_CSA105RES_ALARM_MAX_SLOTS,
        CL_OM_ALARM_CSA105RES_CLASS_TYPE
        },

        {  
        CSA105COMP_CSA105RES_PROV_CLASS_NAME,
        sizeof(CL_OM_PROV_CSA105RES_CLASS),
        CL_OM_PROV_CLASS_TYPE,
        clcsa105CompCSA105RESProvConstructor, 
        clcsa105CompCSA105RESProvDestructor,
        NULL,
        CSA105COMP_CSA105RES_PROV_CLASS_VERSION,
        0,
        CL_MAX_OBJ,
        0,
        CSA105COMP_CSA105RES_PROV_MAX_SLOTS,
        CL_OM_PROV_CSA105RES_CLASS_TYPE
        },
    };
  

This OM class table is generated by the IDE in clcsa105CompOAMPConfig.c. The definition for ClOmClassControlBlockT can be found in:

<project-area_dir>/SAFplus/components/om/include/clOmApi.h 
clcsa105Compcsa105Res.c
ClRcT clcsa105CompCSA105RESProvUpdate(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle,
                                      ClProvTxnDataT* pProvTxnData)
{

    ...

    switch (pProvTxnData->provCmd)
    {
        case CL_COR_OP_CREATE :
        case CL_COR_OP_CREATE_AND_SET:
			
        /*
         * ---BEGIN_APPLICATION_CODE---
         */
         
        clprintf(CL_LOG_SEV_ERROR,"%s: Inside create request for the object [%s] ", appname, moIdName.value);    

        /*
         * ---END_APPLICATION_CODE---
         */

        break;
        case CL_COR_OP_SET:
	    
        /*
         * ---BEGIN_APPLICATION_CODE---
         */
         
        switch (pProvTxnData->attrId)
        {
            case CSA105RES_DELTA_T:
                delta_t = *(ClUint32T *)pProvTxnData->pProvData;
                clprintf(CL_LOG_SEV_NOTICE,"%s: The delta time is now [%d] ", appname, delta_t);
                break;
            case CSA105RES_COUNTER_THRESH:
                counter_threshold = *(ClUint32T *)pProvTxnData->pProvData;
                clprintf(CL_LOG_SEV_NOTICE,"%s: The counter threshold is now [%d] ", appname, counter_threshold);
            }

        /*
         * ---END_APPLICATION_CODE---
         */

        break;

        case  CL_COR_OP_DELETE:

        /*
         * ---BEGIN_APPLICATION_CODE---
         */

        /*
         * ---END_APPLICATION_CODE---
         */

        break;
        default:
            clprintf (CL_LOG_SEV_ERROR, "Prov command is not proper");

    }
  

This base provisioning class method is generated by The IDE but requires application-specific logic to be filled in. clcsa105CompCSA105RESProvUpdate() is called to update an object's attribute. This has changed from our csa104 example as you can now change the counter threshold as well as the delta time.

clcsa105Compcsa105Res.c
ClRcT clcsa105CompCSA105RESAlarmConstructor( void *pThis, void *pUsrData, ClUint32T usrDataLen )
{
    ClRcT rc = CL_OK;

    return rc;
}

ClRcT clcsa105CompCSA105RESAlarmDestructor ( void *pThis , void  *pUsrData, ClUint32T usrDataLen )
{
    ClRcT rc = CL_OK;

    return rc;
}
  

There are two new functions that have been added as well. These are a constructor and destructor for the alarm. The definition for clcsa105CompCSA105RESAlarmConstructor and clcsa105CompCSA105RESAlarmDestructor can be found in the file clcsa105CompOAMPConfig.h

Now lets look at the code in <project-area_dir>/eval/src/app/csa105AlmLstner.

clCompAppMain.c
....
ClRcT 
alarm_event_subscribe_callback(const ClAlarmHandleInfoT* pAlarmInfo);
...
  

Near the top of the module we declare the function that will be used to subscribe to alarm events.

clCompAppMain.c
ClRcT
clCompAppAMFCSISet(
    ClInvocationT       invocation,
    const ClNameT       *compName,
    ClAmsHAStateT       haState,
    ClAmsCSIDescriptorT csiDescriptor)
{

    switch ( haState )
    {
        case CL_AMS_HA_STATE_ACTIVE:
        {
            /*
             * AMF has requested application to take the active HA state 
             * for the CSI.
             */

            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            // ...

            /*
             * ---END_APPLICATION_CODE---
             */

            clCpmResponse(cpmHandle, invocation, CL_OK);
            
            rc = clAlarmEventSubscribe(&alarm_event_subscribe_callback);
            if (CL_OK != rc)
            {
                clprintf(CL_LOG_SEV_ERROR,"%s: Failed while subscribing for the alarm events. rc[0x%x]",
                                                        appname, rc);
                return rc;
            }
            break;
        }

        case CL_AMS_HA_STATE_STANDBY:
        {
            /*
             * AMF has requested application to take the standby HA state 
             * for this CSI.
             */

            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            // ...

            /*
             * ---END_APPLICATION_CODE---
             */

            clCpmResponse(cpmHandle, invocation, CL_OK);
            break;
        }

        case CL_AMS_HA_STATE_QUIESCED:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active or quiescing HA state. The application 
             * must stop work associated with the CSI immediately.
             */

            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            // ...

            /*
             * ---END_APPLICATION_CODE---
             */

            clCpmResponse(cpmHandle, invocation, CL_OK);

            rc = clAlarmEventUnsubscribe();
            if (CL_OK != rc)
            {
                clprintf(CL_LOG_SEV_ERROR,"%s: Failed while un-subscribing for the alarm evnets. rc[0x%x] ",  
                                                                appname, rc);
                return rc;
            }
            break;
        }

        case CL_AMS_HA_STATE_QUIESCING:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active HA state. The application must stop work
             * associated with the CSI gracefully and not accept any new
             * workloads while the work is being terminated.
             */

            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            // ...

            /*
             * ---END_APPLICATION_CODE---
             */

            clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);
            break;
        }

        default:
        {
            /*
             * Should never happen. Ignore.
             */
        }
    }

  

The clCompAppAMFCSISet function is called when the state of the CSI is set. Here we call the clAlarmEventSubscribe api (passing it a handle to our callback function) when the CSI becomes active. When the CSI becomes innactive we call the clAlarmEventUnsubscribe api.

clCompAppMain.c
ClRcT 
alarm_event_subscribe_callback(const ClAlarmHandleInfoT* pAlarmInfo)
{
    ClRcT   rc = CL_OK;
    ClNameT moIdName = {0};
    ClCorMOIdT  moId = pAlarmInfo->alarmInfo.moId;
    ClAlarmUtilPayLoadListPtrT pPayloadList = NULL;

    rc = clCorMoIdToMoIdNameGet(&moId, &moIdName);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]:Failed while getting the moId from MOId Name. rc[0x%x] ", 
                appname, rc);
        return rc;
    }

    rc = clAlarmUtilPayLoadExtract((ClUint8T *)pAlarmInfo->alarmInfo.buff, 
            pAlarmInfo->alarmInfo.len, &pPayloadList);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]: Failed while extracting the payload information. rc[0x%x] ", 
                appname, rc);
        return rc;
    }
        
    clprintf(CL_LOG_SEV_INFO,"______________________________________________________");
    clprintf(CL_LOG_SEV_INFO,"The alarm is [%s] ", pAlarmInfo->alarmInfo.alarmState ?"RAISED":"CLEARED");
    clprintf(CL_LOG_SEV_INFO,"The alarm Raised on the resource [%s]  ", moIdName.value);
    clprintf(CL_LOG_SEV_INFO,"Component which has raised the alarm  is [%s] ", pAlarmInfo->alarmInfo.compName.value);
    clprintf(CL_LOG_SEV_INFO,"Probable cause of the alarm is [%d] ", pAlarmInfo->alarmInfo.probCause);
    clprintf(CL_LOG_SEV_INFO,"Severity of the alarm is [%d] ", pAlarmInfo->alarmInfo.severity);
    clprintf(CL_LOG_SEV_INFO,"The payload information : [%s] ", (char*)pPayloadList->pPayload[0].pTlv[0].value);
    clprintf(CL_LOG_SEV_INFO,"______________________________________________________");

    clAlarmUtilPayloadListFree(pPayloadList);
    return rc;
}
  

Finally we the callback function. Since this component has registered itself as an alarm listener when it becomes active, this function will be called when the alarm is raised. The function simply prints out a message displaying some of the data that was loaded into the ClAlarmHandleInfoT structure when the alarm was raised.

How to Run csa105 and What to Observe

  1. Start the application as usual with the SAFplus Platform Console. Since our example has two components we will put them both into a lock assignment state.
     # cd /root/asp/bin
     # ./asp_console
    
     cli[Test]-> setc 1
     cli[Test:SCNodeI0]-> setc cpm
     cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa105SGI0
     cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa105AlmLstnerSGI0
    

    This example actually creates three log files.../root/asp/var/log/csa105CompI0Log.latest, /root/asp/var/log/csa105CompI1Log.latest and /root/asp/var/log/csa105AlmLstnerCompLog.latest. The only ones that we are interested in are /root/asp/var/log/csa105CompI0Log.latest and /var/log/csa105AlmLstnerCompLog.latest. Open up two separate command windows. We will view each of the logs in a separate window. In one window type the command tail -f /root/asp/var/log/csa105CompI0Log.latest. In the other type the command tail -f /root/asp/var/log/csa105AlmLstnerCompLog.latest. You should see the following output. (The csa105AlmLstnerComp.log file will not have any output yet.)

    /root/asp/var/log/csa105CompI0Log.latest
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00135 :   INFO)
     Component [csa105CompI0] : PID [22201]. Initializing
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00136 :   INFO)
        IOC Address             : 0x1
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00137 :   INFO)
        IOC Port                : 0x81
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00138 :   INFO)
     csa105: instantiated as component instance csa105CompI0.
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00139 :   INFO)
     csa105CompI0: cpmHandle = 0x1
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00140 :   INFO)
     csa105CompI0: Waiting for CSI assignment...
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00141 :   INFO)
     csa105CompI0: checkpoint_initialize
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00148 :   INFO)
     csa105CompI0: Checkpoint service initialized (handle=0x1)
    Mon Jul 14 20:15:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00150 :   INFO)
     csa105CompI0: Checkpoint opened (handle=0x2)
      
  2. Now unlock the csa105AlmLstnerSGI0 service group.
     cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa105AlmLstnerSGI0
    
  3. Next unlock the csa105SGI0 service group.
     cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa105SGI0
    

    You should see the following output in the /root/asp/var/log/csa105CompI0Log.latest log file.

    /root/asp/var/log/csa105CompI0Log.latest
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00286 :   INFO)
     csa105CompI0: Hello World! (count = 0)
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00291 :   INFO)
     **** Inside the function : [clCompAppProvTxnStart] ****
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00293 :   INFO)
     Inside the function clcsa105CompCSA105RESProvObjectStart
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00295 :   INFO)
     Inside the function clcsa105CompCSA105RESProvValidate
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00311 :   INFO)
     Inside the function clcsa105CompCSA105RESProvUpdate
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00313 :   INFO)
     Inside the function clcsa105CompCSA105RESProvObjectEnd
    Mon Jul 14 20:21:18 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00322 :   INFO)
     **** Inside the function : [clCompAppProvTxnEnd] ****
    Mon Jul 14 20:21:19 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00329 :   INFO)
     csa105CompI0: Hello World! (count = 1)
    Mon Jul 14 20:21:20 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00330 :   INFO)
     csa105CompI0: Hello World! (count = 2)
    Mon Jul 14 20:21:21 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00331 :   INFO)
     csa105CompI0: Hello World! (count = 3)
      

    You will notice that the csa105CompI0 component has begun printing out the 'Hello World'. You can also see that the counter value is incrementing.

    Keep watching the counter value as it increments. Remember that we set up an initial counter threshold of 65. Once the counter value reaches 65 you will see the following in the /root/asp/var/log/csa105AlmLstnerCompLog.latest log file.

    /root/asp/var/log/cscsa105AlmLstnerCompLog.latest
    __________________________________________________________________________________
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00109 :   INFO)
     The alarm is [RAISED]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00110 :   INFO)
     The alarm Raised on the resource [\Chassis:0\csa105Res:0]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00111 :   INFO)
     Component which has raised the alarm  is [csa105CompI1]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00112 :   INFO)
     Probable cause of the alarm is [16]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00113 :   INFO)
     Severity of the alarm is [4]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00114 :   INFO)
     The payload information : [[csa105CompI0]: The Alarm has been raised as the counter 
    became [65] for [1] time]
    __________________________________________________________________________________
    __________________________________________________________________________________
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00134 :   INFO)
     The alarm is [CLEARED]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00135 :   INFO)
     The alarm Raised on the resource [\Chassis:0\csa105Res:0]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00136 :   INFO)
     Component which has raised the alarm  is [csa105CompI1]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00137 :   INFO)
     Probable cause of the alarm is [16]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00138 :   INFO)
     Severity of the alarm is [4]
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22234 : csa105AlmLstner_EO.---.---.00139 :   INFO)
     The payload information : [[csa105CompI0]: The Alarm has been raised as the counter
    became [65] for [1] time]
    
    __________________________________________________________________________________
      

    As you can see our callback function in the module <project-area_dir>/eval/src/app/csa105AlmLstner/clCompAppMain.c was called twice. Once when the alarm was raised and once when it was cleared. Looking at the /root/asp/var/log/csa105CompI0Log.latest log file you can see that the alarm was raised and cleared from this component and then the counter value was reset.

    /root/asp/var/log/csa105CompI0Log.l
    Mon Jul 14 20:22:22 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00812 :   INFO)
     csa105CompI0: Hello World! (count = 64)
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00813 :   INFO)
     csa105CompI0: Hello World! (count = 65)
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00814 :   INFO)
     [csa105CompI0]: Raising the alarm as the counter threashold has reached.
    Mon Jul 14 20:22:23 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00843 :   INFO)
     csa105CompI0: Hello World! (count = 0)
    Mon Jul 14 20:22:24 2008   (SCNodeI0.22201 : csa105Comp_EO.---.---.00844 :   INFO)
     csa105CompI0: Hello World! (count = 1)
      

    This behavior will continue each time the counter value reaches 65.

  4. Now lets change the threshold value. We do this through the SAFplus Platform Console. In the SAFplus Platform Console return to the SCNodeI0 context by entering end until it prints the SCNodeI0 prompt: cli[Test:SCNodeI0]->.
    cli[Test:SCNodeI0:CPM]-> end
    cli[Test:SCNodeI0]->
    
  5. Now set the context to the COR server using the following command:
    cli[Test:SCNodeI0]-> setc corServer_SCNodeI0
    
  6. Then, dump the object tree:
    cli[Test:SCNodeI0:COR]-> objTreeShow
    

    You should see something like the following. There may be extra entries, but you should at least see an entry where ClassName = CLASS_CSA105RES_PROV_MS0.

    SAFplus Platform Console
    cli[Test:SCNodeI0:COR]-> objtreeshow
    
    Objects (Instance Tree):
        [0] ClassName=Chassis ClassId=0x10001 inst=0 [flgs=0x508]
            [0] ClassName=SCNodeRes ClassId=0x10007 inst=0 [flgs=0x508]
                *[3] ClassName=CLASS_SCNODERES_PROV_MSO ClassId=0x10009 inst=0 [flgs=0x508]
            [0] ClassName=csa105Res ClassId=0x10004 inst=0 [flgs=0x508]
                *[2] ClassName=CLASS_CSA105RES_ALARM_MSO ClassId=0x10006 inst=0 [flgs=0x508]
                *[3] ClassName=CLASS_CSA105RES_PROV_MSO ClassId=0x10005 inst=0 [flgs=0x508]
      
  7. Next, dump the CLASS_CSA105RES_PROV_MS object with:
    cli[Test:SCNodeI0:COR]-> objectShow \Chassis:0\csa105Res:0 3
    
    SAFplus Platform Console
     Showing Object
    ClCorMOId:[Svc: 3] (/).(10001:0000).(10004:0000):
    
    [Class:0x10005] Object 
    {
    [CSA105RES_COUNTER             ] [0x0004] = [41]
    [CSA105RES_COUNTER_THRESH      ] [0x0005] = [65]
    [CSA105RES_DELTA_T             ] [0x0006] = [1000]
    }
      

    The 3 is the service ID of the object and is the value in brackets next to the asterisk on the ClassName=CLASS_CSA105RES_PROV_MSO line.

  8. Now, set the counter_thresh attribute to 20 instead of 65 with:
    cli[Test:SCNodeI0:COR]-> attrSet \Chassis:0\csa105Res:0 3 null 5 -1 20
    
    SAFplus Platform Console
     Execution Result : Passed
      

    Now you will notice that the alarm is raised every time the counter value reaches 20.

  9. To end this example first get back to the CPM context.
    cli[Test:SCNodeI0:COR]-> end
    cli[Test:SCNodeI0]-> setc cpm
    
  10. Now shut things down in the usual fashion. Remember that this example has two components to shut down.
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa105SGI0
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa105AlmLstnerSGI0
    cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa105SGI0
    cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa105AlmLstnerSGI0
    cli[Test:SCNodeI0:CPM]-> end
    cli[Test:SCNodeI0]-> end
    cli[Test]-> bye
    

Summary and References

This application is built upon the csa104 application and presents :

  • how provisioning and alarm libraries work together to achieve a simple software alarm management
  • how COR change notification is utilized