Community
OpenEnergyMonitor

Community

Monitoring – Are Inputs/Feeds actually updating?


(John Banks) #1

I have 4 instances of emonTx/RPi running the SD image Oct 2018 to monitor a largish PV system – at the inverter, grid incoming meter, air source heat pump and car charger.

Periodically one or another will stop recording inputs/feeds but I do not discover this until several days later.

Each instance has an AC-AC adapter and so the Vrms input/feed is available as a sign of ‘continuing life’.

I would like to create a script that can be run as a cron job periodically to report on system status/failure.

A simple script to ping each emonTx/RPi is not adequate as I’ve experienced that an emonTX/RPi instance being discoverable on the network does not necessarily mean that emoncms is running correctly.

Forum Resources suggest sudo service emonhub status as a diagnostic command. I’ve tried that – it produces quite a lengthy report …

[email protected]:~ $ sudo service emonhub status
● emonhub.service - LSB: Start/stop emonHub
   Loaded: loaded (/etc/init.d/emonhub; generated; vendor preset: enabled)
   Active: active (running) since Wed 2019-02-13 18:02:04 GMT; 6 days ago
     Docs: man:systemd-sysv-generator(8)
  Process: 938 ExecStart=/etc/init.d/emonhub start (code=exited, status=0/SUCCES
   CGroup: /system.slice/emonhub.service
           └─987 python /usr/share/emonhub/emonhub.py --config-file /home/pi/dat

Feb 13 18:02:04 watchman sudo[948]: pam_unix(sudo:session): session opened for u
Feb 13 18:02:04 watchman sudo[948]: pam_unix(sudo:session): session closed for u
Feb 13 18:02:04 watchman sudo[957]:     root : TTY=unknown ; PWD=/ ; USER=root ;
Feb 13 18:02:04 watchman sudo[957]: pam_unix(sudo:session): session opened for u
Feb 13 18:02:04 watchman sudo[957]: pam_unix(sudo:session): session closed for u
Feb 13 18:02:04 watchman sudo[966]:     root : TTY=unknown ; PWD=/ ; USER=root ;
Feb 13 18:02:04 watchman sudo[966]: pam_unix(sudo:session): session opened for u
Feb 13 18:02:04 watchman sudo[966]: pam_unix(sudo:session): session closed for u
Feb 13 18:02:04 watchman emonhub[938]: Starting OpenEnergyMonitor emonHub: emonh
Feb 13 18:02:04 watchman systemd[1]: Started LSB: Start/stop emonHub.
lines 1-18/18 (END)

How in a script to test for the key words … ‘active (running)’?

Any suggestions would be most welcome

Thank you

John Banks


(John Banks) #2

I’ve found a simple solution after I discovered the command stat and used it as follows …

[email protected]:/ $ stat -c %Z /home/pi/data/phptimeseries/feed_4.MYD && date +%s
1550771918
1550771920

The stat command returns 1550771918 which is the unix time (in secs) when file feed_4.MYD was last changed (updated)

The date command returns the time when the commands were executed. And so if the two times are different by several mins then there must be something wrong with the feed updating.

The feed numeric identifier (4 in this example) is the ID for the feed as shown in the Data Viewer.

So now it’s just a case of creating a simple script that can be run periodically as a cronjob and anything untoward reported in an email.


(Brian Orpin) #3

Try installing monit (sudo apt-get install monit) - great little monitoring package. Will run as a service and monitor services, files folders, almost anything.

Problems like this are reported occasionally, but there has been no firm solution.

Which release of Emoncms are you on?

[edit] I enable and use the inbuilt http server and a node-red node to monitor all my servers

[{"id":"66f88233.c8694c","type":"http request","z":"5fcfec40.91a254","name":"Get Monit Status - 51","method":"GET","ret":"txt","url":"http://192.168.7.51:2812/_status?format=xml","tls":"","x":330,"y":170,"wires":[["32dc118c.cce34e","c975fd10.43b8d"]]}]

I’ve done a couple of Blogs on using monit.