Demos

Elos comes with a set of demo applications to show certain aspects of elos.

elosMon – publish events as mails

Usage: elosMon [OPTION]...
  -h, --help              Display this usage information.
  -v, --verbose           Print verbose messages.
  -H, --host              Specifies the sending server in form <host>[:<port>] (default port 587).
  -s, --sender            Sending mail address (FROM header).
  -r, --recipient         Adds a new recipient e-mail address.
  -f, --filter            Specifies an elos event filter to be added.
  -a, --authentication    Specifies data needed for authentication with smtp server
                          in form of <username>:<password> (optional).

The options for filters (-f) and recipients (-r) can be used more than once
in order to add more than one filter for events to be monitored
or recipient to get informed of occurring system events.
However at least one filter and recipient has to be specified.

Example:
  elosMon -H mailer.example.com:25 \
     -s noreply-elos@example.com \
     -f ".event.source.appName 'login' STRCMP" \
     -r recipient1@mailer.com \
     -r recipient2@example.com

elosc – simple commandline client

Usage: elosc [OPTION]...
  -s <filter>      event subscribe
  -u <queueId>     event unsubscribe
  -p <json event>  event publish
  -f <filter>      event log find
  -c <count>       set event count
  -r <events/sec>  set event rate
  -H <Host-Ip>     set host ip address
  -P <Port>        set host port
  -h               print this help
  -v               get version

<filter>: event filter in RPN notation
         example: '.event.messageCode 1000 GE .event.messageCode 2000 LT AND'

To verify the elos version use :

$ elosc -v
elosc-0.67.3.cbdc562

To subscribe on any event :

$ elosc -s "1 1 EQ"
Connecting to elosd...
ERROR: Connection to elosd failed!

To subscribe on coredump events :

$ elosc -s ".event.messageCode 5005 EQ"
Connecting to elosd...
ERROR: Connection to elosd failed!

To list all events logged :

$ elosc -f "1 1 EQ"
Connecting to elosd...
ERROR: Connection to elosd failed!

To list all logged events that are critical :

$ elosc -f "event.severity 1 EQ"
Connecting to elosd...
ERROR: Connection to elosd failed!

To publish an event :

$ elosc -p '{"messageCode": 1001, "severity": 4, "payload": "a custom event with severity INFO (4)"}'
Connecting to elosd...
ERROR: Connection to elosd failed!

To publish 100 events as fast as possible :

$ elosc -c 100 -p '{"messageCode": 1001, "severity": 4, "payload": "publish 100 events as fast as possible"}'
Connecting to elosd...
ERROR: Connection to elosd failed!

To publish 100 events with 50Hz :

$ elosc -c 100 -r 50 -p '{"messageCode": 1001, "severity": 4, "payload": "publish 100 events at 50Hz"}'
Connecting to elosd...
ERROR: Connection to elosd failed!

To set host ip :

$ elosc -H 127.0.0.1 -f "1 1 Q"
Connecting to elosd...
ERROR: Connection to elosd failed!

To set host connection port :

$ elosc -H 127.0.0.10 -P 9876 -f "1 1 Q"
Connecting to elosd...
ERROR: Connection to elosd failed!

demo_libelos_v2 – publish subscrie demo using libelos

To verify the elos version use :

$ demo_libelos_v2 -v
libelos_demo-0.67.3.cbdc562

demo_scanner_shmem - publish random messages into shared memory ringbuffer

This demo is a simple demonstrator that writes into an ebRingBuffer located in a shared memory region. Writes 1-8 messages with random content every 0.5 seconds until the demo is stopped with ctrl+c.

The name of the shared memory region comes first, followed by the offset:

$ demo_scanner_shmem scanner_shmem 0
shm_open: No such file or directory
use sem name : scanner_shmem_sem

The name of the semaphore will be autogenerated from the first parameter if you call the demo with 2 parameters (by appending “_sem” to the name). You can also call the demo with an explicitely specified semaphore name:

$ demo_scanner_shmem scanner_shmem 0 scanner_shmem_sem
shm_open: No such file or directory
use sem name : scanner_shmem_sem

Note: The size is detected automatically by reading out the number of ringbuffer entries in the shmem area. Calling the demo on a shmem area that is not big enough the contain the ringbuffer struct itself is undefined behaviour and must be avoided.

demo_eventbuffer – test performance of event buffer

This demo was manly developed to test and verify the EventBuffer component.

usage: demo_eventbuffer [-h|--help] [--publisher NUMBER] [--consumer NUMBER] [--messageCount NUMBER] [--eventLimit NUMBER]

EventBuffer demonstration with time measurements for reading and writing.
Uses a single EventBuffer that is written/read by multiple publishers/consumers.

options:
  -h, --help               Shows this help message and exits
  --publisher NUMBER       Number of publishers used (with each publisher running in its own thread)
  --consumer NUMBER        Number of consumers used (with each consumer running in its own thread)
  --messageCount NUMBER    Number of messages to be sent by each publisher
  --eventLimit NUMBER      Number of Events that can be stored before old unread Events are dropped

To benchmark the event buffers on a target with default value run:

$ demo_eventbuffer

publisher: 4
consumer: 4
messageCount: 1000

