Bad behavior of sensorsd on laptop

2010-03-06 Thread Tomas Bodzar
Hi all,

I set sensorsd and sensorsd.conf this way :

# $OpenBSD: sensorsd.conf,v 1.8 2007/08/14 19:02:02 cnst Exp $

#
# Sample sensorsd.conf file. See sensorsd.conf(5) for details.
#

# +5 voltage (volts)
#hw.sensors.lm0.volt3:low=4.8V:high=5.2V

# +12 voltage (volts)
#hw.sensors.lm0.volt4:low=11.5V:high=12.5V

# Monitor laptop battery for remaining capacity
hw.sensors.acpibat0.watthour3:low=1.40Wh:command=/etc/sensorsd/switchoff

# Chipset temperature (degrees Celsius)
#hw.sensors.lm0.temp0:high=50C
hw.sensors.acpitz0.temp0:high=60C:command=/etc/sensorsd/switchoff
hw.sensors.acpitz1.temp0:high=60C:command=/etc/sensorsd/switchoff

# CPU temperature (degrees Celsius)
#hw.sensors.lm0.temp1:high=60C
hw.sensors.cpu0.temp0:high=65C:command=/etc/sensorsd/switchoff

# CPU fan (RPM)
#hw.sensors.lm0.fan1:low=3000
hw.sensors.acpithinkpad0.fan0:low=2500:command=/etc/sensorsd/switchoff

# ignore certain indicators on ipmi(4)
#hw.sensors.ipmi0.indicator1:istatus

# Warn if any temperature sensor is over 70 degC.
# This entry will match only those temperature sensors
# that don't have their own entry.
#temp:high=70C


# By default, sensorsd(8) reports status changes of all sensors that
# keep their state. Uncomment the following lines if you want to
# suppress reports about status changes of specific sensor types.

#temp:istatus
#fan:istatus
#volt:istatus
#acvolt:istatus
#resistance:istatus
#power:istatus
#current:istatus
#watthour:istatus
#amphour:istatus
#indicator:istatus
#raw:istatus
#percentage:istatus
#illuminance:istatus
#drive:istatus
#timedelta:istatus

Command is simple :

#!/bin/sh
shutdown -h now Shutdown caused by sensor

It's running from point of view that computer is turned off in case of
low battery or high battery on some of sensor which has command
assigned. Problem starts if your battery is empy and computer turned
off. So you plug AC and start laptop. If you are below limit for
hw.sensors.acpibat0.watthour3 then your laptop is turned off after
login again. It's quite understandable, but if you're above limit
behavior is still same. Is it problem this part from man page for
sensorsd.conf?

 If the limits are crossed or if the status provided by the driver
 changes, sensorsd(8)'s alert functionality is triggered and a command, if
 specified, is executed.

Battery status trough this sensor is changing because battery was
empty and now laptop is in AC and charging. Does it really mean that
it will turn off my computer after every change of battery status
untill my battery is fully recharged?

