aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2019-11-21 18:28:39 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2019-11-21 18:28:39 +0200
commit8ea7df854fc10cba9c3a19937e3c06b329bd83be (patch)
treeaf6d2698ce4a9070d6ff16145c4011d720f174b1
parent0f89d97bcdaea8e3acc147a59b992dc907ba69fb (diff)
downloadweather-8ea7df854fc10cba9c3a19937e3c06b329bd83be.tar.gz
weather-8ea7df854fc10cba9c3a19937e3c06b329bd83be.zip
Add documentation
-rw-r--r--src/update_database.nim31
-rw-r--r--src/update_graphs.nim17
2 files changed, 48 insertions, 0 deletions
diff --git a/src/update_database.nim b/src/update_database.nim
index 1a27517..0ac4962 100644
--- a/src/update_database.nim
+++ b/src/update_database.nim
@@ -1,3 +1,34 @@
+## RRD database update CGI program. Takes JSON measurements from ruuvitag-upload
+## (https://github.com/oswjk/ruuvitag-upload) as input and stores them in the correct RRD database.
+##
+## The JSON format is as follows:
+##
+## {
+## "alias": {
+## "timestamp": <seconds since unix epoch>,
+## "temperature": <temperature in degrees celcius>,
+## "humidity": <relative humidity (0% - 100%)>,
+## "pressure": <pressure in kilopascals>,
+## "battery_potential": <ruuvitag battery potential in volts>
+## },
+## "another_alias": {
+## ...
+## }
+## }
+##
+## The program should be run with an accompanying CGI script as the main driver. The web server will
+## execute the script which looks like this:
+##
+## #!/path/to/update_database
+## databaseDir = /path/to/where/databases/are
+##
+## This will execute update_database with one argument: the path to this script file.
+## update_database will read this script and parse it as a configuration file. The databaseDir
+## option should point to where the .rrd databases are stored.
+##
+## The update_database program will use the ``alias`` from measurements as the database name (with
+## ``.rrd`` extension).
+
import json
import os
import osproc
diff --git a/src/update_graphs.nim b/src/update_graphs.nim
index 3f902a4..b1747dd 100644
--- a/src/update_graphs.nim
+++ b/src/update_graphs.nim
@@ -1,3 +1,20 @@
+## RRD database graphing tool. Reads all databases from a directory and generates graphs from each
+## of them.
+##
+## The generated graphs include
+##
+## - Temperature for today and yesterday
+## - Temperature for current month and previous month
+## - Relative humidity for today and yesterday
+## - Relative humidity for current month and previous month
+## - Pressure for today and yesterday
+## - Pressure for current month and previous month
+##
+## The database directory is constructed from the path to this executable, by using the relative
+## path ``../database``.
+##
+## The graphs are output to directory specified on the command line.
+
import os
import osproc
import strformat