for those who might want to use collectd_mod_tail_csv - to read and process CSV into useable data for collectd.. say to read snort log outputs to display in luci - statistics -- I never built a graph function for it as it just use it to collect the data into collectd and then pass it on to influxdatabase --
nano /usr/bin/stat-genconfig
--################################--
function config_tail_csv( c )
local str = ""
for s in pairs(sections) do
for key, type in pairs({ Pub="collectd_tail_csv_metric" }) do
if sections[s][".type"] == type then
mname = sections[s].mname
type = sections[s].type
instance = sections[s].instance
valuefrom = sections[s].valuefrom
if mname then
str = str .. "\t" .. "<Metric " .."\"".. mname .."\"".." >" .. " \n"
str = str .. "\t" .. "Type" .. " \"" .. type .. "\"\n"
str = str .. "\t" .. "Instance" .. " \"" .. instance .. "\"\n"
str = str .. "\t" .. "ValueFrom" .. " " .. valuefrom .. "\n"
str = str .. "\t" .. "</Metric>" .. " \n"
end
end
for key, type in pairs({ Sub="collectd_tail_csv_file" }) do
if sections[s][".type"] == type then
finstance = sections[s].finstance
plugin = sections[s].plugin
fname = sections[s].fname
interval = sections[s].interval
collect = sections[s].collect
Collect2 = sections[s].Collect2
Collect3 = sections[s].Collect3
Collect4 = sections[s].Collect4
timefrom = sections[s].timefrom
if fname then
str = str .. "\t" .. "<File " .."\"".. fname .."\"".." >" .. " \n"
str = str .. "\t" .. "Instance" .. " \"" .. finstance .. "\"\n"
str = str .. "\t" .. "Plugin" .. " \"" .. plugin .. "\"\n"
str = str .. "\t" .. "Interval" .. " " .. interval .. "\n"
if Collect4 then
str = str .. "\t" .. "Collect" .. " \"" .. Collect .. "\" \"" .. Collect2 .. "\" \"" .. Collect3 .. "\" \"" .. Collect4 .. "\"\n"
else
if Collect3 then
str = str .. "\t" .. "Collect" .. " \"" .. Collect .. "\" \"" .. Collect2 .. "\" \"" .. Collect3 .. "\"\n"
else
if Collect2 then
str = str .. "\t" .. "Collect" .. " \"" .. Collect .. "\"\"" .. Collect2 .. "\"\n"
else
str = str .. "\t" .. "Collect" .. " \"" .. Collect .. "\"\n"
end
end
end
--str = str .. "\t" .. "Collect" .. " \"" .. collect .. "\"\n"
str = str .. "\t" .. "TimeFrom" .. " " .. "0" .. "\n"
str = str .. "\t" .. "</File>" .. " \n"
end
end
end
end
end
return str
end
--###############################--
and add this to plugin section
tail_csv = config_tail_csv,
then -- nano /usr/lib/lua/luci/model/cbi/luci_statistics/tail_csv.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("CSV Metrics "),
translate(
"The Metrics Name and Type from CSV " ..
"to be displayled "
))
-- collectd_tail_csv config section
s = m:section( NamedSection, "collectd_tail_csv", "luci_statistics" )
-- collectd_tail_csv_metric.enable
enable = s:option( Flag, "enable", translate("Enable this plugin") )
enable.default = 0
-- collectd_mqtt_sub config section (Pub)
pub = m:section( TypedSection, "collectd_tail_csv_metric",
translate("CSV Metrics"),
translate(
"This section defines metrics of the CSV collectd will gather " ..
" incoming data from."
))
pub.addremove = true
pub.anonymous = true
-- collectd_tail_csv_metric.mname
pub_mname = pub:option( Value, "mname", translate("Metrics Name"))
pub_mname.default = "Metric1"
-- collectd_tail_csv.type
pub_type = pub:option( Value, "type", translate("Collectd Type"))
pub_type.default = "percent"
-- collectd_tail_csv.instance
pub_instance = pub:option( Value, "instance", translate("CSV's metric Name") )
pub_instance.default = "value"
-- collectd_tail_csv.valuefrom
pub_valuefrom = pub:option( Value, "valuefrom", translate("Column Data is in") )
pub_valuefrom.default = "1"
-- collectd_tail_csv_file config section (Sub)
sub = m:section( TypedSection, "collectd_tail_csv_file",
translate("What CSV to Collect"),
translate(
"This section defines what CSV file to read and where to save the " ..
"data to."
))
sub.addremove = true
sub.anonymous = true
-- collectd_tail_csv.fname
sub_fname = sub:option( Value, "fname", translate("The CSV File location"))
sub_fname.default = "/tmp/tmp.csv"
-- collectd_tail_csv.finstance
sub_finstance = sub:option( Value, "finstance", translate("Name") )
sub_finstance.default = "Data1"
-- collectd_tail_csv.finstance
sub_plugin = sub:option( Value, "plugin", translate("Name to Save and Display as") )
sub_plugin.default = "tail_csv"
-- collectd_tail_csv.interval
sub_interval = sub:option( Value, "interval", translate("what interval rate to check for changes in csv") )
sub_interval.default = "60"
-- collectd_tail_csv.collect
sub_collect = sub:option( Value, "collect", translate(" Metric Name1 to collect ") )
sub_collect.default = "Metric1"
-- collectd_tail_CSV.Collect2
sub_Collect2 = sub:option( Value, "Collect2", translate("Metric Name2") )
sub_Collect2.default = ""
sub_Collect2.optional = true
-- collectd_tail_csv.Collect3
sub_Collect3 = sub:option( Value, "Collect3", translate("Metric Name3") )
sub_Collect3.default = ""
sub_Collect3.optional = true
-- collectd_tail_csv.Collect4
sub_Collect4 = sub:option( Value, "Collect4", translate("Metric Name4") )
sub_Collect4.default = ""
sub_Collect4.optional = true
-- collectd_tail_csv.timefrom
sub_timefrom = sub:option( Value, "timefrom", translate("What column to get Time from") )
sub_timefrom.default = ""
sub_timefrom.optional = true
return m
then add these to nano /usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
tail_csv = _("CSV"),
add to network section
network = { "conntrack", "dns", "interface", "iptables", "tail_csv",
"netlink", "olsrd", "openvpn", "ping",
"splash_leases", "tcpconns", "iwinfo" }
lastly edit nano /etc/config/luci_statistics
config statistics 'collectd_tail_csv'
option enable '1'
you need to set file location first save and then add in metrics afterward.. it has some particularities to how stat_genconfig works for some reason it always places the 3rd metric at the bottom of the list when generating collectd.conf .. but I think that is due to the naming of the subgroup "file" and "metric". I can get it to put all the "file" subgroup at the top but never the entire "metric" subgroup - it think it somehow related to alphabetical order difference between the name "file" and "metric" . so it always places the 3rd metric at the bottom of the list you can add multiple of metrics after that but always the third one is at the bottom of the list.. which is fine it does no harm there you just have to repeat the 3 metric twice and it will work fine with no error you just can not have the "file" come before the "metrics" then it will fail with errors .. if someone has a solution to that great post it