summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/root/usr/libexec
diff options
context:
space:
mode:
authorMiguel Angel Mulero Martinez <migmul@gmail.com>2023-03-17 19:39:53 +0100
committerPaul Donald <itsascambutmailmeanyway@gmail.com>2024-03-08 02:28:50 +0100
commit8bf5646459e229c1d01736f7c45f3b1c9bf3058f (patch)
tree17eadd2b5b42335b0e557bf6b5c68a287587ab68 /applications/luci-app-statistics/root/usr/libexec
parentc68ec2f910007c77874816fc0b829df78ca47aa0 (diff)
luci-app-statistics: Add UI to configure Mqtt
This commit adds UI to configure the Mqtt plugin of the luci-app-statistics. Signed-off-by: Miguel Angel Mulero Martinez <migmul@gmail.com>
Diffstat (limited to 'applications/luci-app-statistics/root/usr/libexec')
-rwxr-xr-xapplications/luci-app-statistics/root/usr/libexec/stat-genconfig28
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;
}