EmonPiFileSystem.md
September 24, 2020 · View on GitHub
EmonCMS file system
| EMONCMS_WWW | /var/www/emoncms | location of the core package and of the main modules (admin, dashboards, config) |
| EMONCMS_DATADIR | /var/opt/emoncms | timeseries database directories |
| EMONCMS_DIR | /opt/emoncms | location of symlinked modules (postprocess, sync) and of uploaded tar.gz archives when importing a backup |
| OPENENERGYMONITOR_DIR | /opt/openenergymonitor | location of EmonScripts, emonhub and of created backup archives |
| EMONCMS_LOG_LOCATION | /var/log/emoncms | log location for emoncms logs emoncms.log is main emoncms log, managed with the EmonLogger PHP class |
main dependencies
| web server | Apache2 | |
| relational databases | mysql or maria | |
| key:value database | redis-server | data buffering for timeseries and backgroud processing for service-runner |
| message broker | mosquitto | |
| data engine language | php with extensions | pear (for pecl needs) mysql gd dev, common mbstring redis mosquitto (https://github.com/mgdm/Mosquitto-PHP) curl |
EmonCMS systemd services
all systemd services have to be symlinked in /etc/systemd/system
emoncms_mqtt.service -> /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.service
emonhub.service -> /opt/openenergymonitor/emonhub/service/emonhub.service
feedwriter.service -> /var/www/emoncms/scripts/services/feedwriter/feedwriter.service
service-runner.service -> /var/www/emoncms/scripts/services/service-runner/service-runner.service
MariaDB and Redis services are in lib/systemd/system, but they are compiled...
mysqld.service -> /lib/systemd/system/mariadb.service
mysql.service -> /lib/systemd/system/mariadb.service
redis.service -> /lib/systemd/system/redis-server.service
| phpmqtt input (PHP) | listen to payloads published to the mosquitto broker on topic emon |
|---|---|
| scriptpath | EMONCMS_WWW/scripts/services/emoncms_mqtt/emoncms_mqtt.php |
| Servicepath | EMONCMS_WWW/scripts/services/emoncms_mqtt/emoncms_mqtt.service |
| globals | mysqli, user, mqtt_server mqtt_client, input, $process |
| non globals | subscribed, last_heartbeat, $count |
| log | uses emoncms main log file journalctl -f -u emoncms_mqtt |
| specific conf file | no |
| feedwriter (PHP) | writes input data from redis-buffer to disk in order to feed the timeseries database |
|---|---|
| scriptpath | EMONCMS_WWW/scripts/feedwriter.php |
| Servicepath | EMONCMS_WWW/scripts/services/feedwriter/feedwriter.service |
| globals | feed_settings, redis feed |
| log | uses emoncms main log file journalctl -f -u feedwriter |
| specific conf file | no |
| Service-runner (Python) | trigger background workers from modules (update, backup, sync, postprocess) |
|---|---|
| scriptpath | EMONCMS_WWW/scripts/services/service-runner/service-runner.py |
| Servicepath | EMONCMS_WWW/scripts/services/service-runner/service-runner.service |
| log | uses systemd log file journalctl -f -u service-runner |
| specific conf file | no |
| emonhub (Python) | listen on serial port or ethernet and publish to mosquitto broker topic emon |
|---|---|
| scriptpath | OPENENERGYMONITOR_DIR/emonhub/src/emonhub.py |
| Servicepath | OPENENERGYMONITOR_DIR/service/emonhub.service |
| log | log file is in /var/log/emonhubjournalctl -u emonhub -n 30 –no-pager |
| specific conf file | /etc/emonhub/emonhub.conf /etc/emonhub/emonhub.env |
| emonPiLCD (Python) | manages the emonpi LCD screen |
|---|---|
| scriptpath | OPENENERGYMONITOR_DIR/emonpi/lcd/emonPiLCD.py |
| Servicepath | OPENENERGYMONITOR_DIR/emonpi/lcd/emonPiLCD.service |
| log | log file is in /var/log/emonpilcdjournalctl -u emonPiLCD |
| specific conf file | no |
EmonCMS modules
| admin | module integrated into the core package - does not have its own git repo |
|---|---|
| place | EMONCMS_WWW/Modules/admin |
| globals | session,updatelogin,redis, admin_show_update, log, log_enabled, $log_level |
| background workers | none |
| log | uses emoncms main log file |
| specific conf file | no |
| config | web interface to supervise and configure emonhub |
|---|---|
| place | EMONCMS_WWW/Modules/config |
| globals | session, homedir |
| non globals | emonhub_logfile, logfile, restart_log_name |
| background workers | restart.sh |
| log | /var/log/emoncms/emonhub-restart.log |
| specific conf file | no |
| dashboard | Dashboard Module |
|---|---|
| place | EMONCMS_WWW/Modules/dashboard |
| globals | session, path |
| background workers | no |
| log | no |
| specific conf file | no |
| graph | main graph module with averaging on the fly |
|---|---|
| place | EMONCMS_WWW/Modules/graph |
| globals | route,redis, $path |
| background workers | no |
| log | no |
| specific conf file | no |
| backup | import/export all timeseries+mysql database |
|---|---|
| place | EMONCMS_DIR/modules/backup |
| globals | session, redis, log_location |
| background workers | emoncms-import.sh emoncms-export.sh emoncms-copy.sh ? service-runner bash file why ? All things related to service-runner are in controller |
| log | EMONCMS_LOG_LOCATION/exportbackup.log EMONCMS_LOG_LOCATION/importbackup.log |
| specific conf file | config.cfg which has to be set up during installation |
| sync | connect to distant EmonCMS machines to retrieve feeds IOT flavoured alternative to backup |
|---|---|
| place | EMONCMS_DIR/modules/sync |
| globals | path,route redis,feed_settings,log in model |
| background workers | emoncms-sync.sh launching sync_run.php in CLI |
| log | EMONCMS_LOG_LOCATION/sync.log also uses emoncms main log file |
| specific conf file | no |
| postprocess | postprocess feeds - calculation module |
|---|---|
| place | EMONCMS_DIR/modules/postprocess |
| globals | session,mysqli,feed_settings, $log_location |
| background workers | postprocess.sh launching postprocess_run.php in CLI Postprocess_run.php scans the redis postprocessqueue and start process functions |
| log | EMONCMS_LOG_LOCATION/postprocess.log |
| specific conf file | no |