[luci] [PATCH] luci/luci-app-statistics: add support for collectd-mod-apcups to luci-app-statistics

James Klaas jklaas at appalachian.dyndns.org
Mon Apr 6 16:55:23 CEST 2015


This is a patch to add support to luci-app-statistics for
collectd-mod-apcups.

diff -ruN orig/etc/config/luci_statistics new/etc/config/luci_statistics
--- orig/etc/config/luci_statistics 2014-09-23 02:16:42.000000000 -0400
+++ new/etc/config/luci_statistics 2015-04-06 10:15:37.526954877 -0400
@@ -79,6 +79,11 @@
 config 'statistics' 'collectd_load'
  option 'enable' '1'

+config statistics 'collectd_apcups'
+ option enable '0'
+ option Host 'localhost'
+ option Port '3551'
+
 config 'statistics' 'collectd_logfile'
  option 'enable' '0'
  option 'LogLevel' 'notice'
diff -ruN orig/usr/bin/stat-genconfig new/usr/bin/stat-genconfig
--- orig/usr/bin/stat-genconfig 2014-09-23 02:16:42.000000000 -0400
+++ new/usr/bin/stat-genconfig 2015-04-06 10:06:16.051309149 -0400
@@ -261,6 +261,12 @@
  { }
  },

+ apcups = {

+ { "Host", "Port" },
+ { },
+ { }
+ },

