diff options
| author | Blaise Thompson <blaise@untzag.com> | 2020-10-30 16:21:09 -0500 | 
|---|---|---|
| committer | Blaise Thompson <blaise@untzag.com> | 2020-10-30 16:21:09 -0500 | 
| commit | 454ebe99359cc22fcff74625320024a7b5353045 (patch) | |
| tree | ec08fc04da60de311d4aa3af5bf981bbcea97b19 | |
| parent | 008a3dfe234a0207f7c558559cebae993083099f (diff) | |
examples
| -rw-r--r-- | docker-compose.yml | 2 | ||||
| -rw-r--r-- | influxdb/dockerfile | 6 | ||||
| -rw-r--r-- | web/index.html | 26 | ||||
| -rw-r--r-- | web/style.css | 17 | ||||
| -rw-r--r-- | write-influx/write_influx.py | 4 | 
5 files changed, 42 insertions, 13 deletions
diff --git a/docker-compose.yml b/docker-compose.yml index 9201a9a..d5b0812 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services:    web:      build: ./web      ports: -      - 8080:80 +      - 80:80      depends_on:        - broker        - db diff --git a/influxdb/dockerfile b/influxdb/dockerfile index 0a36f75..d3f86a2 100644 --- a/influxdb/dockerfile +++ b/influxdb/dockerfile @@ -3,10 +3,4 @@ FROM influxdb:1.8  ENV TZ=America/Chicago  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -ENV INFLUXDB_DB="homie" -ENV INFLUXDB_ADMIN_USER="admin" -ENV INFLUXDB_ADMIN_PASSWORD="mypassword" -ENV INFLUXDB_READ_USER="millikan" -ENV INFLUXDB_READ_USER_PASSWORD="1.602e-19" -  RUN ./init-influxdb.sh diff --git a/web/index.html b/web/index.html index fbbbf1c..59e3aeb 100644 --- a/web/index.html +++ b/web/index.html @@ -81,25 +81,43 @@ Device history older than two years will automatically be deleted.  </p>  <p> -Homie data is written to the database with each [node] as one [field]. +Homie data is written to the database with each node corresponding to one field.  All of the additional information that is represented within the homie hierarchy is stored as tags.  </p>  <p> -EXAMPLE CURL +The following example will return all of the recorded "temperature" measurements within the last one day using curl.  </p> +<pre><code> +curl -G 'mosquitto.chem.wisc.edu:8086/query?pretty=true' --data-urlencode "db=homie" --data-urlencode "q=SELECT \"value\" FROM \"temperature\" WHERE time > now() - 1d" + +</code></pre> +  <p> -EXAMPLE PYTHON +The following example will return all of the recorded "temperature" measurements within the last one day using Python. You will need the <a href="https://influxdb-client.readthedocs.io/">influxdb Python package</a>.  </p> +<pre><code> +import influxdb + +client = influxdb.InfluxDBClient(host="mosquitto.chem.wisc.edu", +                                 database="homie") + +result = c.query("SELECT value FROM temperature WHERE time > now() - 1d") + +</code></pre> +  <p> -RECOMMEND GRAFANA +We have also set-up a <a href="https://grafana.com/">grafana</a> appliance with this database as a source. +Check it out at <a href="grafana.chem.wisc.edu">grafana.chem.wisc.edu</a>.  </p>  <hr>  <p> +<a href="https://git.chem.wisc.edu/shop/mqtt">source</a> +                                                         <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>: no copyright  </p> diff --git a/web/style.css b/web/style.css index 4e33ceb..d109581 100644 --- a/web/style.css +++ b/web/style.css @@ -16,3 +16,20 @@ body {    text-align: left;    overflow-y: scroll;  } + +pre { +  width: 80ch; +  padding: 15px; +  margin-left: auto; +  margin-right: auto; +  overflow: auto; +  overflow-y: hidden; +  font-size: 15.3px; +  background: #ffffff; +  border: 1px solid #c5c8c6; +} + +code { +  background: #ffffff; +  color: #c82829 +} diff --git a/write-influx/write_influx.py b/write-influx/write_influx.py index 7337c9d..ccfb15d 100644 --- a/write-influx/write_influx.py +++ b/write-influx/write_influx.py @@ -68,8 +68,8 @@ def on_message(client, userdata, msg):  influx_client = InfluxDBClient(host="db",                                 port=8086, -                               username="admin", -                               password="mypassword", +                               username="root", +                               password="root",                                 database="homie")  influx_client.create_database("homie")  | 
