diff options
Diffstat (limited to 'applications/luci-app-statistics/root/usr/libexec/stat-genconfig')
-rwxr-xr-x | applications/luci-app-statistics/root/usr/libexec/stat-genconfig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/applications/luci-app-statistics/root/usr/libexec/stat-genconfig b/applications/luci-app-statistics/root/usr/libexec/stat-genconfig index d60e1a69ed..1bf622d9c1 100755 --- a/applications/luci-app-statistics/root/usr/libexec/stat-genconfig +++ b/applications/luci-app-statistics/root/usr/libexec/stat-genconfig @@ -241,6 +241,33 @@ function config_network(c) { ; } +function config_mqtt(c) { + let str = ""; + + for (let k, s in sections) { + if (s['.type'] === 'collectd_mqtt_block') { + const isPublish = s['blocktype'] === 'Publish'; + + str += isPublish ? `\t<Publish "${s.name}">\n` : `\t<Subscribe "${s.name}">\n`; + + str += `\t\tHost "${s.Host}"\n`; + str += s['Port'] ? `\t\tPort ${s.Port}\n` : ''; + str += s['User'] ? `\t\tUser "${s.User}"\n` : ''; + str += s['Password'] ? `\t\tPassword "${s.Password}"\n` : ''; + str += s['Qos'] ? `\t\tQos ${s.Qos}\n` : ''; + str += s['Prefix'] ? `\t\tPrefix ${s.Prefix}\n` : ''; + str += s['Retain'] ? `\t\tRetain ${s.Retain}\n` : ''; + str += s['StoreRates'] ? `\t\tRetain ${s.StoreRates}\n` : ''; + str += s['CleanSession'] ? `\t\tRetain ${s.CleanSession}\n` : ''; + str += s['Topic'] ? `\t\tTopic "${s.Topic}"\n` : ''; + + str += isPublish ? `\t</Publish>\n` : `\t</Subscribe>\n`; + } + } + + return str; +} + function section(plugin) { let config = sections[`collectd_${plugin}`] ?? sections.collectd; @@ -270,6 +297,7 @@ for (let filename in lsdir(plugin_dir)) { case 'iptables': plugins[name] = config_iptables; break; case 'curl': plugins[name] = config_curl; break; case 'network': plugins[name] = config_network; break; + case 'mqtt': plugins[name] = config_mqtt; break; default: plugins[name] = json(open(`${plugin_dir}/${filename}`))?.legend; } |