You can define conditions that will trigger an alarm, as well as an optional action to be triggered by the alarm, such as publishing an alarm notification within IAP, sending an email or SMS notification, or executing a job object.
IAP/MQ Alarm Requests and Responses
Alarm Configuration
The alarm’s current configuration is reported in the following topic (See Alarm in API Reference):
glp/0/{SID}/fb/alarm/{Handle}/cfg |
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/cfg
{"desc":null,"enabled":true,"cat":"alarm","ackd":true,"activation":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true)","deactivation":null,"message":null,"urgent":false,"actions":null,"severity":null,"mru":"2019-04-15 11:42:01.515 UTC"}
Alarm Status
The alarm's status is reported in the following topic (See Alarm in API Reference):
glp/0/{SID}/fb/alarm/{Handle}/sts |
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/sts
{"state":"enabled","mru":"2019-04-15 10:46:25.792 UTC"}
Creating, Deleting, or Updating Alarms
You can manage alarms by publishing one of the actions (create, delete, or update) on the alarm do
topic (See Manage Alarms in API Reference):
glp/0/{SID}/rq/alarm/{Handle}/do |
We are configuring alarm for datapoint relay-val/value/level on dio device for interface if/relay/2.
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2
{
"desc": "Relay output",
"type": "iox-profiles-0/relay",
"relay-val": {
"desc": "iox-relay",
"type": "iox-datapoints-0/relay-val",
"property": false,
"cat": "in",
"value": {
"level": false
},
"values": {
"level": "17",
"levels": {
"17": {
"level": false
}
},
"inactive": {
}
}
}
}
^C
apollo@smartserver-17q2d9x:~$
Alarm activation condition need to set while creating alarm. We are activating alarm when the level value becomes true.
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/alarm/alarm_1/do -m '{"action":"create","args":{"enabled":true,"cat":"alarm","activation":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true)","ackd":true}}'
apollo@smartserver-17q2d9x:~$
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/sts
{"state":"enabled","mru":"2019-04-15 10:46:25.792 UTC"}
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/cfg
{"desc":null,"enabled":true,"cat":"alarm","ackd":true,"activation":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true)","deactivation":null,"message":null,"urgent":false,"actions":null,"severity":null,"mru":"2019-04-15 11:42:01.515 UTC"}
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/ev/alarm
<----NO OUTPUT--->
To activate an alarm we have to set the datapoint value of "relay-val" level to true.
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/dev/iox.409e21/dio/if/relay/2 -m '{"relay-val": {
"value": {
"level": true
}
}
}'
apollo@smartserver-17q2d9x:~$
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/ev/alarm
{"id":264,"cat":"alarm","utc":"2019-04-15 10:48:22.304 UTC","language":"en","local":"2019-04-15 16:18:22.304 IST","message":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true)","topic":"glp/0/17q2d9x/rq/alarm/alarm_1","urgent":false,"active":true,"acknowledged":false,"acknowledge":"glp/0/17q2d9x/rq/alarm/alarm_1","source":"alarm"}
To deactivate an alarm we have to unset the datapoint value of "relay-val" level to false.
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/dev/iox.409e21/dio/if/relay/2 -m '{"relay-val": {
"value": {
"level": false
}
}
}'
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/ev/alarm
{"id":266,"cat":"alarm","utc":"2019-04-15 10:55:32.824 UTC","language":"en","local":"2019-04-15 16:25:32.824 IST","message":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true)","topic":"glp/0/17q2d9x/rq/alarm/alarm_1","urgent":false,"active":false,"acknowledged":false,"acknowledge":"glp/0/17q2d9x/rq/alarm/alarm_1","source":"alarm"}
Following is the example to update the alarm condition.
Previously we created alarm on the activation condition eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/2/relay-val/value/level\", true).
This example shows to update alarm activation condition to eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1/relay-val/value/level\", true).
mosquitto_sub -t glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1
{
"desc": "Relay output",
"type": "iox-profiles-0/relay",
"relay-val": {
"desc": "iox-relay",
"type": "iox-datapoints-0/relay-val",
"property": false,
"cat": "in",
"value": {
"level": false
},
"values": {
"level": "17",
"levels": {
"17": {
"level": false
}
},
"inactive": {
}
}
}
}
mosquitto_pub -t glp/0/17q2d9x/rq/alarm/alarm_1/do -m '{"action":"update","args":{"enabled":true,"cat":"alarm","activation":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1/relay-val/value/level\", true)","ackd":true}}'
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/cfg
{"desc":null,"enabled":true,"cat":"alarm","ackd":true,"activation":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1/relay-val/value/level\", true)","deactivation":null,"message":null,"urgent":false,"actions":null,"severity":null,"mru":"2019-04-15 11:52:10.440 UTC"}
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/sts
{"state":"enabled","mru":"2019-04-15 11:03:04.277 UTC"}
Activate updated alarm:
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/dev/iox.409e21/dio/if/relay/1 -m '{"relay-val": {
"value": {
"level": true
}
}
}'
apollo@smartserver-17q2d9x:~$
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/ev/alarm
{"id":269,"cat":"alarm","utc":"2019-04-15 11:06:40.426 UTC","language":"en","local":"2019-04-15 16:36:40.426 IST","message":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1/relay-val/value/level\", true)","topic":"glp/0/17q2d9x/rq/alarm/alarm_1","urgent":false,"active":true,"acknowledged":false,"acknowledge":"glp/0/17q2d9x/rq/alarm/alarm_1","source":"alarm"}
Deactivate updated alarm:
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/dev/iox.409e21/dio/if/relay/1 -m '{
"relay-val": {
"value": {
"level": false
}
}
}'
apollo@smartserver-17q2d9x:~$
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/ev/alarm
{"id":271,"cat":"alarm","utc":"2019-04-15 11:08:59.445 UTC","language":"en","local":"2019-04-15 16:38:59.445 IST","message":"eq(\"glp/0/17q2d9x/fb/dev/iox.409e21/dio/if/relay/1/relay-val/value/level\", true)","topic":"glp/0/17q2d9x/rq/alarm/alarm_1","urgent":false,"active":false,"acknowledged":false,"acknowledge":"glp/0/17q2d9x/rq/alarm/alarm_1","source":"alarm"}
Following is the example of deleting an alarm "alarm_1"
apollo@smartserver-17q2d9x:~$ mosquitto_pub -t glp/0/17q2d9x/rq/alarm/alarm_1/do -m '{"action":"delete"}'
apollo@smartserver-17q2d9x:~$ mosquitto_sub -t glp/0/+/fb/alarm/alarm_1/sts
{"state":"deleted","mru":"2019-04-15 11:10:56.932 UTC"}
IAP/REST Alarm Operations
Get all alarms, unless a filter or pagination is specified. (See Alarms in API Reference.)
Example https://localhost:8443/iap/alarms?order=asc&pg=1&sortBy=timestamp&sz=25
Example of success response:
[
{
"id": 1760,
"timestamp": "2019-01-11T15:27:52.994-08:00[America/Los_Angeles]",
"category": "System-SW",
"severity": "Major Fault",
"state": "Active",
"geozone": {
"id": 88,
"name": "World"
},
"device": {
"id": "Ab93fcpn.25",
"name": "Test Device",
"uid": "00D07111EA6B"
},
"type": "Type mismatch",
"details": "Device type mismatch for device Test Device",
"alarmTargetType": "DEVICE"
}
]
Get either the count of active alarms that the current user is permitted to get, or returns the count of active alarms for the current moment. (See Alarms in API Reference.)
Example https://localhost:8443/iap/alarms/count
Example of success response:
{
"value": 5
}
Get all alarms related to the specified device, including the cleared ones. (See Alarms in API Reference.)
GET | iap/alarms/dev/{deviceId} |
Example https://localhost:8443/iap/alarms/device/Ab93fcpn.25
Example of success response:
[
{
"id": 1760,
"timestamp": "2019-01-11T15:27:52.994-08:00[America/Los_Angeles]",
"category": "System-SW",
"severity": "Major Fault",
"state": "Active",
"geozone": {
"id": 88,
"name": "World"
},
"device": {
"id": "Ab93fcpn.25",
"name": "Test Device",
"uid": "00D07111EA6B"
},
"type": "Type mismatch",
"details": "Device type mismatch for device Test Device",
"alarmTargetType": "DEVICE"
}
]
Get all alarms IDs that are accessible to the current customer. (See Alarms in API Reference.)
Example https://localhost:8443/iap/alarms/ids?order=asc&pg=1&sortBy=timestamp&sz=25
Example of success response:
[
1760,
1765
]
Returns all alarms related to specified devices including the cleared ones. (See Alarms in API Reference.)
Example https://localhost:8443/iap/alarms/devs
Request body:
["Ab93fcpn.2","Ab93fcpn.25"]
Response:
[
{
"deviceId": "Ab93fcpn.25",
"alarms": [
{
"id": 1760,
"timestamp": "2019-01-11T15:27:52.994-08:00[America/Los_Angeles]",
"category": "System-SW",
"severity": "Major Fault",
"state": "Active",
"geozone": {
"id": 88,
"name": "World"
},
"device": {
"id": "Ab93fcpn.25",
"name": "Test Device",
"uid": "00D07111EA6B"
},
"type": "Type mismatch",
"details": "Device type mismatch for device Test Device",
"alarmTargetType": "DEVICE"
}
]
}
]
Change state to INACTIVE_OPERATOR for the specified alarms. (See Alarms in API Reference.)
Example https://localhost:8443/iap/alarms/clear
Request body:
[1760]
Response:
empty
Deletes specified alarm definition from the CMS. (See Alarms in API Reference.)
PUT | /iap/alarms/definitions/{id} |
Example https://localhost:8443/iap/alarms/definitions/1908
Response:
Response code 200