Item state file writer (JSON/CSV)

Allows to write item states into JSON/CSV text files.

The files can be rotated with any external tool or manually. As soon as the file is rotated, a new one is created automatically.

Setup

Use the template EVA_DIR/share/svc-tpl/svc-tpl-filewriter.yml:

# Event-to-file writer service
command: svc/eva-svc-filewriter
bus:
  path: var/bus.ipc
config:
  # the file path may contain date-time formatting options
  # see https://man7.org/linux/man-pages/man3/strftime.3.html
  #
  # if the rotation is used, the following rules are applied:
  #
  # no date-time fmt: rotated as file_path.rfc3339-date
  # date-time fmt: not rotated, new name is used
  # rotated_path set: files are customly renamed when rotated
  file_path: /tmp/1.csv
  # the rotated path may also contain date-time formatting
  #rotated_path: /tmp/%s.csv
  # flush data after each block (slow, but more reliable)
  auto_flush: false
  # use DOS-style CR/LF
  dos_cr: false
  # csv or json for NDJSON
  format: csv
  # custom fieldset/ordering
  #fields:
    #- oid
    #- type
    #- group
    #- id
    #- timestamp
    #- time
    #- status
    #- value
  # periodically submit all item states
  interval: null
  # do not submit remote disconnected items (useful for zfrepl or similar)
  skip_disconnected: false
  # ignore real-time events
  ignore_events: false
  # deduplicate lines (if already written within the last N seconds)
  #dedup_lines; 3600
  # event queue size
  queue_size: 8192
  # auto-rotation, a cron-like schedule:
  # second minute hour day month weekday year
  #
  # rotates the output file by renaming it to file_path.TIME_RFC3339
  #
  # the year field can be omitted
  # to run rotation every N, use */N
  #
  # the example below rotates the output file every hour
  #auto_rotate: "0 0 * * * *"
  #
  # item OIDs / OID masks
  oids:
    - "#"
  oids_exclude: []
# make sure the user has create/write access for the output file
user: eva

Create the service using eva-shell:

eva svc create eva.svc.fwriter1 /opt/eva4/share/svc-tpl/svc-tpl-filewriter.yml

or using the bus CLI client:

cd /opt/eva4
cat DEPLOY.yml | ./bin/yml2mp | \
    ./sbin/bus ./var/bus.ipc rpc call eva.core svc.deploy -

(see eva.core::svc.deploy for more info)

EAPI methods

See EAPI commons for the common information about the bus, types, errors and RPC calls.

flush

Description

Flushes the output file immediately

Parameters

none

Returns

nothing

rotate

Description

Rotates the output file, by renaming it to file_path.TIME_RFC3339

Parameters

none

Returns

nothing