[Nut-upsdev] [PATCH 33/36] Add basic temperature monitoring support to snmp-ups.
Arnaud Quette
aquette.dev at gmail.com
Tue May 15 15:00:21 UTC 2012
2012/3/9 Greg A. Woods <woods at planix.com>:
> From: "Greg A. Woods" <woods at planix.com>
>
> The "ups.temperature" and "ambient.temperature" values are monitored, if
> available, and if either 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/snmp-ups.txt | 28 ++++++++++++++++++++++++++++
> drivers/snmp-ups.c | 24 +++++++++++++++++++++++-
> drivers/snmp-ups.h | 3 ++-
> 3 files changed, 53 insertions(+), 2 deletions(-)
>
> diff --git a/docs/man/snmp-ups.txt b/docs/man/snmp-ups.txt
> index 5512fa0..c087aad 100644
> --- a/docs/man/snmp-ups.txt
> +++ b/docs/man/snmp-ups.txt
> @@ -70,6 +70,15 @@ Set SNMP version (default = v1, the other allowed value is v2c)
> *pollfreq*='value'::
> Set polling frequency in seconds, to reduce network flow (default=30)
>
> +*maxtemp*='value'::
> +Set the maximum temperature for the *ups.temperature* and
> +*ambient.temperature* variables, 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.
> +
> *notransferoids*::
> Disable the monitoring of the low and high voltage transfer OIDs in
> the hardware. This will remove input.transfer.low and input.transfer.high
> @@ -148,6 +157,25 @@ The hostname of the UPS is specified with the "port" value in
> privPassword = myprivatepassphrase
> desc = "Example SNMP v3 device, with the highest security level"
>
> +MONITORING FOR UNHEALTHY ENVIRONMENTS
> +-------------------------------------
> +
> +Many SNMP-capable UPS units can report on their internal temperature
> +(see the *ups.temperature* and *ambient.temperature* variables). The
> +driver will report a *DYING* state if this temperature exceeds some
> +pre-set value. The default maximum temperature is set to 150 degrees
> +Celsius, the point where many plastics begin to melt, but far past the
> +point where the batteries have probably already self-destructed. A
> +reasonable value to use may be somewhere between 45 and 50. Most
> +battery specifications warn that operating over 40 C for long will
> +seriously lower the battery's expected lifetime. Note that the battery
> +may not be at the same temperature as the sensor.
> +
> +You may wish to observe the normal operating temperature of your UPS as
> +reported by this driver, and perhaps measure it independently by hand as
> +well, before setting a maximum temperature which will protect your UPS
> +and nearby systems from certain physical damage.
> +
> AUTHORS
> -------
> Arnaud Quette, Dmitry Frolov
> diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c
> index ebf0cab..842fbdf 100644
> --- a/drivers/snmp-ups.c
> +++ b/drivers/snmp-ups.c
> @@ -274,6 +274,8 @@ void upsdrv_makevartable(void)
> "Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5)");
> addvar(VAR_VALUE, SU_VAR_PRIVPROT,
> "Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES)");
> + addvar(VAR_VALUE, SU_VAR_MAXTEMP,
> + "Set the maximum allowed operating temperature (in degrees C, default=150)");
> #if 0 /* XXX unused */
> addvar(VAR_VALUE, SU_VAR_SDTYPE,
> "Set the shutdown mode (3 or 2, default=3)");
> @@ -1331,6 +1333,23 @@ bool_t snmp_ups_walk(int mode)
> return status;
> }
>
> +static void check_temperature(const char *type, int curtemp)
> +{
> + char *val;
> + int maxtemp = 150; /* 150 is far too high for sure... */
> +
> + /* should */
> +
> + if ((val = getval("maxtemp"))) {
> + maxtemp = atoi(val);
> + }
> + if (curtemp > maxtemp) {
> + upslogx(LOG_EMERG, "current value of %s at %d C exceeds maximum temperature of %d C", type, curtemp, maxtemp);
> +
> + status_set("DYING"); /* dying! */
> + }
> +}
> +
> bool_t su_ups_get(snmp_info_t *su_info_p)
> {
> static char buf[SU_INFOSIZE];
> @@ -1353,7 +1372,8 @@ bool_t su_ups_get(snmp_info_t *su_info_p)
> }
>
> /* another special case */
> - if (!strcasecmp(su_info_p->info_type, "ambient.temperature")) {
> + if (!strcasecmp(su_info_p->info_type, "ups.temperature") ||
> + !strcasecmp(su_info_p->info_type, "ambient.temperature")) {
> float temp=0;
>
> status = nut_snmp_get_int(su_info_p->OID, &value);
> @@ -1382,6 +1402,8 @@ bool_t su_ups_get(snmp_info_t *su_info_p)
> snprintf(buf, sizeof(buf), "%.1f", temp);
> su_setinfo(su_info_p, buf);
>
> + check_temperature(su_info_p->info_type, temp);
> +
> return TRUE;
> }
>
> diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h
> index 2fd0400..b1d5e5b 100644
> --- a/drivers/snmp-ups.h
> +++ b/drivers/snmp-ups.h
> @@ -172,6 +172,8 @@ typedef struct {
> #define SU_VAR_MIBS "mibs"
> #define SU_VAR_POLLFREQ "pollfreq"
> #define SU_VAR_SDTYPE "sdtype" /* XXX unused */
> +#define SU_VAR_WARNTEMP "warntemp" /* XXX unused -- for alarms */
> +#define SU_VAR_MAXTEMP "maxtemp"
> /* SNMP v3 related parameters */
> #define SU_VAR_SECLEVEL "secLevel"
> #define SU_VAR_SECNAME "secName"
> @@ -181,7 +183,6 @@ typedef struct {
> #define SU_VAR_PRIVPROT "privProtocol"
> #define SU_VAR_MAGIC "magic"
>
> -
> #define SU_INFOSIZE 128
> #define SU_BUFSIZE 32
> #define SU_LARGEBUF 256
this one is very interesting, and part of the things I wanted to do for years.
I've however postponed it for now for 2 reasons:
- DYING is postponed for now,
- I would really prefer a generic implementation in upsmon / upssched,
and provide this to any driver, not just snmp-ups.
And this will (probably) require some discussions and investigations...
cheers,
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/
More information about the Nut-upsdev
mailing list