hi there here a partial update for luci statistic to include mqtt - though i am not sure in collectd Mqtt is working for me as i have not created a graph yet or create a mqtt rrd
-
edit /usr/bin/stat-genconfig
function config_mqtt( c ) local str = "" for s in pairs(sections) do for key, type in pairs({ Sub="collectd_mqtt_sub", Pub="collectd_mqtt_pub" }) do if sections[s][".type"] == type then sname = sections[s].sname host = sections[s].host user = sections[s].user port = sections[s].port topic = sections[s].topic password = sections[s].password pname = sections[s].pname prefix = sections[s].prefix if sname then if user then str = str .. "\t" .. "<Subscribe " .."\"".. sname .."\"".." >" .. " \n" str = str .. "\t" .. "host" .. " \"" .. host .. "\"\n" str = str .. "\t" .. "port" .. " \"" .. port .. "\"\n" str = str .. "\t" .. "user" .. " " .. user .. "\n" str = str .. "\t" .. "password" .. " " .. password .. "\n" str = str .. "\t" .. "topic" .. " \"" .. topic .. "\"\n" str = str .. "\t" .. "CleanSession true" .. " \n" str = str .. "\t" .. "</Subscribe>" .. " \n" else str = str .. "\t" .. "<Subscribe " .."\"".. sname .."\"".." >" .. " \n" str = str .. "\t" .. "host" .. " \"" .. host .. "\"\n" str = str .. "\t" .. "port" .. " \"" .. port .. "\"\n" str = str .. "\t" .. "topic" .. " \"" .. topic .. "\"\n" str = str .. "\t" .. "</Subscribe>" .. " \n" end else str = str .. "\t" .. "<Publish " .."\"".. pname .."\"".." >" .. " \n" str = str .. "\t" .. "host" .. " \"" .. host .. "\"\n" str = str .. "\t" .. "port" .. " \"" .. port .. "\"\n" str = str .. "\t" .. "prefix" .. " \"" .. prefix .. "\"\n" str = str .. "\t" .. "</Publish>" .. " \n" end end end end return str end
and add this to plugin section
mqtt = config_mqtt,
created /usr/lib/lua/luci/model/cbi/luci_statistics/mqtt.lua
-- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
m = Map("luci_statistics",
translate("MQTT Subscriptions"),
translate(
"The MQTT will subscribe to MQTT Topics " ..
"to be displayled "
))
-- collectd_mqtt config section
s = m:section( NamedSection, "collectd_mqtt", "luci_statistics" )
-- collectd_mqtt_sub.enable
enable = s:option( Flag, "enable", translate("Enable this plugin") )
enable.default = 0
-- collectd_mqtt_sub config section (Sub)
sub = m:section( TypedSection, "collectd_mqtt_sub",
translate("MQTT Subscriptions"),
translate(
"This section defines on which subscription collectd will wait " ..
"for incoming data."
))
sub.addremove = true
sub.anonymous = true
-- collectd_mqtt_sub.sname
sub_name = sub:option( Value, "sname", translate("Subscription Name"))
sub_name.default = "Subscription1"
-- collectd_mqtt_sub.hosts
sub_hosts = sub:option( Value, "host", translate("MQTT hosts"))
sub_hosts.default = "127.0.0.1"
-- collectd_mqtt_sub.port
sub_port = sub:option( Value, "port", translate("MQTT port") )
sub_port.isinteger = true
sub_port.default = "1883"
-- collectd_mqtt_sub.user
sub_user = sub:option( Value, "user", translate("MQTT User") )
sub_user.isinteger = true
sub_user.default = ""
-- collectd_mqtt_sub.password
sub_password = sub:option( Value, "password", translate("MQTT password") )
sub_password.isinteger = true
sub_password.default = ""
-- collectd_mqtt_sub.topic
sub_topic = sub:option( Value, "topic", translate("Topic to Subscribe too") )
sub_topic.isinteger = true
sub_topic.default = "incoming/#"
-- collectd_mqtt_pub config section (Pub)
pub = m:section( TypedSection, "collectd_mqtt_pub",
translate("Publish MQTT"),
translate(
"This section defines to which MQTT servers it will publish MQTT " ..
"data to."
))
pub.addremove = true
pub.anonymous = true
-- collectd_mqtt_pub.pname
pub_name = pub:option( Value, "pname", translate("Publish Name"))
pub_name.default = "PublishCollectd"
-- collectd_mqtt_pub.host
pub_host = pub:option( Value, "host", translate("MQTT host") )
pub_host.default = "localhost"
-- collectd_mqtt_pub.port
pub_port = pub:option( Value, "port", translate("MQTT port") )
pub_port.default = ""
pub_port.isinteger = true
pub_port.optional = true
-- collectd_mqtt_pub.prefix
pub_prefix = pub:option( Value, "prefix", translate("Prefix") )
pub_prefix.default = "collectd"
return m
added the /usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
mqtt = _("MQTT"),
and added mqtt to this section
network = { "conntrack", "dns", "interface", "iptables", "mqtt",
"netlink", "olsrd", "openvpn", "ping",
"splash_leases", "tcpconns", "iwinfo" }
edit /etc/config/luci_statistics
config statistics 'collectd_mqtt'
option enable '1'
It creates the proper config and collectd starts with out errors
I am uncertain how to create a graph this is where I am mainly stuck
create /usr/lib/lua/luci/statistics/rrdtool/definitions/mqtt.lua
also I am uncertain if mqtt plugin is working does it automatically produce a rrd container or it has to be explicitly told to create a rrd container in openwrt ????