/
mqttwarn.ini
executable file
·157 lines (117 loc) · 3.74 KB
/
mqttwarn.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- coding: utf-8 -*-
# (c) 2014-2022 The mqttwarn developers
#
# mqttwarn example configuration file "mqttwarn.ini"
#
; ------------------------------------------
; Base configuration
; ------------------------------------------
[defaults]
; ----
; MQTT
; ----
hostname = 'localhost'
port = 1883
username = None
password = None
clientid = 'mqttwarn'
lwt = 'clients/mqttwarn'
skipretained = False
cleansession = False
# MQTTv31 = 3 (default)
# MQTTv311 = 4
protocol = 3
; -------
; Logging
; -------
; Send log output to STDERR
logfile = 'stream://sys.stderr'
; Send log output to file
;logfile = 'mqttwarn.log'
; one of: CRITICAL, DEBUG, ERROR, INFO, WARN
loglevel = DEBUG
; optionally set the log level for filtered messages, defaults to INFO
;filteredmessagesloglevel = DEBUG
;logformat = '%(asctime)-15s %(levelname)-8s [%(name)-25s] %(message)s'
; --------
; Services
; --------
; path to file containing self-defined functions like `format` or `alldata`
functions = 'udf.py'
; name the service providers you will be using.
launch = file, log
; Publish mqttwarn status information (retained)
status_publish = True
; status_topic = mqttwarn/$SYS
; -------
; Targets
; -------
[config:file]
append_newline = True
targets = {
'f01' : ['/tmp/f.01'],
'log-me' : ['/tmp/log.me'],
'mqttwarn' : ['/tmp/mqttwarn.err'],
}
[config:log]
targets = {
'debug' : [ 'debug' ],
'info' : [ 'info' ],
'warn' : [ 'warn' ],
'crit' : [ 'crit' ],
'error' : [ 'error' ]
}
; special config for 'failover' events
[failover]
targets = log:error, file:mqttwarn
; ------------------------------------------
; Basic
; ------------------------------------------
[hello/1]
; echo '{"name": "temperature", "number": 42.42}' | mosquitto_pub -h localhost -t hello/1 -l
targets = log:info
format = '{name}: {number} => {_dthhmm}'
; ------------------------------------------
; OwnTracks
; ------------------------------------------
[owntracks-location]
topic = owntracks/+/+
targets = log:info, file:f01
datamap = OwnTracksTopic2Data()
format = OwnTracksConvert()
[owntracks-battery]
topic = owntracks/+/+
targets = log:info, file:f01
datamap = OwnTracksTopic2Data()
filter = OwnTracksBattFilter()
format = {username}'s phone battery is getting low ({batt}%)
; ------------------------------------------
; Dynamic targets
; ------------------------------------------
[robustness-1]
; even if "foo" is considered an invalid service or
; "log:baz" is considered an invalid service target,
; mqttwarn should keep calm and carry on
topic = test/robustness-1
targets = foo:bar, log:baz
[topic-targets-dynamic]
; interpolate transformation data values into topic target, example:
; mosquitto_pub -t test/topic-targets-dynamic -m '{"loglevel": "crit", "message": "Nur Döner macht schöner!"}'
topic = test/topic-targets-dynamic
format = Something {loglevel} happened! {message}
targets = log:{loglevel}
[topic-targets-func]
; use functions for computing topic targets, example:
; mosquitto_pub -t test/topic-targets-func -m '{"condition": "sunny", "remark": "This should go to a file"}'
; mosquitto_pub -t test/topic-targets-func -m '{"condition": "rainy", "remark": "This should go to the log"}'
topic = test/topic-targets-func
format = Weather conditions changed: It's {condition}. Remark: {remark}
targets = TopicTargetList()
; ------------------------------------------
; Periodic tasks
; ------------------------------------------
[cron]
; Demonstrate periodic task feature.
; Define a function for publishing your public ip address to the MQTT bus each minute.
; mosquitto_sub -t 'test/ip/#' -v
#publish_public_ip_address = 60; now=true