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 Triage 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 --eventtrigger "lowmem" -c "/path/to/your/app --arg1 --arg2 --arg3"

See psymon man page for a complete list of options.

注釈

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

Using PSYGIG SDK API

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

Raising an event on demand

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

int main(int argc, char **argv)
{
    psygig_agent_handle     pah;  // handle to psygig agent

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

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

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

Sample event JSON data

{
    "Event": {
        "Duration": 0,
        "Timestamp": 1547534065,
        "TimeOfDay": "2019-01-15 15:34:25",
        "Level": "Info",
        "Source": "monitor",
        "EventID": 1,
        "Message": "Monitor task start"
    }
},
{
    "Event": {
        "Duration": 15,
        "Timestamp": 1547534080,
        "TimeOfDay": "2019-01-15 15:34:40",
        "Level": "Info",
        "Source": "monitor",
        "EventID": 2,
        "Message": "Monitor task complete"
    }
}