csw-event-cli
A command line application that facilitates interaction with Event Service. It accepts various commands to publish and subscribe to events.
Supported Commands
- inspect
- get
- publish
- subscribe
inspect
Takes a comma separated list of events and displays event’s parameter information which includes key name, key type and unit along with metadata (event key, timestamp & id).
-e
,--events
: comma separated list of events to inspect
Examples:
csw-event-cli inspect -e wfos.prog.cloudcover,wfos.prog.filter
inspect
command does not display parameter values. To view values, use get
command instead.
get
Takes a comma separated list of events with nested key paths and displays event information including values either in oneline or json format.
-e
,--events
comma separated list of events in the form of<event1:key1>,<event2:key2:key3>
, use:
to separate multiple keys for same event. Ex.-e a.b.c:struct1/ra,x.y.z:struct2/dec:epoch
-o
,--out
output format, default is oneline-t
,--timestamp
display timestamp--id
display event id-u
,--units
display units
Examples:
-
Displays all keys information in oneline form for eventcsw-event-cli get -e wfos.prog.cloudcover
wfos.prog.cloudcover
-
csw-event-cli get -e wfos.prog.cloudcover:struct1/ra:epoch -t --id -u
Displays information of only
struct1/ra
andepoch
keys as well astimestamp
,event id
andunits
of provided keys in oneline form for eventwfos.prog.cloudcover
-
csw-event-cli get -e wfos.prog.cloudcover:epoch,wfos.prog.filter:ra
Displays information of
epoch
of eventwfos.prog.cloudcover
andra
key of eventwfos.prog.filter:ra
-
csw-event-cli get -e wfos.prog.cloudcover:epoch -o json
Displays event
wfos.prog.cloudcover
with onlyepcoh
key in JSON format.
-t
, --id
& --u
options are not applicable when -o json
option is provided. Event displayed in json
format will always have timestamp
, event id
and units
irrespective of whether those options are provided or not via CLI.
publish
Publishes an event to event server from provided input data file or CLI params.
-e
,--event
event key to publish--data
absolute file path which contains event in JSON format--params
pipe ‘|’ separated list of params enclosed in double quotes in the form of"keyName:keyType:unit=values| ..."
. unit is optional here. Supported key types are:[i = IntKey | s = StringKey | f = FloatKey | d = DoubleKey | l = LongKey | b = BooleanKey]
. You can optionally choose to enclose param values in [, ] brackets. Values of string key should be provided in single quotes and use backslash to escape string. Ex."addressKey:s=['Kevin O\'Brien','Chicago, USA']|timestampKey:s=['2016-08-05T16:23:19.002']"
-i
,--interval
interval in<ms>
to publish event, single event will be published if not provided-p
,--period
publish events for this duration<seconds>
on provided interval. Default is2147483
seconds.
If --data
& --params
are provided together, then event is generated from both --data
file & --params
option. --params
takes a precedence and overrides params from event data file if it is already present in the file.
Option -p
should be used with -i
, otherwise -p
is ignored.
Examples:
-
Creates event from provided JSON file and publishes same with keycsw-event-cli publish -e wfos.prog.cloudcover --data /path/to/event.json
wfos.prog.cloudcover
to event server. -
csw-event-cli publish -e wfos.prog.cloudcover --data /path/to/event.json -i 500 -p 60
Creates event from provided JSON file and publishes same event at every
500ms
for duration of60s
. -
csw-event-cli publish -e wfos.prog.cloudcover --params "k1:s=['Kevin O\'Brien','Chicago, USA']|k2:s=['2016-08-05T16:23:19.002']"
First fetches already published event for key
wfos.prog.cloudcover
from event server and then updates that event with provided--params
If provided keys are already present in existing event, then those will be updated else new param entries will be added to event. If no event is published in past for provided key, then new event gets created with provided params and event key.
subscribe
Takes a comma separated list of events with nested key paths and displays continuous stream of event information as soon as it receives event.
-e
,--events
comma separated list of events in the form of<event1:key1>,<event2:key2:key3>
, use:
to separate multiple keys for same event. Ex.-e a.b.c:struct1/ra,x.y.z:struct2/dec:epoch
-i
,--interval
interval in<ms>
, receive an event exactly at each interval-o
,--out
output format, default is oneline-t
,--timestamp
display timestamp--id
display event id-u
,--units
display units
Examples:
-
Subscribes to event keycsw-event-cli subscribe -e wfos.prog.cloudcover
wfos.prog.cloudcover
and displays all keys information as soon as there is an event published for keywfos.prog.cloudcover
in the form of oneline. -
csw-event-cli subscribe -e wfos.prog.cloudcover:struct1/ra:epoch -t --id -u
Subscribes to event key
wfos.prog.cloudcover
and displays information of onlystruct1/ra
andepoch
keys along withtimestamp
,event id
andunits
of provided keys in oneline form as soon as there is an event published for keywfos.prog.cloudcover
. -
csw-event-cli subscribe -e wfos.prog.cloudcover -i 500
Subscribes to event key
wfos.prog.cloudcover
and displays all keys information at provided interval <500ms>. Irrespective of whether there are multiple events published for keywfos.prog.cloudcover
within500ms
interval or not, at every tick (i.e. 500ms), latest event information will be displayed on the console. -
csw-event-cli subscribe -e wfos.prog.cloudcover:epoch -o json
Subscribes to event key
wfos.prog.cloudcover
and displays onlyepoch
key information as soon as there is an event published for keywfos.prog.cloudcover
in the form of JSON.
-t
, --id
& --u
options are not applicable when -o json
option is provided. Event displayed in json
format will always have timestamp
, event id
and units
irrespective of whether those options are provided or not via CLI.
About this application
--help
Prints the help message.
--version
Prints the version of the application.
All the above examples require that csw-location-server
is running on local machine at localhost:7654
. If csw-location-server
is running on remote machine having Ip address 172.1.1.2
, then you need to pass additional --locationHost 172.1.1.2
command line argument. Example: csw-event-cli get -e wfos.prog.cloudcover --locationHost 172.1.1.2
Testing/Development
While testing or development, in order to use this CLI application, below prerequisites must be satisfied:
- csw-location-server application is running.
- csw-location-agent application is running, which has started event server and registered it to location service.
Please refer Starting apps for development section for more details on how to start these applications using csw-services.sh
script.
Monitor statistics
Event Service
uses redis as a event store. Using redis-cli
, you can monitor continuous stats about Event service.
$ redis-cli --stat
------- data ------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
305 20.70M 605 0 1771418 (+0) 615
305 20.71M 605 0 1825363 (+53945) 615
305 20.70M 605 0 1877638 (+52275) 615
305 20.71M 605 0 1910198 (+32560) 615
305 20.71M 605 0 1960837 (+50639) 615
305 20.74M 605 0 2001565 (+40728) 615
In above example, new line is printed every second with useful information and also the difference between the current and old data point.
keys
: Represents all the keys present in the Redis database which in case of event service are EventKeysclients
: Represents total number of clients currently connected to Redis serverrequests
: Represents total number of Redis commands processed along with delta between every interval, in this case 1 secondconnections
: Represents total number of socket connections opened to Redis server
The -i <interval>
option in this case works as a modifier in order to change the frequency at which new lines are emitted. The default is one second.
You can explicitly pass hostname and port of Redis server while running redis-cli
$ redis-cli -h redis.tmt.org -p 6379
Detailed list of operations you can perform with redis-cli
can be found here