Hello, I'm experiencing some problem with sys-power/apcupsd-3.14.8-r1 (but I've also tried the version ~3.14.10-r1. First of all, let me ensure you know that the UPS is correctly working on Windows and can be queried using his software Power Chute, so there is no problem with the cable or the USB port or some other hardware issue. Every time I try to start the apcupsd daemon I get: Starting APC UPS daemon ... [ OK ] But if I want to check the status I get: * status: crashed OK, if I stop the daemon and if I want to make a test using apctest, I get: 2011-11-16 00:04:15 apctest 3.14.8 (16 January 2010) gentoo Checking configuration ... Attached to driver: usb sharenet.type = DISABLE cable.type = USB_CABLE You are using a USB cable type, so I'm entering USB test mode mode.type = USB_UPS Setting up the port ... apctest FATAL ERROR in device.c at line 71 Unable to create UPS lock file. If apcupsd or apctest is already running, please stop it and run this program again. apctest error termination completed Well, since I don't know if it is a gentoo related issue or an apcupsd source code issue, I decided to compile and install from sources by myself. Note that the UPS is recognized by the Linux kernel since I get this on dmesg: hiddev0,hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS BR 800 FW:9.o5 .I USB FW:o5 ] on usb-0000:00:1d.0-1/input0 I performed the following steps: 1) source code extraction from the tarball 2) ./configure --enable-test --with-upstype=usb --with-upscable=usb --enable-usb --with-distname=gentoo --sbindir=/sbin --sysconfdir=/etc/apcupsd --with-pwrfail-dir=/etc/apcupsd --with-lock-dir=/var/lock --with-pid-dir=/var/run --with-log-dir=/var/log --with-nis-port=3551 --enable-net --enable-pcnet 3) make 4) make install 5) I still get status as crashed after starting up the apcupsd daemon. 6) I modified the src/device.c at lines 67->72 commenting out these lines: /*if ((ups->fd != -1) && create_lockfile(ups) == LCKERROR) { device_close(ups); Error_abort0(_("Unable to create UPS lock file.\n" " If apcupsd or apctest is already running,\n" " please stop it and run this program again.\n")); }*/ So the lock file check is going to be skipped. 7) recompile and install 8) apcupsd status is still showing crashed but if I perform the apctest command, it works this time!!! I can use the test application as usual and the UPS replies as expected. So my question now is: where could be the problem? On the application or on my system? It's more likely on my system because I have another system with the same version of apcupsd and it works. For sure I didn't change anything as regard the lock files or the apcupsd configuration. In any case it's not a permission issue. Reproducible: Always
Please post your `emerge --info sys-power/apcupsd' output too.
Created attachment 292779 [details] emerge --info sys-power/apcupsd Here's the `emerge --info sys-power/apcupsd`. Thanks a lot, Flavio
Created attachment 294155 [details] emerge --info sys-power/apcupsd (working PC) I tried apcupsd on another Gentoo Linux and it works. This is the configuration: - sys-power/apcupsd-3.14.10-r1 USE="nls usb cgi" - Linux Gentoo 3.1.0-gentoo x86_64 apctest works perfectly. I tried to upgrade to version 3.14.10-r1 on the PC where apcupsd doesn't work, but I can't still understand what is the problem. This is what happens if I try to start it: * Starting APC UPS Daemon ... * start-stop-daemon: did not create a valid pid in `/var/run/apcupsd.pid' * Failed to start apcupsd [ !! ] * ERROR: apcupsd failed to start
Hello! Good news. I played a little bit with the /var/lock directory and I noticed that a strange file(?) was present in it: "LCK..". So I straced the apctest command and this made me suspicious about that file which was mentioned in the strace. So I tried to issue the following command: mv /var/lock/LCK.. /home/myhome and I noticed something strange: the whole /var/lock directory was moved. Maybe I don't understand what is "LCK.." but after replacing the /var/lock dir at its own place I performed the following steps: mv /var/lock /home/myhome mkdir /var/lock mv /home/myhome/lvm /var/lock/ mv /home/myhome/subsys /var/lock/ mv /home/myhome/xl /var/lock/ and then I started apctest successfully, as well as for the apcupsd init script. I really can't explain what happened to myself, so I ask you to clarify this, that has been revealed to not be an apcupsd bug but a system bug (maybe). I hope that this problem won't be present again at next reboot. I'll check. Thanks. Flavio
By the way: BEFORE deleting the old /var/lock/LCK.. file: # cat /var/lock/LCK.. 3 (active) AFTER starting the apcupsd daemon, the LCK.. file has been created again and this is the content: # cat LCK.. 0000008037 AND: # ps aux|grep 8037 root 8037 0.0 0.0 33172 796 ? Ssl 00:01 0:00 /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf -P /var/run/apcupsd.pid It seems like the LCK.. file before was something wrong or dirty and persistent. And this was the reason why the apcupsd daemon couldn't create a new lock file.
This might actually solve itself for good once we actually have /var/lock in tmpfs...
I don't know. I don't use to put /var/lock in tmpfs but maybe I've found the root cause that generated this problem. One time I accidentally powered down the UPS when the PC was still switched on. Maybe the LCK.. file remained there, and the daemon was no longer able to create the LCK.. file since it was already present.