+
  conntrack = {
  { },
  { },
diff -ruN
orig/usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
new/usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
--- orig/usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
2014-09-23 02:16:42.000000000 -0400
+++ new/usr/lib/lua/luci/controller/luci_statistics/luci_statistics.lua
2015-04-06 10:07:57.483967224 -0400
@@ -32,7 +32,7 @@
  s_output = _("Output plugins"),
  s_system = _("System plugins"),
  s_network = _("Network plugins"),
-
+ apcups = _("APCUPS"),
  conntrack = _("Conntrack"),
  cpu = _("Processor"),
  csv = _("CSV Output"),
@@ -62,7 +62,7 @@
  -- our collectd menu
  local collectd_menu = {
  output  = { "csv", "network", "rrdtool", "unixsock" },
- system  = { "cpu", "df", "disk", "email", "exec", "irq", "load",
"memory", "nut", "processes", "uptime" },
+ system  = { "apcups", "cpu", "df", "disk", "email", "exec", "irq",
"load", "memory", "nut", "processes", "uptime" },
  network = { "conntrack", "dns", "interface", "iptables", "netlink",
"olsrd", "ping", "tcpconns", "iwinfo" }
  }

diff -ruN orig/usr/lib/lua/luci/model/cbi/luci_statistics/apcups.lua
new/usr/lib/lua/luci/model/cbi/luci_statistics/apcups.lua
--- orig/usr/lib/lua/luci/model/cbi/luci_statistics/apcups.lua 1969-12-31
19:00:00.000000000 -0500
+++ new/usr/lib/lua/luci/model/cbi/luci_statistics/apcups.lua 2015-04-06
10:09:41.128639904 -0400
@@ -0,0 +1,40 @@
+--[[
+
+Luci configuration model for statistics - collectd load plugin
configuration
+(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm at leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
+m = Map("luci_statistics",
+ translate("APCUPS Plugin Configuration"),
+ translate(
+ "The APSUPS plugin collects statistics about the APC UPS."
+ ))
+
+-- collectd_apcups config section
+s = m:section( NamedSection, "collectd_apcups", "luci_statistics" )
+
+-- collectd_apcups.enable
+enable = s:option( Flag, "enable", translate("Enable this plugin") )
+enable.default = 0
+
+-- collectd_apcups.host (Host)
+host = s:option( Value, "Host", translate("Monitor host"), translate ("Add
multiple hosts separated by space."))
+host.default = "localhost"
+host:depends( "enable", 1 )
+
+-- collectd_apcups.port (Port)
+port = s:option( Value, "Port", translate("Port for apcupsd
communication") )
+port.isinteger = true
+port.default   = 3551
+port:depends( "enable", 1 )
+
+return m
diff -ruN orig/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua
new/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua
--- orig/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua
1969-12-31 19:00:00.000000000 -0500
+++ new/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua
2015-04-06 10:41:44.261245653 -0400
@@ -0,0 +1,112 @@
+--[[
+
+Luci statistics - apcups plugin diagram definition
+Copyright © 2008 Freifunk Leipzig / Jo-Philipp Wich <
xm at leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+
+module("luci.statistics.rrdtool.definitions.apcups",package.seeall)
+
+function rrdargs( graph, plugin, plugin_instance, dtype )
+
+ local voltages = {
+ title = "%H: Voltages on APCUPS ",
+ vlabel = "V",
+ number_format = "%5.1lfV",
+ data = {
+ instances = {
+ voltage = { "battery", "input", "output" }
+ },
+
+ options = {
+ voltage_output  = { color = "00e000", title = "Output voltage",
noarea=true, overlay=true },
+ voltage_battery = { color = "0000ff", title = "Battery voltage",
noarea=true, overlay=true },
+ voltage_input   = { color = "ffb000", title = "Input voltage",
noarea=true, overlay=true }
+ }
+ }
+ }
+
+ local percentload = {
+ title = "%H: Load on APCUPS ",
+ vlabel = "Percent",
+ y_min = "0",
+ y_max = "100",
+ number_format = "%5.1lf%%",
+ data = {
+ sources = {
+                                percent_load = { "percent" }

+                        },
+ instances = {
+ percent = "percent"
+ },
+ options = {
+ percent_percent = { color = "00ff00", title = "Load level"  }
+ }
+ }
+ }
+
+ local charge_percent = {
+ title = "%H: Battery charge on APCUPS ",
+ vlabel = "Percent",
+ y_min = "0",
+ y_max = "100",
+ number_format = "%5.1lf%%",
+ data = {
+ types = { "charge" },
+ options = {
+ charge = { color = "00ff0b", title = "Charge level"  }
+ }
+ }
+ }
+
+ local temperature = {
+ title = "%H: Battery temperature on APCUPS ",
+ vlabel = "\176C",
+ number_format = "%5.1lf\176C",
+ data = {
+ types = { "temperature" },
+ options = {
+ temperature = { color = "ffb000", title = "Battery temperature" } }
+ }
+ }
+
+ local timeleft = {
+ title = "%H: Time left on APCUPS ",
+ vlabel = "Minutes",
+ number_format = "%.1lfm",
+ data = {
+ sources = {
+ timeleft = { "timeleft" }
+ },
+ options = {
+ timeleft__timeleft = { color = "0000ff", title = "Time left",
transform_rpn = "60,/" }
+ }
+ }
+ }
+
+ local frequency = {

+ title = "%H: Incoming line frequency on APCUPS ",
+ vlabel = "Hz",
+ number_format = "%5.0lfhz",
+ data = {
+ sources = {
+ frequency_input = { "frequency" }
+ },
+ instances = {
+ frequency = "frequency"
+ },
+ options = {
+ frequency_frequency = { color = "000fff", title = "Line frequency" }
+ }
+ }
+ }
+
+ return { voltages, percentload, charge_percent, temperature, timeleft,
frequency }
+end
diff -ruN orig/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua~
new/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua~
--- orig/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua~
1969-12-31 19:00:00.000000000 -0500
+++ new/usr/lib/lua/luci/statistics/rrdtool/definitions/apcups.lua~
2015-04-06 10:09:08.340427073 -0400
@@ -0,0 +1,113 @@
+--[[
+
+Luci statistics - apcups plugin diagram definition
+Copyright © 2008 Freifunk Leipzig / Jo-Philipp Wich <
xm at leipzig.freifunk.net>
+Copyright © 2012 David Woodhouse <dwmw2 at infradead.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+
+module("luci.statistics.rrdtool.definitions.apcups",package.seeall)
+
+function rrdargs( graph, plugin, plugin_instance, dtype )
+
+ local voltages = {
+ title = "%H: Voltages on APCUPS ",
+ vlabel = "V",
+ number_format = "%5.1lfV",
+ data = {
+ instances = {
+ voltage = { "battery", "input", "output" }
+ },
+
+ options = {
+ voltage_output  = { color = "00e000", title = "Output voltage",
noarea=true, overlay=true },
+ voltage_battery = { color = "0000ff", title = "Battery voltage",
noarea=true, overlay=true },
+ voltage_input   = { color = "ffb000", title = "Input voltage",
noarea=true, overlay=true }
+ }
+ }
+ }
+
+ local percentload = {
+ title = "%H: Load on APCUPS ",
+ vlabel = "Percent",
+ y_min = "0",
+ y_max = "100",
+ number_format = "%5.1lf%%",
+ data = {
+ sources = {
+                                percent_load = { "percent" }

+                        },
+ instances = {
+ percent = "percent"
+ },
+ options = {
+ percent_percent = { color = "00ff00", title = "Load level"  }
+ }
+ }
+ }
+
+ local charge_percent = {
+ title = "%H: Battery charge on APCUPS ",
+ vlabel = "Percent",
+ y_min = "0",
+ y_max = "100",
+ number_format = "%5.1lf%%",
+ data = {
+ types = { "charge" },
+ options = {
+ charge = { color = "00ff0b", title = "Charge level"  }
+ }
+ }
+ }
+
+ local temperature = {
+ title = "%H: Battery temperature on APCUPS ",
+ vlabel = "\176C",
+ number_format = "%5.1lf\176C",
+ data = {
+ types = { "temperature" },
+ options = {
+ temperature = { color = "ffb000", title = "Battery temperature" } }
+ }
+ }
+
+ local timeleft = {
+ title = "%H: Time left on APCUPS ",
+ vlabel = "Minutes",
+ number_format = "%.1lfm",
+ data = {
+ sources = {
+ timeleft = { "timeleft" }
+ },
+ options = {
+ timeleft__timeleft = { color = "0000ff", title = "Time left",
transform_rpn = "60,/" }
+ }
+ }
+ }
+
+ local frequency = {

+ title = "%H: Incoming line frequency on APCUPS ",
+ vlabel = "Hz",
+ number_format = "%5.0lfhz",
+ data = {
+ sources = {
+ frequency_input = { "frequency" }
+ },
+ instances = {
+ frequency = "frequency"
+ },
+ options = {
+ frequency_frequency = { color = "000fff", title = "Line frequency" }
+ }
+ }
+ }
+
+ return { voltages, percentload, charge_percent, temperature, timeleft,
frequency }
+end


Signed-off-by: James T Klaas <jklaas at appalachian.dyndns.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsignal.org/pipermail/luci/attachments/20150406/74b75fa5/attachment.html>


More information about the luci mailing list