1 /* Licensed to the public under the Apache License 2.0. */
5 return L.Class.extend({
8 rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
12 * Types and instances supported by APC UPS
13 * e.g. ups_types -> [ 'timeleft', 'charge', 'percent', 'voltage' ]
14 * e.g. ups_inst['voltage'] -> [ 'input', 'battery' ]
17 var ups_types = graph.dataTypes(host, plugin, plugin_instance),
20 for (var i = 0; i < ups_types.length; i++)
21 ups_inst[ups_types[i]] = graph.dataInstances(host, plugin, plugin_instance, ups_types[i]);
23 /* Check if hash table or array is empty or nil-filled */
32 /* Append graph definition but only types/instances which are */
33 /* supported and available to the plugin and UPS. */
35 function add_supported(t, defs) {
36 var def_inst = defs['data']['instances'];
38 if (L.isObject(def_inst)) {
39 for (var k in def_inst) {
40 if (ups_types.filter(function(t) { return t == k }).length) {
41 for (var i = def_inst[k].length - 1; i >= 0; i--)
42 if (!ups_inst[k].filter(function(n) { return n == def_inst[k][i] }).length)
43 def_inst[k].splice(i, 1);
45 if (def_inst[k].length == 0)
46 def_inst[k] = null; /* can't assign v: immutable */
49 def_inst[k] = null; /* can't assign v: immutable */
61 /* Graph definitions for APC UPS measurements MUST use only 'instances': */
62 /* e.g. instances = { voltage = { "input", "output" } } */
65 title: "%H: Voltages on APC UPS - Battery",
68 number_format: "%5.1lfV",
71 voltage: [ "battery" ]
74 voltage: { title: "Battery voltage", noarea: true }
78 add_supported(rv, voltagesdc);
81 title: "%H: Voltages on APC UPS - AC",
84 number_format: "%5.1lfV",
87 voltage: [ "input", "output" ]
90 voltage_output : { color: "00e000", title: "Output voltage", noarea: true, overlay: true },
91 voltage_input : { color: "ffb000", title: "Input voltage", noarea: true, overlay: true }
95 add_supported(rv, voltagesac);
98 title: "%H: Load on APC UPS ",
102 number_format: "%5.1lf%%",
108 percent_load: { color: "00ff00", title: "Load level" }
112 add_supported(rv, percentload);
114 var charge_percent = {
115 title: "%H: Battery charge on APC UPS ",
119 number_format: "%5.1lf%%",
125 charge: { color: "00ff0b", title: "Charge level" }
129 add_supported(rv, charge_percent);
132 title: "%H: Battery temperature on APC UPS ",
134 number_format: "%5.1lf\u00b0C",
140 temperature: { color: "ffb000", title: "Battery temperature" } }
143 add_supported(rv, temperature);
146 title: "%H: Time left on APC UPS ",
148 number_format: "%.1lfm",
154 timeleft: { color: "0000ff", title: "Time left" }
158 add_supported(rv, timeleft);
161 title: "%H: Incoming line frequency on APC UPS ",
163 number_format: "%5.0lfhz",
166 frequency: [ "input" ]
169 frequency_input: { color: "000fff", title: "Line frequency" }
173 add_supported(rv, frequency);