Monitoring

Download *-bin.zip distribution archive from repository. Unzip the archive in a directory and within that directory issue the commands described below.

Detect dead units

Synopsis

usage: cythres.sensnet.cli.Monitor [-d <MINS>] [-help] -p <NAME> [-t <URL>] -u <NAME>
 -d,--delay <MINS>      default: 120
 -help                  print this message
 -p,--password <NAME>   password
 -t,--target <URL>      default: https://snog.cythres.cz/sn/rest
 -u,--user <NAME>       username

This utility connects to the target and lists all speechless units managed by a user (see username and password parameters) in admin or superadmin roles. The speechless unit is defined as a unit that did not send any registration or measurement packet for several minutes (see delay parameter).

The output is printed out on stdout:

unit #251 [measurement] Thu Aug 04 10:42:22 CEST 2016
unit #227 [measurement] Tue Oct 25 16:20:01 CEST 2016
unit #220 [measurement] Thu Jul 02 17:37:24 CEST 2015
unit #228 [measurement] Wed Jan 24 17:59:00 CET 2018
unit #233 [measurement] Wed Jan 24 17:56:10 CET 2018
unit #32766 [measurement] Thu Nov 24 08:27:02 CET 2016
unit #232 [measurement] Thu Feb 16 03:28:26 CET 2017
unit #201 [measurement] Thu Jul 02 17:37:24 CEST 2015
:
:

You can easily add this utility to your crontab and/or send the output to your email address, e.g.

java -cp sensnet-cli-0.9.5-SNAPSHOT.jar:lib/* \
  cythres.sensnet.cli.Monitor -u ... -p ... 2>/dev/null | \
  mailx -s "Email subject" user@mailhost.localdomain

Subscribe to measurement packet stream

Synopsis

usage: cythres.sensnet.cli.ws.Sniffer -c <FILENAME> [-help] [-n <HOSTNAME>] -p <NAME> -u <NAME>
 -c,--config <FILENAME>     configuration
 -help                      print this message
 -n,--hostname <HOSTNAME>   default: snog.cythres.cz
 -p,--password <NAME>       password
 -u,--user <NAME>           username

Configuration file

# this is comment
; this is comment
// and another comment - empty lines are skipped over

# unit_id gauge_id tag min(float) max(float) min(int) max(int) set_mask unset_mask flag
200          *      *   -20.5       50.0        -        -        2         1      last
200          *      *     -          -          -        -        0         2
# If unit 200 gives any measurement out of the range [-20.5;50.0], then the unit status sets
# the 2nd bit and clears the 1st bit of the respective unit status. Moreover, this is the last
# line to evaluate for the given sensor/gauge measurement.
# Next, if the previous test is not the case, unit 200 does not anything, but the 2nd bit is cleared.

# unit_id gauge_id tag min(float) max(float) min(int) max(int) set_mask unset_mask flag
*            7      *     -          -          0        10       4         0      last
*            7      *     -          -          -        -        0         4
# Any unit that reads integer values from the sensor/gauge 7 sets the 3rd bit of its status, if and only if
# the values are out of the range [0;10].

This utility listens to all measurement packets which are accepted from units managed or analyzed by a user (see username and password parameters). It means that the user must be in roles superadmin, admin or analytics.

The configuration file is applied onto all gauge/measurements in a single packet (see the technical documentation). The resulting (un)set_mask is computed as OR operation over all separate (un)set_mask values (specified for the respective gauge/measurement values). The status update operation is executed (on the server) for superadmin and admin roles only.

Finally, unit-id, set_mask and unset_mask are printed out onto stdout. You can read this output to send email or log the event somewhere.