[collectd] [PATCH] Change timeleft unit for nut plugin to minutes.

David Woodhouse dwmw2 at infradead.org
Tue Dec 11 15:32:29 CET 2012


The snmp and apcups plugins both report timeleft in minutes, but nut
does so in seconds. This makes them consistent.

I note that the maximum value for it is defined as 3600. That's 60
hours, which is 2½ days. Not a particularly round number...?

diff --git a/src/nut.c b/src/nut.c
index edc48c6..104ec93 100644
--- a/src/nut.c
+++ b/src/nut.c
@@ -206,7 +206,11 @@ static int nut_read_one (nut_ups_t *ups)
       else if (strcmp ("battery.current", key) == 0)
 	nut_submit (ups, "current", "battery", value);
       else if (strcmp ("battery.runtime", key) == 0)
+      {
+	/* NUT uses seconds but other plugins give it to us in minutes */
+	value /= 60.0;
 	nut_submit (ups, "timeleft", "battery", value);
+      }
       else if (strcmp ("battery.temperature", key) == 0)
 	nut_submit (ups, "temperature", "battery", value);
       else if (strcmp ("battery.voltage", key) == 0)

-- 
dwmw2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6171 bytes
Desc: not available
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20121211/169f1d05/attachment-0001.bin>


More information about the collectd mailing list