This commit is contained in:
Hristo Jelev
2020-05-06 21:52:02 +03:00
parent 1ac8f32f9d
commit d6a971a6b4
3 changed files with 15 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
from random import randrange
# MQTT server configuration
mqtt_host = "192.168.0.13"
mqtt_host = "ip address or host"
mqtt_user = "user"
mqtt_password = "password"
mqtt_port = "1883"
@@ -7,9 +9,14 @@ mqtt_topic_prefix = "rpi-MQTT-monitor"
# Messages configuration
# If this is send to True the script will send just one message containing all values
# If this is set to True the script will send just one message containing all values
group_messages = True
# Random delay in seconds before measuring the values
# - this is used for de-synchronizing message if you run this script on many hosts, set this to 0 for no delay.
# - if you want a fix delay you can remove the randarnge function and just set the needed delay.
random_delay = randrange(30)
# This is the time between sending the indivudual messages
sleep_time = 0.5
cpu_load = True

View File

@@ -112,6 +112,9 @@ if __name__ == '__main__':
# set all monitored values to False in case they are turned off in the config
cpu_load = cpu_temp = used_space = voltage = sys_clock_speed = swap = memory = False
# delay the execution of the script
time.sleep(config.random_delay)
# collect the monitored values
if config.cpu_load:
cpu_load = check_cpu_load()