Brush

brush logo

A tool for logging and monitoring data from Menlo Systems optical frequency combs.

Installation

Brush is on PyPI:

$ pip install brush

Python versions of at least 3.3 are recommended, though Brush should work with Python 2.7 if necessary.

Data is stored using a SQL database. PostgresQL is recommended, but any database supported by SQLAlchemy will work.

A database driver library will also need to be installed unless SQLite is used. For example, if using Postgres, the psycopg2 driver should be installed. On Debian-based Linux systems the following commands can be used:

$ sudo apt-get install -y postgresql-server-dev-all
$ pip install psycopg2

See the SQLAlchemy dialect documentation for additional details.

Usage

Brush defines the following command-line options for collecting data:

  --config                         Path to configuration file (default
                                   ~/.brush.conf)
  --debug                          Enable debug output (default False)
  --offline                        Run in offline mode (default False)
  --redis-host                     Redis hostname (default localhost)
  --redis-password                 Redis password
  --redis-port                     Redis port (default 6379)
  --save-when-unlocked             Write data to database when comb is unlocked
                                   (default False)
  --server-port                    Port to serve on (default 8090)
  --server-url-prefix              URL prefix
  --sql-table                      SQL table name (default brush)
  --sql-url                        SQL database URL (default
                                   sqlite:///brush.sqlite)
  --xmlrpc-host                    XMLRPC server hostname
  --xmlrpc-password                XMLRPC server password
  --xmlrpc-port                    XMLRPC server port (default 8123)
  --xmlrpc-user                    XMLRPC server user


These can also be written into a configuration file. For example:

xmlrpc_host = "localhost"
xmlrpc_port = 8123
xmlrpc_user = None
xmlrpc_password = None

sql_url = "sqlite://"

These values are just normal Python variables and will be overridden by any command-line options passed. See the Tornado documentation for additional details on configuration files.

With these settings stored in brush.config, Brush can then be started with the following command:

$ brush --config=brush.config

If using the default port, point your browser to http://localhost:8090 and see the current comb status.

HTTP API

Brush exposes the following routes for accessing data from the web user interface and other programs:

GET /

Render the web UI.

GET /data

Get data starting from the timestamp start up until the timestamp stop. Timestamps must be given as seconds since the epoch (i.e., Unix time) and passed as query arguments in the GET request.

If only start is given, the stop point is the current time.

Example:

http://localhost:8090/data?start=1465727734.4149404

Note

The database stores timestamps in UTC.

GET /data/current

Return the most recent data.

GET /data/recent

Return all data currently in the store.

GET /data/query/(.*)

Return the most recent value for the requested key.

GET /data/metadata

Return comb metadata.

Metadata includes types and descriptions of all data types.

GET /data/keys

Return all data keys.

GET /query/(.*)

Return the most recent value for the requested key.