eschava / psmqtt

Utility reporting system health and status via MQTT
MIT License
159 stars 35 forks source link

Raspberry pi CPU temp #9

Closed vzorglub closed 6 years ago

vzorglub commented 6 years ago

Hello, I get an error: Exception: Element 'sensors_temperatures' in 'sensors_temperatures/*' is not supported When using psmqtt on a rapsberry pi zero Has the CPU temperature been implemented for raspis yet?

eschava commented 6 years ago

Sorry, could you please provide more info? What type of request do you use? Is it scheduled request or request via request/* topic?

vzorglub commented 6 years ago

I use a scheduled request:

import socket

mqtt_broker = 'localhost'       # default: 'localhost'
mqtt_port = 1883                # default: 1883
mqtt_clientid = 'psmqtt-1'
mqtt_username = 'username'
mqtt_password = 'password'
mqtt_clean_session = False
mqtt_qos = 0
mqtt_retain = False
mqtt_topic_prefix = 'psmqtt/pizero/'
#mqtt_topic_prefix = 'psmqtt/' + socket.gethostname() + '/'
mqtt_request_topic = 'request'

schedule = {
    "every 1 minute" :    [
        "cpu_percent",
        "virtual_memory/percent",
        "boot_time",
        "sensors_temperatures/*",
     ],
    "every 60 minutes"  :     "disk_usage/percent/|",  # slash replaced with ve$
    "every 3 hours" : {
        "boot_time/{{x|uptime}}": "uptime",
    }
}
eschava commented 6 years ago

I see. Could you please ensure that you use the latest version of psmqtt? I've checked your configuration and it works OK at my box

vzorglub commented 6 years ago

Do I just replace the psmqtt.py file with the new one?

eschava commented 6 years ago

psmqtt.py + handlers.py

vzorglub commented 6 years ago

Nope, not working I'll do a fresh install from rasbian image anyway in a few days time and let you know how it goes Thanks

vzorglub commented 6 years ago

Nope, Fresh raspbian install I am using a pizero

eschava commented 6 years ago

same error?

vzorglub commented 6 years ago

No, no errors, but no message...

On Wed, 19 Sep 2018, 12:55 Eugene Schava, notifications@github.com wrote:

same error?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eschava/psmqtt/issues/9#issuecomment-422773654, or mute the thread https://github.com/notifications/unsubscribe-auth/ASmb4PRMnEzCz_vpeKNERn0HHALWUQKvks5ucjC_gaJpZM4WcTA4 .

eschava commented 6 years ago

How do you check the output?

You can try mosquitto_sub -t -v psmqtt/# command to see all messages sent by psqmtt

Also I've committed minor change that should improve messages sent for sensor_temparatures request

vzorglub commented 6 years ago

I use node-red mqtt node subscribed on # I get the other 3 messages from the pi

vzorglub commented 6 years ago

Still the same, I have changed handlers.py with your latest code but no luck.

vzorglub commented 6 years ago

Ok, I have done a bit of research and it appears that the psutil library doesn't work for sensors_temperature on raspberry pis:

https://github.com/giampaolo/psutil/issues/1310

eschava commented 6 years ago

Thanks for your research! Subscribing to the original issue

vzorglub commented 6 years ago

The original issue was closed. Maybe you have more influence in getting it reopened

On Fri, 21 Sep 2018, 09:21 Eugene Schava, notifications@github.com wrote:

Thanks for your research! Subscribing to the original issue

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eschava/psmqtt/issues/9#issuecomment-423454363, or mute the thread https://github.com/notifications/unsubscribe-auth/ASmb4PYw8oX4y3QNp42CN3XhkL9g84-pks5udKGGgaJpZM4WcTA4 .

eschava commented 6 years ago

It's reopened without my influence :)

vzorglub commented 6 years ago

That's great. Millions of raspberry pis out there...

On Wed, 26 Sep 2018, 15:28 Eugene Schava, notifications@github.com wrote:

It's reopened without my influence :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eschava/psmqtt/issues/9#issuecomment-424735960, or mute the thread https://github.com/notifications/unsubscribe-auth/ASmb4P-eX3Uy2gEGroeAsu4hZ6tuRfMFks5ue473gaJpZM4WcTA4 .

osos commented 3 years ago

There is a specieal command to view rasperry pi temperature. Some info here: https://pimylifeup.com/raspberry-pi-temperature/

Running in bash:

$ /opt/vc/bin/vcgencmd measure_temp
temp=42.0'C

Maybe psmqtt could call that process on raspberry pies