1 /* Licensed to the public under the Apache License 2.0. */
6 return baseclass.extend({
9 rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
13 * Types and instances supported by APC UPS
14 * e.g. ups_types -> [ 'timeleft', 'charge', 'percent', 'voltage' ]
15 * e.g. ups_inst['voltage'] -> [ 'input', 'battery' ]
18 var ups_types = graph.dataTypes(host, plugin, plugin_instance),
21 for (var i = 0; i < ups_types.length; i++)
22 ups_inst[ups_types[i]] = graph.dataInstances(host, plugin, plugin_instance, ups_types[i]);
24 /* Check if hash table or array is empty or nil-filled */
33 /* Append graph definition but only types/instances which are */
34 /* supported and available to the plugin and UPS. */
36 function add_supported(t, defs) {
37 var def_inst = defs['data']['instances'];
39 if (L.isObject(def_inst)) {
40 for (var k in def_inst) {
41 if (ups_types.filter(function(t) { return t == k }).length) {
42 for (var i = def_inst[k].length - 1; i >= 0; i--)
43 if (!ups_inst[k].filter(function(n) { return n == def_inst[k][i] }).length)
44 def_inst[k].splice(i, 1);
46 if (def_inst[k].length == 0)
47 def_inst[k] = null; /* can't assign v: immutable */
50 def_inst[k] = null; /* can't assign v: immutable */
62 /* Graph definitions for APC UPS measurements MUST use only 'instances': */
63 /* e.g. instances = { voltage = { "input", "output" } } */
66 title: "%H: Voltages on APC UPS - Battery",
69 number_format: "%5.1lfV",
72 voltage: [ "battery" ]
75 voltage: { title: "Battery voltage", noarea: true }
79 add_supported(rv, voltagesdc);
82 title: "%H: Voltages on APC UPS - AC",
85 number_format: "%5.1lfV",
88 voltage: [ "input", "output" ]
91 voltage_output : { color: "00e000", title: "Output voltage", noarea: true, overlay: true },
92 voltage_input : { color: "ffb000", title: "Input voltage", noarea: true, overlay: true }
96 add_supported(rv, voltagesac);
99 title: "%H: Load on APC UPS ",
103 number_format: "%5.1lf%%",
109 percent_load: { color: "00ff00", title: "Load level" }
113 add_supported(rv, percentload);
115 var charge_percent = {
116 title: "%H: Battery charge on APC UPS ",
120 number_format: "%5.1lf%%",
126 charge: { color: "00ff0b", title: "Charge level" }
130 add_supported(rv, charge_percent);
133 title: "%H: Battery temperature on APC UPS ",
135 number_format: "%5.1lf\u00b0C",
141 temperature: { color: "ffb000", title: "Battery temperature" } }
144 add_supported(rv, temperature);
147 title: "%H: Time left on APC UPS ",
149 number_format: "%.1lfm",
155 timeleft: { color: "0000ff", title: "Time left" }
159 add_supported(rv, timeleft);
162 title: "%H: Incoming line frequency on APC UPS ",
164 number_format: "%5.0lfhz",
167 frequency: [ "input" ]
170 frequency_input: { color: "000fff", title: "Line frequency" }
174 add_supported(rv, frequency);