OpenBSD 4.7-beta (GENERIC.MP) #423: Tue Feb 23 12:24:22 MST 2010
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Core(TM)2 Duo CPU L7300 @ 1.40GHz (GenuineIntel
686-class) 1.40 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR
real mem  = 2657374208 (2534MB)
avail mem = 2574045184 (2454MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 07/02/07, BIOS32 rev. 0 @
0xfdc80, SMBIOS rev. 2.4 @ 0xe0010 (63 entries)
bios0: vendor LENOVO version 7NET25WW (1.06 ) date 07/02/2007
bios0: LENOVO 766927G
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF!
SSDT SSDT SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) DURT(S3) IGBE(S4) EXP0(S4)
EXP1(S4) EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3)
USB2(S3) USB3(S3) USB4(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 199MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU L7300 @ 1.40GHz (GenuineIntel
686-class) 1.40 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus -1 (EXP3)
acpiprt6 at acpi0: bus -1 (EXP4)
acpiprt7 at acpi0: bus 5 (PCI1)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpipwrres0 at acpi0: PUBS
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 99 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model 42T5247 serial   505 type LION oem SANYO
acpibat1 at acpi0: BAT1 not present
acpibat2 at acpi0: BAT2 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock0 at acpi0: GDCK not docked (0)
bios0: ROM list: 0xc/0x1! 0xd/0x1000 0xd1000/0x1000 0xe/0x1!
cpu0: Enhanced SpeedStep 1397 MHz: 

Re: Bad behavior of sensorsd on laptop

2010-03-06 Thread Joachim Schipper
On Sat, Mar 06, 2010 at 02:26:28PM +0100, Tomas Bodzar wrote:
 Hi all,
 
 I set sensorsd and sensorsd.conf this way :
 
 # $OpenBSD: sensorsd.conf,v 1.8 2007/08/14 19:02:02 cnst Exp $

 # Monitor laptop battery for remaining capacity
 hw.sensors.acpibat0.watthour3:low=1.40Wh:command=/etc/sensorsd/switchoff

 Command is simple :
 
 #!/bin/sh
 shutdown -h now Shutdown caused by sensor
 
 It's running from point of view that computer is turned off in case of
 low battery or high battery on some of sensor which has command
 assigned. Problem starts if your battery is empy and computer turned
 off. So you plug AC and start laptop. If you are below limit for
 hw.sensors.acpibat0.watthour3 then your laptop is turned off after
 login again. It's quite understandable, but if you're above limit
 behavior is still same. Is it problem this part from man page for
 sensorsd.conf?
 
  If the limits are crossed or if the status provided by the driver
  changes, sensorsd(8)'s alert functionality is triggered and a command, if
  specified, is executed.
 
 Battery status trough this sensor is changing because battery was
 empty and now laptop is in AC and charging. Does it really mean that
 it will turn off my computer after every change of battery status
 untill my battery is fully recharged?

Yes. Write a better script to fix this. Some ideas: if the CPU gets hot,
switch to low speed (apm -L) instead of turning the machine off; if the
battery is low, check if you're connected to wall power before turning
off; etc.

Joachim



Re: Bad behavior of sensorsd on laptop

2010-03-06 Thread Tomas Bodzar
Thx. I will prepare some more complicated creatures :-)

On Sat, Mar 6, 2010 at 5:09 PM, Joachim Schipper
joac...@joachimschipper.nl wrote:
 On Sat, Mar 06, 2010 at 02:26:28PM +0100, Tomas Bodzar wrote:
 Hi all,

 I set sensorsd and sensorsd.conf this way :

 # $OpenBSD: sensorsd.conf,v 1.8 2007/08/14 19:02:02 cnst Exp $

 # Monitor laptop battery for remaining capacity
 hw.sensors.acpibat0.watthour3:low=1.40Wh:command=/etc/sensorsd/switchoff

 Command is simple :

 #!/bin/sh
 shutdown -h now Shutdown caused by sensor

 It's running from point of view that computer is turned off in case of
 low battery or high battery on some of sensor which has command
 assigned. Problem starts if your battery is empy and computer turned
 off. So you plug AC and start laptop. If you are below limit for
 hw.sensors.acpibat0.watthour3 then your laptop is turned off after
 login again. It's quite understandable, but if you're above limit
 behavior is still same. Is it problem this part from man page for
 sensorsd.conf?

 B If the limits are crossed or if the status provided by the driver
 B  B  B changes, sensorsd(8)'s alert functionality is triggered and a
command, if
 B  B  B specified, is executed.

 Battery status trough this sensor is changing because battery was
 empty and now laptop is in AC and charging. Does it really mean that
 it will turn off my computer after every change of battery status
 untill my battery is fully recharged?

 Yes. Write a better script to fix this. Some ideas: if the CPU gets hot,
 switch to low speed (apm -L) instead of turning the machine off; if the
 battery is low, check if you're connected to wall power before turning
 off; etc.

 B  B  B  B  B  B  B  B Joachim



