j...@entropicblur.com (Joe Gidi), 2014.11.27 (Thu) 16:41 (CET):
> I just spent some more time poking at this and I'm still unable to get

So did I...

> sensorsd to recognize upd state changes. This is a bit of a frustrating
> regression from my point of view, since I can no longer use apcupsd unless
> I disable uhidev in the kernel.
> 
> Does anyone have a working example configuration for sensorsd/upd?

What I have now:

$ getcap -a -f /etc/sensorsd.conf
hw.sensors.upd0.indicator0:low=1:high=2:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4
hw.sensors.upd0.indicator1:low=1:high=2:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4
hw.sensors.upd0.indicator2:low=1:high=2:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4
hw.sensors.upd0.indicator3:low=1:high=2:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4
hw.sensors.upd0.indicator4:low=1:high=2:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4
hw.sensors.upd0.percent0:low=10:high=100:command=\
/etc/sensorsd/upd-capacityremaining.sh %l %n %s %x %t %2 %3 %4
hw.sensors.upd0.percent1:low=95:high=100:command=/etc/sensorsd/upd.sh \
%l %n %s %x %t %2 %3 %4

The ``command=/etc/sensorsd/upd.sh'' lines are just informational.

The workhorse is "command=/etc/sensorsd/upd-capacityremaining.sh":
----
#!/bin/sh -e
if [[ X"${1}" == X"below" ]]; then
logger -t "UPD-capacityremaining" "SHUTDOWN (${@})"
shutdown -hp +1
else
logger -t "UPD-capacityremaining" "NON-SHUTDOWN (${@})"
fi
----

I did some testing (plug/unplug, wait for hw.sensors.upd0.percent0 to go
below low=) and left it as "working".

Bye, Marcus

