Metrics Collection

A critical aspect of diagnosing software applications for embedded systems is collecting and visualizing the metrics data obtained from the device. This includes raw sensor measurements, internal hardware metrics, firmware/operating system metrics, and other high-level software metrics. For example, Unmanned Aerial Vehicles (UAV) obtain linear velocity, altitude, orientation measurements from its sensors, which can plotted on time-series graphs to diagnose flight control issues.

PSYGIG Mobility IoT SDK alleviates the complexity of writing specific code for each metric source with its built-in support for known sensors, internal hardware, operating systems and applications. The Metrics Collection API includes many features suitable for integration into embedded systems:

Known metric sources

The Metrics Collection API provides facilities to discover and poll metrics data from the following known applications:

cpu

CPU (eg. % usage, temperature, clock speed)

gpu

GPU (eg. % usage, memory usage)

ram

Memory (eg. % RAM usage)

disk

Disk (eg. Read/write speed, Response time)

network

Network (eg. throughput)

linux

Linux (eg. process count, open sockets)

Note

This list is constantly expanding. Please contact us if there is a specific sensor or application that you would like to be supported.

Using psymon

Without modifying your existing source code, you can instantly enable periodic collection of system resource metrics to your application by using the psymon script to run your program. For example:

psymon --metrics "/path/to/your/app --arg1 --arg2 --arg3"

See psymon man page for a complete list of options.

Using C/C++ SDK API

The Metrics Collection 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.

Enable periodic collection of system resource metrics

 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 ... */

    // Poll system resource metrics every 500ms
    psyiage_metric_enable_poll_system_resources(pah, 500);

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

Collection of application-defined metrics

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

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

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

    /* ... Read and aggregate data from laser sensors and cameras */

    // Collect application-defined topographic data
    rc = psyiage_metric_record_values_blob(pah, "Topography", topographic_data, topographic_data_size, 1);

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

Sample metrics JSON data

"Metrics": [
  {
    "Name": "ProcVM",
    "Timestamps": [
      1559439076.125103951,
      1559439076.626415014,
      1559439077.127984047,
      1559439077.629561663,
      1559439078.130370855,
      1559439078.631809711,
      1559439079.132480621,
      1559439079.633147001,
      1559439080.133864164,
      1559439080.635303974,
      1559439081.136044741,
      1559439081.636738777,
      1559439082.137473822,
      1559439082.638967037
    ],
    "Values": [
      112214016,
      112214016,
      113311744,
      113311744,
      112230400,
      112906240,
      113340416,
      112934912,
      112394240,
      112242688,
      112377856,
      112242688,
      112230400,
      112230400
    ]
  },
  {
    "Name": "SysCPU",
    "Timestamps": [
      1559439076.626402378,
      1559439077.127982140,
      1559439077.629560232,
      1559439078.130369663,
      1559439078.631808519,
      1559439079.132479429,
      1559439079.633145809,
      1559439080.133862734,
      1559439080.635302544,
      1559439081.136043549,
      1559439081.636737585,
      1559439082.137472630,
      1559439082.638965845
    ],
    "Values": [
      0.1624365448951721,
      0.1700507551431656,
      0.1616161614656448,
      0.157760813832283,
      0.1670886129140854,
      0.1569620221853256,
      0.149367094039917,
      0.1454081684350967,
      0.1472081243991852,
      0.1522842645645142,
      0.1522842645645142,
      0.1594936698675156,
      0.1548223346471786
    ]
  },
  {
    "Name": "ProcRAMPeak",
    "Timestamps": [
      1559439076.125098944,
      1559439076.626414537,
      1559439077.127983570,
      1559439077.629561424,
      1559439078.130370617,
      1559439078.631809473,
      1559439079.132480383,
      1559439079.633146763,
      1559439080.133863926,
      1559439080.635303736,
      1559439081.136044502,
      1559439081.636738539,
      1559439082.137473583,
      1559439082.638966799
    ],
    "Values": [
      4075520,
      4075520,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096,
      5636096
    ]
  },
  {
    "Name": "SysRAM",
    "Timestamps": [
      1559439076.125087976,
      1559439076.626402617,
      1559439077.127982855,
      1559439077.629560709,
      1559439078.130370140,
      1559439078.631808996,
      1559439079.132479906,
      1559439079.633146286,
      1559439080.133863211,
      1559439080.635303259,
      1559439081.136044025,
      1559439081.636737823,
      1559439082.137473106,
      1559439082.638966322
    ],
    "Values": [
      7739355136,
      7773405184,
      7816024064,
      7798185984,
      7815942144,
      7802179584,
      7853674496,
      7907958784,
      7963762688,
      8024965120,
      8073596928,
      8121901056,
      8156819456,
      8199684096
    ]
  },
  {
    "Name": "ProcCPU",
    "Timestamps": [
      1559439076.626414061,
      1559439077.127983093,
      1559439077.629560709,
      1559439078.130370140,
      1559439078.631808996,
      1559439079.132479906,
      1559439079.633146286,
      1559439080.133863449,
      1559439080.635303259,
      1559439081.136044264,
      1559439081.636738062,
      1559439082.137473106,
      1559439082.638966322
    ],
    "Values": [
      0.004999999888241291,
      0.01250000018626451,
      0.002499999944120646,
      0.007499999832361937,
      0.01250000018626451,
      0.007499999832361937,
      0.004999999888241291,
      0.007499999832361937,
      0.007352941203862429,
      0.007499999832361937,
      0.007499999832361937,
      0.007499999832361937,
      0.007499999832361937
    ]
  },
  {
    "Name": "ProcRAM",
    "Timestamps": [
      1559439076.125092983,
      1559439076.626414299,
      1559439077.127983570,
      1559439077.629561186,
      1559439078.130370378,
      1559439078.631809473,
      1559439079.132480145,
      1559439079.633146763,
      1559439080.133863688,
      1559439080.635303736,
      1559439081.136044502,
      1559439081.636738300,
      1559439082.137473345,
      1559439082.638966799
    ],
    "Values": [
      4075520,
      4075520,
      5582848,
      5582848,
      4775936,
      5312512,
      5611520,
      5341184,
      4804608,
      4788224,
      4788224,
      4788224,
      4775936,
      4775936
    ]
  },
  {
    "Name": "ProcSwap",
    "Timestamps": [
      1559439076.125116587,
      1559439076.626415253,
      1559439077.127984524,
      1559439077.629562140,
      1559439078.130371332,
      1559439078.631810188,
      1559439079.132480860,
      1559439079.633147478,
      1559439080.133864641,
      1559439080.635304451,
      1559439081.136045218,
      1559439081.636739254,
      1559439082.137474060,
      1559439082.638967514
    ],
    "Values": [
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ]
  },
  {
    "Name": "ProcVMPeak",
    "Timestamps": [
      1559439076.125111103,
      1559439076.626415014,
      1559439077.127984285,
      1559439077.629561901,
      1559439078.130371094,
      1559439078.631809950,
      1559439079.132480621,
      1559439079.633147240,
      1559439080.133864403,
      1559439080.635304213,
      1559439081.136044979,
      1559439081.636739016,
      1559439082.137473822,
      1559439082.638967276
    ],
    "Values": [
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536,
      175169536
    ]
  }
]