Re: Bad behavior of sensorsd on laptop

2010-03-06 Thread Constantine A. Murenin
On 6 March 2010 08:26, Tomas Bodzar tomas.bod...@gmail.com wrote:
 Hi all,

 I set sensorsd and sensorsd.conf this way :

 # $OpenBSD: sensorsd.conf,v 1.8 2007/08/14 19:02:02 cnst Exp $

 #
 # Sample sensorsd.conf file. See sensorsd.conf(5) for details.
 #

 # +5 voltage (volts)
 #hw.sensors.lm0.volt3:low=4.8V:high=5.2V

 # +12 voltage (volts)
 #hw.sensors.lm0.volt4:low=11.5V:high=12.5V

 # Monitor laptop battery for remaining capacity
 hw.sensors.acpibat0.watthour3:low=1.40Wh:command=/etc/sensorsd/switchoff

 # Chipset temperature (degrees Celsius)
 #hw.sensors.lm0.temp0:high=50C
 hw.sensors.acpitz0.temp0:high=60C:command=/etc/sensorsd/switchoff
 hw.sensors.acpitz1.temp0:high=60C:command=/etc/sensorsd/switchoff

 # CPU temperature (degrees Celsius)
 #hw.sensors.lm0.temp1:high=60C
 hw.sensors.cpu0.temp0:high=65C:command=/etc/sensorsd/switchoff

 # CPU fan (RPM)
 #hw.sensors.lm0.fan1:low=3000
 hw.sensors.acpithinkpad0.fan0:low=2500:command=/etc/sensorsd/switchoff

 # ignore certain indicators on ipmi(4)
 #hw.sensors.ipmi0.indicator1:istatus

 # Warn if any temperature sensor is over 70 degC.
 # This entry will match only those temperature sensors
 # that don't have their own entry.
 #temp:high=70C


 # By default, sensorsd(8) reports status changes of all sensors that
 # keep their state. Uncomment the following lines if you want to
 # suppress reports about status changes of specific sensor types.

 #temp:istatus
 #fan:istatus
 #volt:istatus
 #acvolt:istatus
 #resistance:istatus
 #power:istatus
 #current:istatus
 #watthour:istatus
 #amphour:istatus
 #indicator:istatus
 #raw:istatus
 #percentage:istatus
 #illuminance:istatus
 #drive:istatus
 #timedelta:istatus

 Command is simple :

 #!/bin/sh
 shutdown -h now Shutdown caused by sensor

 It's running from point of view that computer is turned off in case of
 low battery or high battery on some of sensor which has command
 assigned. Problem starts if your battery is empy and computer turned
 off. So you plug AC and start laptop. If you are below limit for
 hw.sensors.acpibat0.watthour3 then your laptop is turned off after
 login again. It's quite understandable, but if you're above limit
 behavior is still same. Is it problem this part from man page for
 sensorsd.conf?

  If the limits are crossed or if the status provided by the driver
 changes, sensorsd(8)'s alert functionality is triggered and a command,
if
 specified, is executed.

 Battery status trough this sensor is changing because battery was
 empty and now laptop is in AC and charging. Does it really mean that
 it will turn off my computer after every change of battery status
 untill my battery is fully recharged?


core:constant {6432} man sensorsd.conf | fgrep -C5 shutdown
CAVEATS
 Alert functionality is triggered every time there is a change in sensor
 state; for example, when sensorsd(8) is started, the status of each
moni-
 tored sensor changes from undefined to whatever it is.  One must keep
 this in mind when using commands that may unconditionally perform
adverse
 actions (e.g. shutdown(8)), as they will be executed even when all sen-
 sors perform to specification.  If this is undesirable, then a wrapper
 shell script should be used instead.

OpenBSD 4.6 March 15, 2008
2
core:constant {6433}


Try using the %l token in your scripts for conditional shutdown.

C.