messagesPublished: 4000
messagesConsumed: 3986
messagesLostByLimit: 0

publishTimes.min: 0.000942msec
publishTimes.avg: 0.002398msec
publishTimes.max: 0.054922msec
publishTimes.sum: 9.590766msec

consumerTimes.min: 0.000772msec
consumerTimes.avg: 0.002368msec
consumerTimes.max: 0.060633msec
consumerTimes.sum: 9.470890msec

To benchmark the event buffers on a target to find optimal configuration :

$ demo_eventbuffer --publisher 100 --consumer 10 --messageCount 1000 --eventLimit 300

publisher: 100
consumer: 10
messageCount: 1000

messagesPublished: 100000
messagesConsumed: 100000
messagesLostByLimit: 44718

publishTimes.min: 0.000932msec
publishTimes.avg: 0.002769msec
publishTimes.max: 0.066303msec
publishTimes.sum: 276.923893msec

consumerTimes.min: 0.000952msec
consumerTimes.avg: 0.007657msec
consumerTimes.max: 0.077273msec
consumerTimes.sum: 76.574187msec

syslog_example – demonstrate and test the syslog scanner

With the syslog_example demo it is possible to verify if the syslog scanner is configured correctly. It can also be used to develop the mapping rules for the syslog scanner.

To verify that the syslog scanner is working:

$ syslog_example "Syslog scanner test"; elosc -f ".event.payload 'Syslog scanner test' STRCMP"
syslog_example: invalid option -- 'f'
ERROR: Unrecognized option: '-f'

Simulate syslog lines and test a filter if it can be used as mapping rule for the syslog-scanner:

simulate the syslog line
$ syslog_example "Jun 15 19:56:23 hostnameXY wpa_supplicant[420]: wlp0s20f3: WPA: Group rekeying completed with 00:00:00:00:00:00 [GTK=TKIP]"
failed to connect to elos
check if rule mtches the syslog line
$ elosc -f ".event.payload r'WPA: Group rekeying' REGEX"
Connecting to elosd...
ERROR: Connection to elosd failed!

tinyElosc – minimized elos client to send raw payload

This demo was developed to send raw formatted payload. The payload is not preprocessed and validated by any JSON parser. This can be used to send malformed or any arbitrary encoded payload.

Usage: tinyElosc [OPTION]...
  -s <filter>      event subscribe
  -u <eventQueue>  unsubscribe from event queue
  -p <payload>     raw payload to be published
  -H <Host-Ip>     set host ip address
  -P <Port>        set host port
  -h               print this help
  -v               get version

<filter>: event filter in RPN notation
         example: '.event.messageCode 1000 GE .event.messageCode 2000 LT AND'

To verify the elos version use :

$ tinyElosc -v
ERR: connect to port 54321

Test elos for arbitrary not valid encoded payload:

try to publish an XML string instead of a JSON string
$ tinyElosc -p "<wrong>this is not a JSON string</wrong>"
ERR: connect to port 54321

elos_log4c_demo - a demo program to show log4c logging in elos

This demo was developed to demonstrate the usage of log4c logging framework with elos. The configuration for log4c can be set with the help of a log4crc configuration file.

In order to log with a log4c framework, a category, a priority and an appender for the logged message should be set in the config file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">

<log4c version="1.2.4">

	<config>
		<bufsize>0</bufsize>
		<debug level="2"/>
		<nocleanup>0</nocleanup>
		<reread>1</reread>
	</config>

	<category name="root" priority="notice"/>
	
	<appender name="stdout" type="stream" layout="dated"/>
	<appender name="stderr" type="stream" layout="dated"/>
	<appender name="syslog" type="syslog" layout="basic"/>
	<appender name="elos" type="elos_appender" layout="elos_layout"/>

	<layout name="basic" type="basic"/>
	<layout name="dated" type="dated"/>
	<layout name="elos_layout" type="elos_formatter"/>
	
        <category name="log4c.elos.demo.log4cdemo" priority="debug" appender="elos" />

</log4c>

More information about how to use log4c framework can be found here : https://log4c.sourceforge.net/

For the elos_log4c_demo application a separate category log4c.elos.demo.log4cdemo with an appender elos is created in the config file log4crc as shown above. The category is the log message destination. The appender outputs the log message to the specified output. An example of an log4c appender can be found here : https://sourceforge.net/p/log4c/log4c/ci/master/tree/examples/example_appenders.c. The output can be an output stream, file, syslog etc. The elos_appender has a layout elos_layout which formats the log message using the formatter elos_formatter. An example ofa log4c formatter can be found here : https://sourceforge.net/p/log4c/log4c/ci/master/tree/examples/example_formatters.c. The elos_formatter formats the log message using pattern strings and sends the formatted string back to the appender to be released out.

$ elos_log4c_demo

elosDlt - a demo program to show useage of libelosdlt

Elos provides a basic implementation of the DLT protocol to publish elos events to a DLT daemon. To observer the workings of libelosdlt and DLT, a dlt-daemon is required to be installed and running. Information about dlt-daemon installation and setup can be found here: https://github.com/COVESA/dlt-daemon.

$ elosDlt
usage :
 elosDlt </path/socket|/path/pipe>