Event Reporting

Events refer to an exceptional behaviour in the environment beyond normal circumstances. This includes events in the physical environment such as a low battery warning for an autonomous drone, as well as software events such as low remaining disk space. Diagnosing system failures involves analyzing any anomaly in events that were raised before the failure occurred. Events may also be used to trigger certain actions, such as performing a graceful shutdown when the battery level is crtically low.

PSYGIG Mobility IoT SDK provides an event reporting service that allows on-demand event reporting, as well as the setting of event triggers when a condition or threshold is exceeded.

The Event Reporting API includes many features suitable for integration into embedded systems:

Using psymon

Without modifying your existing source code, you can instantly enable any of the pre-defined event triggers in your application by using the psymon script to run your program. For example:

psymon --alerts "lowmem" "/path/to/your/app --arg1 --arg2 --arg3"

See psymon man page for a complete list of options.

Note

psymon --alerts is a work-in-progress. Please contact us if you are interested in beta-testing this feature.

Using C/C++ SDK API

The Event Reporting API can be accessed by including a single header file and linking the libpsyiage shared library. See Advanced Setup - Building your application with libpsyiage for details.

Raising an event on demand

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <psyiage/psyiagesdk.h>

int main(int argc, char **argv)
{
    psyiage_handle     pah;  // handle to psyiage instance

    /* ... Initialize code omitted for simplicity ... */

    // Report monitoring task complete as event
    rc = psyiage_event_report(pah, PSYIAGE_EVENT_LEVEL_INFO, "monitor", TASK_COMPLETE_EVENT_ID, "Monitor task complete");

    /* ... Cleanup code omitted for simplicity ... */
}

Sample event JSON data

"Events": [
  {
    "Timestamp": 1559440949.192214012,
    "TimeOfDay": "2019-06-02 11:02:29.192214012",
    "Level": "Info",
    "Source": "event_report",
    "EventID": 1,
    "Message": "Reporting event with severity 0"
  },
  {
    "Timestamp": 1559440950.192817450,
    "TimeOfDay": "2019-06-02 11:02:30.192817449",
    "Level": "Warning",
    "Source": "event_report",
    "EventID": 1,
    "Message": "Reporting event with severity 1"
  },
  {
    "Timestamp": 1559440951.194056273,
    "TimeOfDay": "2019-06-02 11:02:31.194056272",
    "Level": "Error",
    "Source": "event_report",
    "EventID": 1,
    "Message": "Reporting event with severity 2"
  },
  {
    "Timestamp": 1559440952.194596052,
    "TimeOfDay": "2019-06-02 11:02:32.194596052",
    "Level": "Critical",
    "Source": "event_report",
    "EventID": 1,
    "Message": "Reporting event with severity 3"
  }
],