eschava / psmqtt

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

Disconnecting every 11 sec #18

Closed smarthomepch closed 3 years ago

smarthomepch commented 3 years ago

Hi, first of all thanks for this. I have it run on my RPi 4 and everything works fine so far :)

Now I try to run it also on RPi Zero W and for some reasons connection to MQTT broker restarts every 11 seconds:

[2021-01-19 21:04:11,064] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:04:22,331] DEBUG OOOOPS! psmqtt disconnects
[2021-01-19 21:04:33,361] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:04:44,434] DEBUG OOOOPS! psmqtt disconnects

[2021-01-19 21:05:39,500] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:05:50,747] DEBUG OOOOPS! psmqtt disconnects
[2021-01-19 21:06:01,774] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:06:12,850] DEBUG OOOOPS! psmqtt disconnects
[2021-01-19 21:06:23,886] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:06:34,953] DEBUG OOOOPS! psmqtt disconnects
[2021-01-19 21:06:45,987] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#

[2021-01-19 21:08:31,758] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:08:42,972] DEBUG OOOOPS! psmqtt disconnects
[2021-01-19 21:08:54,027] DEBUG Connected to MQTT broker, subscribing to topic psmqtt/raspberry/request/#
[2021-01-19 21:09:05,076] DEBUG OOOOPS! psmqtt disconnects

MQTT broker is on another RPi4 (3rd one (!))

As mentioned another connection works fine.

BTW is there any possibity to add IP and MAC addresses per interface (I think both are part of psutil)?

Thanks in advance for help.

eschava commented 3 years ago

You need to change mqtt_clientid parameter in the psmqtt.conf to something else. I guess I need to make it dynamic eventually.

is there any possibity to add IP and MAC addresses per interface (I think both are part of psutil)?

Agree, will implement it when I have free time

smarthomepch commented 3 years ago

Thanks for prompt answer. After mqtt_clientid change everything works fine.

One more thing. Seems that virtual_memory/free/{{x|MB}} is wrongly calculated. Shoudn't Free memory + Used emory be equal to Total memory?

Used and Total memory look OK.

Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-1/virtual_memory/free/{{x|MB}}', ... (6 bytes))
213 MB
Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-1/virtual_memory/used/{{x|MB}}', ... (7 bytes))
1060 MB
Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-1/virtual_memory/total/{{x|MB}}', ... (7 bytes))
3827 MB

Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-2/virtual_memory/free/{{x|MB}}', ... (5 bytes))
78 MB
Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-2/virtual_memory/used/{{x|MB}}', ... (5 bytes))
47 MB
Client mosq-lvs91ccYqkpct5mghA received PUBLISH (d0, q0, r0, m0, 'psmqtt/rasp-2/virtual_memory/total/{{x|MB}}', ... (6 bytes))
431 MB

Agree, will implement it when I have free time

I appreciate :)

eschava commented 3 years ago

You can check docs here https://psutil.readthedocs.io/en/latest/#psutil.virtual_memory

free: memory not being used at all (zeroed) that is readily available; note that this doesn’t reflect the actual memory available (use available instead). total - used does not necessarily match free.

smarthomepch commented 3 years ago

Thanks!