tree: 74368d838bc66131fc101e0f43ffe72fbafad8e6 [path history] [tgz]
  1. internal/
  2. measured/
  3. scripts/
  4. slcli/
  5. Makefile
  6. README.md
go/src/v.io/x/sensorlog/README.md

Sensor Log

Sensor Log is an example Syncbase application for measuring streams of time series data on a group of devices.

A Sensor Log system consists of a master and any number of measuring devices. The master device runs Syncbase and the command line client (slcli), while each measuring device runs Syncbase and the measuring daemon (measured). The client controls the measuring daemon through Syncbase.

Measuring data

Each measuring device runs an instance of measured, which samples data points for one or more measuring streams. A stream is an ordered sequence of data points that are sampled by running a shell script at a set frequency. The slcli tool can be used to write the sampling configuration to the master Syncbase instance, which is then synced to the appropriate measuring device Syncbase. Measured data points are synced back to the master Syncbase, where they can be examined using slcli.

Starting measured

In the instructions below, replace <creds> with the path to Vanadium credentials obtained using principal seekblessings.

measured, along with the required mounttabled and syncbased services, can be started by:

$ V23_CREDENTIALS=<creds> SL_DEVID=dev1 ./scripts/run_measured.sh

By default, it starts a local mount table at port 8707 (override using $SL_IPADDR_PORT), mounts it at /ns.dev.v.io:8101/users/<email-from-blessing>/sl/measured/<devid>, starts a Syncbase instance mounted in the local mount table at sl/measured/<devid>, and a measuring daemon against the Syncbase instance.

Using the client

Before using the client, the master syncbased must be started by:

$ V23_CREDENTIALS=<creds> ./scripts/run_cli_syncbased.sh

By default, it starts a local mount table at port 8202 (override using $SL_IPADDR_PORT) and starts a Syncbase instance mounted in it at sl/client/main (override using $SL_DEVID).

Running

$ V23_CREDENTIALS=<creds> ./scripts/slcli.sh <args>

will invoke the slcli tool with blessings and flags set appropriately for a master stack run with the same environment.

Adding a device

Each measuring device creates a syncgroup which can be joined by a master device. Using the above default configuration, run:

$ V23_CREDENTIALS=<creds> ./scripts/slcli.sh device add /ns.dev.v.io:8101/users/<email-from-blessing>/sl/measured/dev1/sl/measured/dev1/syncbased dev1

Creating a stream

Once a device has been added, streams can be configured on it to start sampling data. The sampling script is expected to output a single floating point value and exit with a zero status code on every invocation, otherwise an error is logged instead of data.

For example, to sample the Answer to Life, the Universe, and Everything every two seconds:

$ V23_CREDENTIALS=<creds> ./scripts/slcli.sh stream create dev1 stream42 2s <<< "echo 42;"

Listing data

To list all data sampled on the stream, run

$ V23_CREDENTIALS=<creds> ./scripts/slcli.sh list dev1 stream42

To keep listing newly measured data until slcli is killed, add -follow:

$ V23_CREDENTIALS=<creds> ./scripts/slcli.sh list -follow dev1 stream42

Debugging

The internal state of the master Syncbase can be examined using sb:

$ V23_CREDENTIALS=<creds> ${JIRI_ROOT}/release/go/bin/vbecome -name sl:client:main ${JIRI_ROOT}/release/go/bin/sb -service /$(dig $(hostname) +short):8202/sl/client/main/syncbased sh sensorlog sldb