Skip to content

Nature40/pymqttutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pymqttutil

Publish system information via MQTT.

Usage

$ python3 -m mqttutil --help
usage: mqttutil [-h] [-c CONFIG] [-v] [--mqtt-host MQTT_HOST] [--mqtt-port MQTT_PORT] [--json]

publish system information via mqtt

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        configuration file (default: etc/mqttutil.conf)
  -v, --verbose         increase output verbosity (default: 0)

mqtt:
  --mqtt-host MQTT_HOST
                        hostname of mqtt broker (default: localhost)
  --mqtt-port MQTT_PORT
                        port of mqtt broker (default: 1883)
  --json                publish json dict instead of primitive datatypes (default: False)

Configuration

mqttutil's configuration consists of tasks defined in individual sections, e.g.:

[announce]
func = "platform.node()"
scheduling_interval = "1s"
topic_prefix = ""
requires = ["platform"]

In the example above the python statement platform.node() is evaluated once per second and published to the announce topic. The parameters topic_prefix as well as requires are optional. topic_prefix defaults to the hostname, if not defined.

The parameter requires can be used to import additonal modules, such as the psutil module.

[load]
func = "psutil.getloadavg()"
scheduling_interval = "5s"

DEFAULT section

The DEFAULT section allows to initialize the parameters for all sections. Note that the topic_prefix option is initialized globally by the hostname, and is not required to be set.

[DEFAULT]
scheduling_interval = "5s"

[announce]
func = "platform.node()"
topic_prefix = ""

[unixtime]
func = "time.time()"
requires = ["time"]

A comprehensive example configuration file is provided at etc/mqttutil.conf.

About

Publish system information via MQTT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages