Merge pull request #278 from nmav/ocserv
[project/luci.git] / applications / luci-statistics / luasrc / statistics / rrdtool / definitions / nut.lua
1 --[[
2
3 Luci statistics - ups plugin diagram definition
4 Copyright © 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
5 Copyright © 2012 David Woodhouse <dwmw2@infradead.org>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 ]]--
14
15
16 module("luci.statistics.rrdtool.definitions.nut",package.seeall)
17
18 function rrdargs( graph, plugin, plugin_instance, dtype )
19
20         local voltages = {
21                 title = "%H: Voltages on UPS \"%pi\"",
22                 vlabel = "V",
23                 number_format = "%5.1lfV",
24                 data = {
25                         instances = {
26                                 voltage = { "battery", "input", "output" }
27                         },
28
29                         options = {
30                                 voltage_output  = { color = "00e000", title = "Output voltage", noarea=true, overlay=true },
31                                 voltage_battery = { color = "0000ff", title = "Battery voltage", noarea=true, overlay=true },
32                                 voltage_input   = { color = "ffb000", title = "Input voltage", noarea=true, overlay=true }
33                         }
34                 }
35         }
36
37         local currents = {
38                 title = "%H: Current on UPS \"%pi\"",
39                 vlabel = "A",
40                 number_format = "%5.3lfA",
41                 data = {
42                         instances = {
43                                 current = { "battery", "output" }
44                         },
45
46                         options = {
47                                 current_output  = { color = "00e000", title = "Output current", noarea=true, overlay=true },
48                                 current_battery = { color = "0000ff", title = "Battery current", noarea=true, overlay=true },
49                         }
50                 }
51         }
52
53         local percentage = {
54                 title = "%H: Battery charge on UPS \"%pi\"",
55                 vlabel = "Percent",
56                 y_min = "0",
57                 y_max = "100",
58                 number_format = "%5.1lf%%",
59                 data = {
60                         sources = {
61                                 percent = { "percent" }
62                         },
63                         instances = {
64                                 percent = "charge"
65                         },
66                         options = {
67                                 percent_charge = { color = "00ff00", title = "Charge level"  }
68                         }
69                 }
70         }
71
72         -- Note: This is in ISO8859-1 for rrdtool. Welcome to the 20th century.
73         local temperature = {
74                 title = "%H: Battery temperature on UPS \"%pi\"",
75                 vlabel = "\176C",
76                 number_format = "%5.1lf\176C",
77                 data = {
78                         instances = {
79                                 temperature = "battery"
80                         },
81
82                         options = {
83                                 temperature_battery = { color = "ffb000", title = "Battery temperature" }
84                         }
85                 }
86         }
87
88         local timeleft = {
89                 title = "%H: Time left on UPS \"%pi\"",
90                 vlabel = "Minutes",
91                 number_format = "%.1lfm",
92                 data = {
93                         sources = {
94                                 timeleft = { "timeleft" }
95                         },
96                         instances = {
97                                 timeleft = { "battery" }
98                         },
99                         options = {
100                                 timeleft_battery = { color = "0000ff", title = "Time left", transform_rpn = "60,/" }
101                         }
102                 }
103         }
104
105         return { voltages, currents, percentage, temperature, timeleft }
106 end