reactor-c
C Runtime for Lingua Franca
|
#include <stdio.h>
#include "reactor.h"
#include "trace.h"
#include "trace_util.h"
#include "influxdb.h"
Macros | |
#define | LF_TRACE |
#define | MAX_NUM_REACTIONS 64 |
#define | MAX_NUM_WORKERS 64 |
Functions | |
void | usage () |
size_t | read_and_write_trace () |
int | main (int argc, char *argv[]) |
Variables | |
FILE * | trace_file = NULL |
influx_client_t | influx_client |
influx_v2_client_t | influx_v2_client |
instant_t | latest_time = 0LL |
Copyright (c) 2021, The University of California at Berkeley
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Standalone program to send a Lingua Franca trace file to InfluxDB. InfluxDB is a database server to which data can be posted using HTTP or sent as a UDP datagram.
To compile this program, simply do this in this source directory:
This will place an executable program trace_to_influxdb
in the directory usr/local/bin
.
To set up InfluxDB, see:
https://docs.influxdata.com/influxdb/v2.0/get-started/
If you have previously installed InfluxDB and you want a fresh start, do this:
The second command will report any InfluxDB processes that are running. Kill them with
where 'PID' is replaced with whatever process ID(s) are reported by the ps
command above.
To start an InfluxDB server on localhost with port 8087:
The 'reporting-disabled' option simply disables notifications to the InfluxDB mother ship.
You then need to set up at least one user, organization, and bucket. You can do this by pointing your browser to
The browser will walk you through the process of creating a user, password, organization, and initial bucket. E.g.:
The UI in the browser will then give you the options Quick Start or Advanced, either of which you can select. If you select "Data" on the left, you can browse Buckets to verify that your test bucket was created.
First, generate a trace file by setting a target parameter in a Lingua Franca program:
Then, when you run this program, a binary file with extension .lft
will be created.
In your browser, in the InfluxDB UI, select Data on the left, then select the Tokens tab. Select a token and copy the token string to clipboard. It will looks something like this:
Then, invoke the conversion program as follows:
where 'Filename' and the token are replaced with your values. This will upload the trace data to InfluxDB.
You can also specify the following command-line options:
The data can then be viewed in the InfluxDB browser, or you can configure an external tool such as Grafana to visualize it (see https://grafana.com/docs/grafana/latest/datasources/influxdb/).
#define LF_TRACE |
#define MAX_NUM_REACTIONS 64 |
#define MAX_NUM_WORKERS 64 |
int main | ( | int | argc, |
char * | argv[] ) |
size_t read_and_write_trace | ( | ) |
Read a trace in the trace_file and write it to InfluxDB.
void usage | ( | ) |
Print a usage message.
influx_client_t influx_client |
Struct identifying the influx client.
influx_v2_client_t influx_v2_client |
instant_t latest_time = 0LL |
Largest timestamp seen.
FILE* trace_file = NULL |
File containing the trace binary data.