> On Sun, November 23, 2014 11:51 am, Marcus MERIGHI wrote:
> > j...@entropicblur.com (Joe Gidi), 2014.11.23 (Sun) 17:19 (CET):
> >> Just after I sent this, I happened to notice these lines in
> >> /var/log/messages. These came from the tests with the "low=1:high=2"
> >> attributes set in sensorsd.conf per the Undeadly example.
> >>
> >> Nov 23 10:58:08 microserver sensorsd[6250]: upd0.indicator2: exceeds
> >> limits: On is below On
> >> Nov 23 10:59:54 microserver sensorsd[12047]: upd0.indicator2: exceeds
> >> limits: On is below On
> >> Nov 23 11:07:00 microserver sensorsd[27413]: upd0.indicator0: exceeds
> >> limits: On is below On
> >
> > As I had just copied the undeadly example as-is to my sensorsd.conf I
> > did receive the e-mail (i.e. command= worked). It was a false positive,
> > though, as no one had pulled the plug. Did you really pull the plug or
> > was yours a false positive, too?
> >
> > Bye, Marcus
> >
> >> On Sun, November 23, 2014 11:15 am, Joe Gidi wrote:
> >> > Hi Marcus,
> >> >
> >> > Thanks for the reply. Unfortunately, the "low=1:high=2" doesn't seem
> >> to
> >> > work for indicator2. When I start sensorsd I see an initial event
> >> logged
> >> > as the status goes from undefined to OK, but no further events as I
> >> > unplug/plug the UPS. I tried monitoring indicator0 as in the Undeadly
> >> > example, and I see exactly the same behavior.
> >> >
> >> > It appears to me that the driver should be changing the status (%s
> >> token)
> >> > of the indicators to something other than "OK" when the UPS loses
> >> mains
> >> > power, but it simply doesn't.
> >> >
> >> > BTW, I've tested with various check interval values for sensorsd, from
> >> the
> >> > default 20 seconds down to as low as 1 second, with no change in
> >> results.
> >> >
> >> > Is anyone successfully using sensorsd with upd?
> >> >
> >> > Thanks,
> >> >
> >> > Joe
> >> >
> >> > On Sun, November 23, 2014 4:13 am, Marcus MERIGHI wrote:
> >> >> j...@entropicblur.com (Joe Gidi), 2014.11.23 (Sun) 01:22 (CET):
> >> >>> I'm running OpenBSD 5.6/amd64 on my fileserver. It has an APC UPS
> >> that
> >> >>> was
> >> >>> previously managed with apcupsd. Since I upgraded to 5.6, the UPS
> >> now
> >> >>> attaches as a upd device:
> >> >>>
> >> >>> $ dmesg | grep uhidev3
> >> >>> uhidev3 at uhub3 port 5 configuration 1 interface 0 "APC Back-UPS ES
> >> >>> 450
> >> >>> FW:844.K2 .D USB FW:K2" rev 1.10/1.06 addr 2
> >> >>> uhidev3: iclass 3/0, 123 report ids
> >> >>> upd0 at uhidev3
> >> >>>
> >> >>> And it reports sensible values in hw.sensors:
> >> >>> $ sysctl hw.sensors.upd0
> >> >>> hw.sensors.upd0.indicator0=On (Charging), OK
> >> >>> hw.sensors.upd0.indicator1=Off (Discharging), OK
> >> >>> hw.sensors.upd0.indicator2=On (ACPresent), OK
> >> >>> hw.sensors.upd0.indicator3=On (BatteryPresent), OK
> >> >>> hw.sensors.upd0.indicator4=Off (ShutdownImminent), OK
> >> >>> hw.sensors.upd0.percent0=79.00% (RemainingCapacity), OK
> >> >>> hw.sensors.upd0.percent1=100.00% (FullChargeCapacity), OK
> >> >>>
> >> >>> So far, so good. Now, I'd like to configure sensorsd to monitor the
> >> >>> device
> >> >>> and invoke a script when the power goes out. I have this line in
> >> >>> sensorsd.conf:
> >> >>>
> >> >>> hw.sensors.upd0.indicator2:command=/etc/sensorsd/ups.sh %s %2
> >> >>>
> >> >>> The ups.sh script currently just echoes the token values that it's
> >> >>> passed
> >> >>> to a log file.
> >> >>>
> >> >>> The issue I'm running into is this: the status of the sensors seems
> >> to
> >> >>> always be "OK", even when their state changes. I can unplug the UPS
> >> >>> from
> >> >>> the wall and then I see this:
> >> >>>
> >> >>> hw.sensors.upd0.indicator0=Off (Charging), OK
> >> >>> hw.sensors.upd0.indicator1=On (Discharging), OK
> >> >>> hw.sensors.upd0.indicator2=Off (ACPresent), OK
> >> >>> hw.sensors.upd0.indicator3=On (BatteryPresent), OK
> >> >>> hw.sensors.upd0.indicator4=Off (ShutdownImminent), OK
> >> >>> hw.sensors.upd0.percent0=76.00% (RemainingCapacity), OK
> >> >>> hw.sensors.upd0.percent1=100.00% (FullChargeCapacity), OK
> >> >>>
> >> >>> We're not charging, we're discharging, AC power is not present, but
> >> >>> none
> >> >>> of the status indicators (the %s token) ever leaves the "OK" state.
> >> As
> >> >>> I
> >> >>> understand it, that lack of state change results in sensorsd doing
> >> >>> nothing, even though the sensor's value (the %2 token, On/Off)
> >> changes.
> >> >>>
> >> >>> Can anyone clue me in? I feel like I must be missing something silly
> >> >>> and
> >> >>> obvious here.
> >> >>
> >> >> see here: http://undeadly.org/cgi?action=article&sid=20140320093943
> >> >>
> >> >> ``hw.sensors.upd0.indicator0:low=1:high=2:command=echo "who turned %2
> >> \
> >> >>   the lights?" | mail -s "power sensors" root''
> >> >>
> >> >> the trick seems to be to specify "low=1:high=2". I suppose that works
> >> >> for indicator2, too.
> >> >>
> >> >> Bye, Marcus
> >> >>
> 
> 
> -- 
> Joe Gidi
> j...@entropicblur.com
> 
> "You cannot buy skill." -- Ross Seyfried
> 
> 
> !DSPAM:5477465184003109490450!

Reply via email to