Hi all, I’m new on the forums and I did not found any topics regarding MQTT…
I am looking a way to send out the stats of my rigs to a MQTT server and to be able to log the stats to a nice panel like Grafana, and also a realtime monitoring app like Blynk.
I am looking for commands to get the basic info of the miner, I found agent-screen log that cointains all I want, is it possible to run that command without the date output?
I did “solve it” , I am sending all the output to my mqtt server, from the server side I have to parse /n character to keep only the json data… this was simple running node-red on a Raspi
but I struggling to run that script at boot, I did try chrontab but it did not work, and if I place the script in rc.local the rig wont start mining
not sure what is the best way to run a script on the hiveos default user
i got several error …
root@hive192_168_100_174:/opt/scripts# ./output.sh
Error: Unknown option ‘,0.42,0.35],“miner”:“gminer”,“total_khs”:160017,“miner_stats”:{“hs”:[44199723,42’.
Use 'mosquitto_pub --help' to see usage.
root@hive192_168_100_174:/opt/scripts# ./output.sh
Error: Unknown option '51,0.44,0.36],"miner":"gminer","total_khs":160016,"miner_stats":{"hs":[44199795,'.
Use 'mosquitto_pub --help' to see usage.
root@hive192_168_100_174:/opt/scripts#
Would love a little step by step on getting this working, have just started a hiveOS setup and would love to integrate it into my home assistant.
Does anyone know if we can also start/stop miners at all? I would like the ability to stop the mining when my solar/battery drops below a certain % is all.
I would be very interested in this, if someone could walk us through on how to have this bash script that @dcjona mentioned run every time at startup, it would be great.
I would love to monitor all my miner’s stats from home assistant too.
Or suggest any other way to get the data to HA
Edit:
So i copied the .sh contents and filled in my HA address, selected a topic, entered username and password (that i also set in my HA’s mosquitto broker).
Opened shellinabox (by clicking the ip address in the HiveOS UI).
Initial username is user and pw is 1
There is a command in the initial help lines that lets you change your pwd for ssh and vnc, i suggest you do so
Did sudo nano
Pasted all my code - using right click on the background - then pasting in the box that appeared
Saved (crtl+o) as hiveos2mqtt.sh and exited nano
ran sudo bash hiveos2mqtt.sh waited for stuff to download and update
you can exit the script with crtl+c
From the hive side it seems to work ok.
Unfortunately im getting consecutive connections and disconnections on the Broker side.
1621543112: New connection from 10.0.0.110 on port 1883.
1621543112: New client connected from 10.0.0.110 as mosqpub|29832-rig1 (p1, c1, k60, u'hive_os_1').
1621543112: Client mosqpub|29832-rig1 disconnected.
No idea how to troubleshoot this tbh…
The hive mqtt client is working as intended (i guess), connects, publishes, then disconnects.
I’m guessing the next steps if i get it to work would be to do:
sudo nano /hive/etc/crontab.root
add a new line bash -c 'sleep 10 && /home/user/hiveos2mqtt.sh'
which should run it at every startup.
Again i am a total noob on linux so do these at your own risk.
This thing wouldn’t work very well… I noticed it stopped working after a while and had some miner crashes.
So I did this:
Removed the -f flag after the tail command in the script. This way the script reads the last X lines of logs, connects to the mqtt and publishes, then closes.
Created a crontab entry to run it every minute. (* * * * * /path/file.sh)