diff options
| -rw-r--r-- | src/update_database.nim | 31 | ||||
| -rw-r--r-- | src/update_graphs.nim | 17 |
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 |
