Ruuvi and RPi3 w Grafana & InfluxDB

Hi gang -

First time poster here and newbie to Ruuvi…

As part of my first project, I followed this post on setting up my Ruuvi/RPi3: https://blog.ruuvi.com/rpi-gateway-6e4a5b676510

This works great initially, but after a couple of days, I’m no longer recording data. Checking the status of the Grafana server shows the following error: “Jan 31 13:25:55 rpri-ruuvi grafana-server[431]: t=2020-01-31T13:25:55-0600 lvl=info msg=“Alert Rule returned no data” logger=alerting.evalHandler ruleId=1 name=“Battery Voltage (mV) alert” changing state to=no_data”

Using the Ruuvi app, works fine. Any suggestions on what to do to troubleshoot? Please keep in mind that I’m a newbie…

Thanks!

Hello,

There’s a growing number of reports about HCITool crashing in Pi installations since summer 2019. There’s probably some underlying problem with the Raspbian or HCItool, but how to fix it is yet on known. As a workaround you can have a cron job restart the collector.

1 Like

Thanks for the response Otso. Can you provide steps for creating the cron job?

That was it. I restarted the collector and now I’m getting data again.

Hello, here’s one example with nightly reboots: https://askubuntu.com/questions/13730/how-can-i-schedule-a-nightly-reboot. It might be enough to run hciconfig reset instead of full reboot, but I haven’t had a chance to verify that yet.

1 Like

Thank you very much!

sudo hciconfig reset # didn’t help in my case on 1/30/20.

My plan, rather than periodically (by cron ) reset/restart,
is to periodically check at lowest level and take corrective action only if failure is present.

At this time that means running hciconfig and checking output and if it times out invoking:

sudo logger -p kern.alert " " ++ rebooting due to HCI hangup "

sudo shutdown --reboot +5m " ++ rebooting due to HCI hangup "

I would love to hear from anyone with a more “gentle” corrective action.

1 Like

Thanks for the ideas dgerman… How do you determine if the failure is present? Complete newbie, but learning.

To check if bluetooth is hung :

Option #1 : Check output from lowest level device query like hciconfig -a. This normally reports 17 lines. If Bluetooth is hung reports much less.
I seem to have lost the example I created when it hung for me.

Option#2: Check if any data is being processed by background running hcitool lescan which is started by RuuviCollector using hcidump

To Check that RuuviCollector is updating database. For example:

echo "select temperature from ruuvi_measurements where time > now() -2m" |
influx -precision rfc3339 -database ruuvi >temperatureRecent.log

Is that detailed enough?

By newbie do you mean new to Ruuvi or linux…?

2 Likes

Newbie to both actually… I can follow the guides easy enough and know enough to be dangerous. Love learning new stuff and enjoy playing around with this tech.

Is there a way to automatically check these connections via your commands and then issue the restart, based upon a lack of connections? I’ve never built a cron job yet.

There is nothing special about a cron job. It’s just any script which is invoked periodically by the cron daemon. The schedule is managed with
crontab -e
See the best documentation (I wrote it! :slight_smile: ) crontab

Are you still seeing hangups? If so what are the responses to the checking options I suggested?

2 Likes

No hangups in the last three days (of course I fully expect it to crash now that I 've said it out loud)…

hciconfig -a results look good so far:
RX bytes:6225293 acl:1 sco:0 events:203621 errors:0
TX bytes:142465 acl:0 sco:0 commands:19221 errors:0

When I run the “select temperature…” command you provided, I get: -bash: syntax error near unexpected token `(’

ARGH! STUPID forum editor changed my quotes to fancy left quote and right quote.

I fixed them, try again.


re hciconfig: it's not errors you are looking for but rather the fact that it reports 17 lines!
1 Like

Perfect… When I run the “select temperature”, nothing returns, which means it’s writing to influx?

hciconfig, returns the 17 lines.

Thanks for the “best” contab link! I’m gonna check that out and try to incorporate it into my setup.

The last part of the command
>temperatureRecent.log
redirects the standard output (STDOUT) which should contain something like:

name: ruuvi_measurements
time                           temperature
----                           -----------
2020-02-07T15:37:16.29571043Z  18.49
2020-02-07T15:37:21.399290325Z 8.815

If there are no measurements selected the file will be empty - a bad thing!

You can then use grep to find the lines containing a colon (like in the time of the data)

grep ':' temperatureRecent.log
RS=$?

This command saves the return status from the command which will be 0 if it is successful and nonzero if grep is unable to find a : in the file.
You can then use a command like:

 if [ $RS -ne 0 ] ; then echo no recent entries in influxdb ; fi

More details about bash if statement are at: bash if

If this is run by cron the output of the echo will be emailed to you. (if you have mail configured).

2 Likes