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 |
---|
|
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 |
---|
|
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 |
---|
|
clCompAppMain.c |
---|
|
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 |
---|
|
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 |
---|
|
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 |
---|
|
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 |
---|
|
Near the top of the module we declare the function that will be used to subscribe to alarm events.
clCompAppMain.c |
---|
|
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 |
---|
|
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
- 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 commandtail -f /root/asp/var/log/csa105CompI0Log.latest
. In the other type the commandtail -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)
- Now unlock the csa105AlmLstnerSGI0 service group.
cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa105AlmLstnerSGI0
- 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.
- 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]->
- Now set the context to the COR server using the following command:
cli[Test:SCNodeI0]-> setc corServer_SCNodeI0
- Then, dump the object tree:
cli[Test:SCNodeI0:COR]-> objTreeShow
You should see something like the following.
SAFplus Platform Console cli[Test:SCNodeI0:COR]-> objtreeshow Objects (Instance Tree): \Chassis:0 \PayloadNodeRes:0 (provisioning) \PayloadNodeRes:1 (provisioning) \SCNodeRes:0 (provisioning) \SCNodeRes:1 (provisioning) \csa104Res:0 (provisioning) \csa105Res:0 (alarm, provisioning)
- 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. - 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.
- To end this example first get back to the CPM context.
cli[Test:SCNodeI0:COR]-> end cli[Test:SCNodeI0]-> setc cpm
- 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