[Nut-upsdev] [PATCH 34/36] Add basic temperature monitoring support to apcsmart.
Greg A. Woods
woods at planix.com
Thu Mar 8 23:21:45 UTC 2012
From: "Greg A. Woods" <woods at planix.com>
The "ups.temperature" value is monitored, if available, and if it
exceeds the configured "warntemp" variable's value, or 40 by default,
the UPS sets an alarm state to warn of the problem.
If it exceeds the configured "maxtemp" variable's value, or 150 by
default, the UPS reports that it is DYING so that NUT can shut
everything down and then turn it off with the upsdrv_shutdown(epo=1)
call.
---
docs/man/blazer.txt | 13 +++++++++++++
drivers/blazer.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/docs/man/blazer.txt b/docs/man/blazer.txt
index 50c7928..5c5cb31 100644
--- a/docs/man/blazer.txt
+++ b/docs/man/blazer.txt
@@ -69,6 +69,19 @@ Time to wait before shutting down the UPS (seconds). This value is truncated
to units of 6 seconds (less than 60 seconds) or 60 seconds (more than 60
seconds). Defaults to 30 seconds.
+*warntemp*='value'::
+Set the warning temperature for the *ups.temperature* variable, above
+which point the UPS will report an alarm (default=40 (in degrees
+Celsius)). This option takes a numeric value in the range of 1 to 150.
+
+*maxtemp*='value'::
+Set the maximum temperature for the *ups.temperature* variable, above
+which point the UPS will report the emergency *DYING* state (default=150
+(in degrees Celsius)). This option takes a numeric value in the range
+of 1 to 150. Typically this will cause connected systems to be safely
+shut down and the monitored UPS to be powered down completely (if
+possible) so that human intervention will be required to restart things.
+
*norating*::
Some UPSes will lock up if you attempt to read rating information from them.
diff --git a/drivers/blazer.c b/drivers/blazer.c
index 3cd397e..7b76b26 100644
--- a/drivers/blazer.c
+++ b/drivers/blazer.c
@@ -163,6 +163,35 @@ static double blazer_packs(const char *ptr, char **endptr)
}
+static void check_temperature(void)
+{
+ char *val;
+ int warntemp = 40;
+ int maxtemp = 150;
+
+ if ((val = getval("maxtemp"))) {
+ maxtemp = atoi(val);
+ }
+ if ((val = getval("warntemp"))) {
+ warntemp = atoi(val);
+ }
+ if ((val = dstate_getinfo("ups.temperature"))) {
+ int curtemp = atoi(val);
+
+ if (curtemp > warntemp) {
+ upslogx(LOG_EMERG, "current temperature of %d C exceeds warning temperature of %d C", curtemp, warntemp);
+
+ alarm_set("UPS is getting too hot!");
+ }
+
+ if (curtemp > maxtemp) {
+ upslogx(LOG_EMERG, "current temperature of %d C exceeds maximum temperature of %d C", curtemp, maxtemp);
+
+ status_set("DYING");
+ }
+ }
+}
+
static int blazer_status(const char *cmd)
{
const struct {
@@ -285,6 +314,8 @@ static int blazer_status(const char *cmd)
status_set("FSD");
}
+ check_temperature();
+
alarm_commit();
status_commit();
@@ -487,6 +518,9 @@ void blazer_makevartable(void)
addvar(VAR_VALUE, "chargetime", "Nominal charge time for UPS battery");
addvar(VAR_VALUE, "idleload", "Minimum load to be used for runtime calculation");
+ addvar(VAR_VALUE, "warntemp", "Warning temperature (degrees C)");
+ addvar(VAR_VALUE, "maxtemp", "Maximum safe operating temperature (degrees C)");
+
addvar(VAR_FLAG, "norating", "Skip reading rating information from UPS");
addvar(VAR_FLAG, "novendor", "Skip reading vendor information from UPS");
--
1.7.9.2
More information about the Nut-upsdev
mailing list