[opensuse] Attempting (and failing) to use my UPS
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm attempting to make use of my new UPS, connecting it via USB to the 'nut' service (nut-classic package), but I'm failing. It is a Belkin, model BU306000me. According to http://www.networkupstools.org/compat/stable.html I should use the driver megatec_usb, because the vendor id 0665. See the kernel log: kernel: usb 3-1: new low speed USB device using uhci_hcd and address 14 kernel: usb 3-1: configuration #1 chosen from 1 choice kernel: hiddev96hidraw0: USB HID v1.00 Device [Cypress Semiconductor USB to Serial] on usb-0000:02:02.1-1 kernel: usb 3-1: New USB device found, idVendor=0665, idProduct=5161 kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 kernel: usb 3-1: Product: USB to Serial kernel: usb 3-1: Manufacturer: Cypress Semiconductor So in '/etc/ups/ups.conf' I configured it thus: [myups] driver = megatec_usb port = /dev/hiddev0 desc = "Local UPS" When I run "rcupsd start" it fails; it simply says "failed", there is nothing in the logs. But searching this list archive, I found one Date: Jun 2008 Subject: Re: [opensuse] new ups device, what location in which it says, amongst other things, that the user 'upsd' should be added to the group 'uucp' - I understand because the the daemon runs as user and needs access to '/dev/hiddev0': crw-rw-r-- 1 root daemon 180, 96 Nov 18 01:55 /dev/hiddev0 but perhaps it now has to be added to the group "daemon", so that I have added user 'upsd' to both groups. Now I'm getting output in the logs, so I must have done something right. The script "rcupsd start" takes 45" to finish, and fails: nimrodel:~ # time rcupsd start Starting NUT UPS drivers failed real 0m45.113s user 0m0.028s sys 0m0.044s One of the problems is that the device _disappears_ as soon as the above script starts: nimrodel:/etc/ups # l /dev/hiddev0 ls: cannot access /dev/hiddev0: No such file or directory and a minute before it was there. There is an entry in the log: Nov 18 01:57:35 nimrodel megatec_usb[23363]: Startup successful but I think it is false, though I'm unsure how to test it. I suppose it should be this: nimrodel:/etc/ups # upscmd -l myups Error: Connection failure: Connection refused but it fails. Something is running, though: 23276 ? Ss 0:00 /usr/lib/ups/driver/megatec_usb -a myups The daemon stop is also problematic, takes 4 seconds but succeeds: nimrodel:~ # time rcupsd stop Shutting down NUT UPS monitor done Shutting down NUT UPS server done Shutting down NUT UPS drivers.... done real 0m4.295s user 0m0.104s sys 0m0.128s nimrodel:~ # and the log shows it: Nov 18 01:58:58 nimrodel megatec_usb[23363]: Signal 15: exiting I have also tried using mknod to create the device, to no avail. Of course, it does not disappear, but it does not work. nimrodel:/etc/ups # mknod /dev/hiddev0 c 180 96 nimrodel:/etc/ups # chmod 0664 /dev/hiddev0 nimrodel:/etc/ups # chown :uucp /dev/hiddev0 What can I do to make it work - if it should work at all? - -- Cheers Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkiHckACgkQtTMYHG2NR9WqLQCdEb9QcYvgf32JJijwxQUiCufP d/EAnRuFEsSVygLVoQxtjXLWAzMOMrJT =/HfX -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Carlos E. R. wrote:
Hi,
I'm attempting to make use of my new UPS, connecting it via USB to the 'nut' service (nut-classic package), but I'm failing.
It is a Belkin, model BU306000me. According to http://www.networkupstools.org/compat/stable.html I should use the driver megatec_usb, because the vendor id 0665.
See the kernel log:
kernel: usb 3-1: new low speed USB device using uhci_hcd and address 14 kernel: usb 3-1: configuration #1 chosen from 1 choice kernel: hiddev96hidraw0: USB HID v1.00 Device [Cypress Semiconductor USB to Serial] on usb-0000:02:02.1-1 kernel: usb 3-1: New USB device found, idVendor=0665, idProduct=5161 kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 kernel: usb 3-1: Product: USB to Serial kernel: usb 3-1: Manufacturer: Cypress Semiconductor
So in '/etc/ups/ups.conf' I configured it thus:
[myups] driver = megatec_usb port = /dev/hiddev0 desc = "Local UPS"
When I run "rcupsd start" it fails; it simply says "failed", there is nothing in the logs. But searching this list archive, I found one
Date: Jun 2008 Subject: Re: [opensuse] new ups device, what location
in which it says, amongst other things, that the user 'upsd' should be added to the group 'uucp' - I understand because the the daemon runs as user and needs access to '/dev/hiddev0':
crw-rw-r-- 1 root daemon 180, 96 Nov 18 01:55 /dev/hiddev0
but perhaps it now has to be added to the group "daemon", so that I have added user 'upsd' to both groups. Now I'm getting output in the logs, so I must have done something right.
The script "rcupsd start" takes 45" to finish, and fails:
nimrodel:~ # time rcupsd start Starting NUT UPS drivers failed
real 0m45.113s user 0m0.028s sys 0m0.044s
One of the problems is that the device _disappears_ as soon as the above script starts:
nimrodel:/etc/ups # l /dev/hiddev0 ls: cannot access /dev/hiddev0: No such file or directory
and a minute before it was there. There is an entry in the log:
Nov 18 01:57:35 nimrodel megatec_usb[23363]: Startup successful
but I think it is false, though I'm unsure how to test it. I suppose it should be this:
nimrodel:/etc/ups # upscmd -l myups Error: Connection failure: Connection refused
but it fails. Something is running, though:
23276 ? Ss 0:00 /usr/lib/ups/driver/megatec_usb -a myups
The daemon stop is also problematic, takes 4 seconds but succeeds:
nimrodel:~ # time rcupsd stop Shutting down NUT UPS monitor done Shutting down NUT UPS server done Shutting down NUT UPS drivers.... done
real 0m4.295s user 0m0.104s sys 0m0.128s nimrodel:~ #
and the log shows it:
Nov 18 01:58:58 nimrodel megatec_usb[23363]: Signal 15: exiting
I have also tried using mknod to create the device, to no avail. Of course, it does not disappear, but it does not work.
nimrodel:/etc/ups # mknod /dev/hiddev0 c 180 96 nimrodel:/etc/ups # chmod 0664 /dev/hiddev0 nimrodel:/etc/ups # chown :uucp /dev/hiddev0
What can I do to make it work - if it should work at all?
Carlos, You are getting close. There should be a whole string of e-mails on the list from about 6-8 months ago between Patrick Shanahan and myself concerning nut setup for the usb model cyber power UPS. I have forgotten the details, but the permission on the /dev/hiddev0 were important, and for some reason, if not set up right the node would get deleted, etc.. and you would have to create it again.. The permissions need to be setGID uucp. We finally got it solved. If you can search the archives for usb ups cyber power hiddev0 shanahan, I bet you'll find an answer. It works: http://www.3111skyline.com/nutindex.html For my setup hiddev0 isn't there, I have: [03:09 nirvana/home/david/tmp/ups] # lsusb Bus 002 Device 002: ID 0764:0501 Cyber Power System, Inc. ^^^^^^^ ^^^^^^^^^^^ Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000 [03:09 nirvana/home/david/tmp/ups] # l /dev/bus/usb/002/ ^^^^^^^^ total 0 drwxr-xr-x 2 root root 80 2008-11-06 04:34 ./ drwxr-xr-x 4 root root 80 2008-11-06 04:34 ../ crw-r--r-- 1 root root 189, 128 2008-11-06 04:34 001 crw-rw-r-- 1 root uucp 189, 129 2008-11-18 03:11 002 ^^^^ ^^^ ^^^ ^^^ IIRC, you need to create the node for the "Bus" and "Device" After creating the node about 5 times until I figured it out, I ended up with this config: hosts.conf: MONITOR nirvana_ups@localhost "Local UPS" ups.conf: [nirvana_ups] driver = usbhid-ups explore vendor="CPS" desc = "Nirvana UPS - Cyberpower 1000" port = /dev/hiddev0 upsd.conf: ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACL nirvana 127.0.0.2/32 ACCEPT localhost REJECT all upsd.users: [upsmaster] password = putPasswordHere allowfrom = localhost upsmon master [upsslave] password = putPasswordHere allowfrom = localhost upsmon slave [david] password = putPasswordHere allowfrom = localhost nirvana skyline rbpllc actions = SET instcmds = ALL upsmon.conf: MONITOR nirvana_ups@localhost 1 upsmaster putPasswordHere master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h +0" NOTIFYCMD /usr/lib/powersave/powersave-notify POLLFREQ 5 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 15 POWERDOWNFLAG /etc/killpower NOTIFYFLAG ONLINE SYSLOG NOTIFYFLAG COMMOK SYSLOG NOTIFYFLAG SHUTDOWN SYSLOG NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC NOTIFYFLAG FSD SYSLOG+WALL+EXEC NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC RBWARNTIME 43200 NOCOMMWARNTIME 300 FINALDELAY 5 upssched.conf: CMDSCRIPT /usr/local/ups/bin/upssched-cmd upsset.conf: I_HAVE_SECURED_MY_CGI_DIRECTORY Good Luck -- David C. Rankin, J.D.,P.E. | Rankin Law Firm, PLLC | Countdown for openSuSE 11.1 510 Ochiltree Street | http://counter.opensuse.org/11.1/small Nacogdoches, Texas 75961 | Telephone: (936) 715-9333 | openSoftware und SystemEntwicklung Facsimile: (936) 715-9339 | http://www.opensuse.org/ www.rankinlawfirm.com | -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2008-11-18 at 03:16 -0600, David C. Rankin wrote:
Carlos,
You are getting close. There should be a whole string of e-mails on the list from about 6-8 months ago between Patrick Shanahan and myself concerning nut setup for the usb model cyber power UPS.
I know, I have read them. In fact, I mentioned them above :-)
I have forgotten the details, but the permission on the /dev/hiddev0 were important, and for some reason, if not set up right the node would get deleted, etc..
Ah, didn't notice that part. Anyway, I have tried also creating the node via mknode myself, to no avail - apparently at least.
and you would have to create it again.. The permissions need to be setGID uucp. We finally got it solved. If you can search the archives for usb ups cyber power hiddev0 shanahan, I bet you'll find an answer. It works:
I'll have another look.
For my setup hiddev0 isn't there, I have:
[03:09 nirvana/home/david/tmp/ups] # lsusb Bus 002 Device 002: ID 0764:0501 Cyber Power System, Inc. ^^^^^^^ ^^^^^^^^^^^ Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000
That's another problem: it is not listed: nimrodel:/etc/ups # lsusb Bus 003 Device 019: ID 0665:5161 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub nimrodel:/etc/ups # l /dev/hiddev0 ls: cannot access /dev/hiddev0: No such file or directory But the kernel saw it this morning, after thawing the machine: kernel: hiddev96hidraw0: USB HID v1.00 Device [Cypress Semiconductor USB to Serial] on usb-0000:02:02.1-1 kernel: usb 3-1: New USB device found, idVendor=0665, idProduct=5161 Interestingly, the daemon is talking to the UPS, because as soon as I disconnect the cable, it starts complaining: Nov 18 12:34:30 nimrodel megatec_usb[26349]: ser_send_pace: Device detached? (error -19: error sending control message: No such device) Nov 18 12:34:30 nimrodel megatec_usb[26349]: Reconnecting to UPS failed; will retry later... Nov 18 12:34:30 nimrodel megatec_usb[26349]: Reconnecting to UPS failed; will retry later... Nov 18 12:34:32 nimrodel megatec_usb[26349]: Successfully reconnected I have read a document, about using my UPS on gentoo, that says that the megatec driver in fact ignores the /dev/hiddev0 device. It is in Spanish, though: http://www.lacofi.org/014.html#nut One of the things it says is to use the devel version, not the stable. So, according to the messages above, it is working somehow. But if I disconnect the power I see no messages.
[03:09 nirvana/home/david/tmp/ups] # l /dev/bus/usb/002/ ^^^^^^^^ total 0 drwxr-xr-x 2 root root 80 2008-11-06 04:34 ./ drwxr-xr-x 4 root root 80 2008-11-06 04:34 ../ crw-r--r-- 1 root root 189, 128 2008-11-06 04:34 001 crw-rw-r-- 1 root uucp 189, 129 2008-11-18 03:11 002 ^^^^ ^^^ ^^^ ^^^ IIRC, you need to create the node for the "Bus" and "Device"
Yep, but mine dissapears. Ah, I see... it is there, but has no name; it is the first entry: nimrodel:/etc/ups # lsusb Bus 003 Device 020: ID 0665:5161 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub nimrodel:/etc/ups # l /dev/bus/usb/003/ total 0 drwxr-xr-x 2 root root 80 Nov 18 12:34 ./ drwxr-xr-x 5 root root 100 Nov 16 02:38 ../ crw-r--r-- 1 root root 189, 256 Nov 16 02:38 001 crw-rw-r-- 1 root daemon 189, 275 Nov 18 12:39 020 Mine belongs to "daemon", not uucp. Now it does not exist: nimrodel:/etc/ups # l /dev/hiddev0 ls: cannot access /dev/hiddev0: No such file or directory when it does, it belongs to daemon:
crw-rw-r-- 1 root daemon 180, 96 Nov 18 01:55 /dev/hiddev0
and I added 'upsd' to that group. To both groups, actually.
After creating the node about 5 times until I figured it out, I ended up with this config:
hosts.conf:
I'll have a carefull look at all those, thanks.
Good Luck
Thanks. I'll have a good look this afternoon, I hope. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkivakACgkQtTMYHG2NR9XdUwCfafYcgCX5etVZ9V/zfSq8cAE9 I50Anjz/+fcXnTwyWrAcexAu0pUiLNVb =YQt1 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
So in '/etc/ups/ups.conf' I configured it thus:
[myups] driver = megatec_usb port = /dev/hiddev0 desc = "Local UPS"
Wouldn't work with mine, either. I changed "port =" to port = auto and now commands work and the web display shows properly, but I still get errors listed in /var/log/messages: wahoo kernel: usb 2-2: usbfs: USBDEVFS_CONTROL failed cmd newhidups rqt 161 rq 1 len 8 ret -110 has to be something wrong with permissions ?? -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2008-11-18 at 10:44 -0500, Patrick Shanahan wrote:
So in '/etc/ups/ups.conf' I configured it thus:
[myups] driver = megatec_usb port = /dev/hiddev0 desc = "Local UPS"
Wouldn't work with mine, either. I changed "port =" to port = auto
It appears that with my UPS this entry is ignored entirely, does not matter.
has to be something wrong with permissions ??
Yes, indeed it has problems with permissions. First, I changed the script /etc/init.d/upsd to see what is hapening: #$UPSDRVCTL_BIN start >/dev/null 2>&1 || rc_failed $UPSDRVCTL_BIN start >/tmp/ups.log 2>&1 || rc_failed and it says: Megatec protocol UPS detected. Startup timer elapsed, continuing... Network UPS Tools - UPS driver controller 2.2.2 it certainly aborts at 45". As root I can see my UPS like this: nimrodel:/etc/init.d # /usr/lib/ups/driver/megatec_usb -DDDD -a myups Network UPS Tools 2.2.2 - Megatec protocol driver 1.5.14 [megatec_usb] Carlos Rodrigues (c) 2003-2008 Serial-over-USB transport layer for Megatec protocol driver [megatec_usb] Andrey Lelikov (c) 2006, Alexander Gordeev (c) 2006-2007, Jon Gough (c) 2007 debug level is '4' Checking device (0665/5161) (003/026) - - VendorID: 0665 - - ProductID: 5161 - - Manufacturer: Cypress Semiconductor - - Product: USB to Serial - - Serial Number: unknown - - Bus: 003 Trying to match device Device matches Starting UPS detection process... Asking for UPS status [Q1]... Q1 => OK [(231.3 231.3 230.8 020 49.9 13.6 25.0 00001001] ... etc. It does see when I pull the cable: Asking for UPS status [Q1]... Q1 => OK [(005.8 235.2 227.0 022 50.1 12.0 25.0 10001001] Calculated battery charge: 57.5% Asking for UPS status [Q1]... Q1 => OK [(234.7 234.7 234.7 018 49.9 12.6 25.0 00001001] Calculated battery charge: 72.5% So I know that it is indeed the megatec_usb driver. I again changed the startup script: strace -ff -o /tmp/ups_trace $UPSDRVCTL_BIN start >/tmp/ups.log 2>&1 || rc_failed I get a side effect that it never exits, i have to kill it; but I now know what the problem is, or seems to be. /tmp/ups_trace.5352 /usr/lib/ups/driver/upsdrvctl this one starts a child: /tmp/ups_trace.5353 /usr/lib/ups/driver/megatec_usb The problem seems to be here, whenit attempts to access the usb bus: open("/dev/bus/usb/003/001", O_RDWR) = -1 EACCES (Permission denied) open("/dev/bus/usb/003/001", O_RDONLY) = 5 ioctl(5, USBDEVFS_CONNECTINFO, 0xbfff3834) = -1 EPERM (Operation not permitted) ... ioctl(4, USBDEVFS_IOCTL, 0xbfff57cc) = -1 ENOTTY (Inappropriate ioctl for device) close(4) = 0 open("/dev/bus/usb/003/001", O_RDWR) = -1 EACCES (Permission denied) open("/dev/bus/usb/003/001", O_RDONLY) = 4 ioctl(4, USBDEVFS_IOCTL, 0xbfff57cc) = -1 EPERM (Operation not permitted) and then seems to wait for ever here: ioctl(4, USBDEVFS_SETINTERFACE, 0xbfff58a4) = 0 gettimeofday({1227040766, 257390}, NULL) = 0 ioctl(4, USBDEVFS_SUBMITURB, 0xbfff7024) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0xbfff7068) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [4], NULL, {0, 1000}) = 0 (Timeout) gettimeofday({1227040766, 257974}, NULL) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0xbfff7068) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [], NULL, {0, 1000}) = 0 (Timeout) gettimeofday({1227040766, 261832}, NULL) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0xbfff7068) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [], NULL, {0, 1000}) = 0 (Timeout) There is a third process, that I can't see its name, in /tmp/ups_trace.5389: gettimeofday({1227040824, 883850}, NULL) = 0 ioctl(4, USBDEVFS_SUBMITURB, 0xbfff6f84) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0xbfff6fc8) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [4], NULL, {0, 1000}) = 0 (Timeout) gettimeofday({1227040824, 885955}, NULL) = 0 ioctl(4, USBDEVFS_REAPURBNDELAY, 0xbfff6fc8) = -1 EAGAIN (Resource temporarily unavailable) select(5, NULL, [], NULL, {0, 1000}) = 0 (Timeout) But I can't see which file is described by '5'. I have tried "RUN_AS_USER root" in upsmon.conf to no avail. If I use: [myups] # "BELKIN Active Battery Backup" driver = megatec_usb port = auto desc = "Local UPS" user = root but the driver complains it does not recognise the "user" option. Currently I have this startup line: $UPSDRVCTL_BIN -u root start || rc_failed which is verbose but does not work, either. I have been pointed to this email: http://lists.alioth.debian.org/pipermail/nut-upsuser/2008-February/003753.ht... and it appears that my particular UPS model works with the development version of the software. I will have to try that next. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkjaYUACgkQtTMYHG2NR9UuTgCfbVULsHukBNYW5DD8NmLYLSLr KLkAoI4keaB1AxflpHjg5cm2mymHf7qO =XRlM -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
I have tried "RUN_AS_USER root" in upsmon.conf to no avail. If I use:
I have (in upsmon.conf) RUN_AS_USER upsd MONITOR myups@localhost 1 upsd password master in upsd.users [root] password = password allowfrom = localhost actions = SET instcmds = ALL [upsd] password = password allowfrom = localhost upsmon master [upsslave] password = password allowfrom = localhost upsmon slave [root] password = password allowfrom = localhost upsmon master [root] password = password allowfrom = localhost upsmon slave
[myups] # "BELKIN Active Battery Backup" driver = megatec_usb port = auto desc = "Local UPS" user = root
I don't believe the "user =" line is allowed here. Oops, man ups.conf allows it as optional. But you have to define them in upsd.users.
but the driver complains it does not recognise the "user" option. Currently I have this startup line:
$UPSDRVCTL_BIN -u root start || rc_failed
for you looks like $UPSDRVCTL_BIN = /usr/lib/ups/driver/belkin for me: $UPSDRVCTL_BIN = /usr/lib/ups/driver/newhidups ps aux | grep ups /usr/lib/ups/driver/newhidups -a myups as user upsd nut-2.0.4-67.1
I have been pointed to this email:
http://lists.alioth.debian.org/pipermail/nut-upsuser/2008-February/003753.ht...
looking now
and it appears that my particular UPS model works with the development version of the software. I will have to try that next.
have you tried looking at the output of: $UPSDRVCTL_BIN -a myupsd -DDDD there is a lot of information there note: requires <ctrl><c> to stop and I do "rcups restart" after just to make sure that I haven't caused a problem :^) -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2008-11-18 at 21:09 -0500, Patrick Shanahan wrote:
* Carlos E. R.
[11-18-08 20:19]:
I have tried "RUN_AS_USER root" in upsmon.conf to no avail. If I use:
I have (in upsmon.conf) RUN_AS_USER upsd MONITOR myups@localhost 1 upsd password master
same.
in upsd.users
just: [upsd] password = 123456 allowfrom = localhost upsmon master currently. I commented out some entries. Till the driver runs, that part is secondary.
[myups] # "BELKIN Active Battery Backup" driver = megatec_usb port = auto desc = "Local UPS" user = root
I don't believe the "user =" line is allowed here. Oops, man ups.conf allows it as optional. But you have to define them in upsd.users.
Yep.
but the driver complains it does not recognise the "user" option. Currently I have this startup line:
$UPSDRVCTL_BIN -u root start || rc_failed
for you looks like $UPSDRVCTL_BIN = /usr/lib/ups/driver/belkin
No, I have a line before that: echo "User: "$UPSD_USER " Owner: " $UPS_OWNER " Port: " $PORT " Driver controller: "$UPSDRVCTL_BIN that prints me the vars, and they are: nimrodel:~ # time rcupsd start User: upsd Owner: upsd:root Port: auto Driver: /usr/lib/ups/driver/upsdrvctl The driver controller runs as root, I think. The daemon runs as "upsd", but the driver itself is doubtfull. i think it runs as upsd too..
for me: $UPSDRVCTL_BIN = /usr/lib/ups/driver/newhidups
ps aux | grep ups /usr/lib/ups/driver/newhidups -a myups
Thats the driver, not the controller. They are two processes.
have you tried looking at the output of: $UPSDRVCTL_BIN -a myupsd -DDDD
That would be /usr/lib/ups/driver/upsdrvctl -a myupsd -DDDD which fails to run. It would be the one I posted on my previous email, /usr/lib/ups/driver/megatec_usb -DDDD -a myups which does indeed work. But started from the controller, as the script does, it fails.
there is a lot of information there
Yes, I saw it. But nothing that helps starting the daemon: the daemon runs as user, and thus is denied access to the USB. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkjg0wACgkQtTMYHG2NR9UTlwCgmEeigkUvbTtHpQGJhgd/ZAH8 KJIAmwZouoDrjax0UQbWCcWuI39xD+DL =GdIY -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
On Tuesday, 2008-11-18 at 21:09 -0500, Patrick Shanahan wrote:
for me: $UPSDRVCTL_BIN = /usr/lib/ups/driver/newhidups
ps aux | grep ups /usr/lib/ups/driver/newhidups -a myups
Thats the driver, not the controller. They are two processes.
yes
have you tried looking at the output of: $UPSDRVCTL_BIN -a myupsd -DDDD
That would be
/usr/lib/ups/driver/upsdrvctl -a myupsd -DDDD
yes, this is wrong, s/b
/usr/lib/ups/driver/
which fails to run. It would be the one I posted on my previous email,
/usr/lib/ups/driver/megatec_usb -DDDD -a myups
which does indeed work. But started from the controller, as the script does, it fails.
as root, try: /usr/lib/ups/driver/upsdrvctl -t stop myups -t is test mode -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Patrick Shanahan
as root, try:
/usr/lib/ups/driver/upsdrvctl -t stop myups
-t is test mode
note: 23:54 wahoo:/home/pat # /usr/lib/ups/driver/upsdrvctl -t start myups Network UPS Tools - UPS driver controller 2.0.4 *** Testing mode: not calling exec/kill exec: /usr/lib/ups/driver/newhidups -a myups so upsdrvctl merely calls /usr/lib/ups/driver/<driver> to start the process. -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2008-11-18 at 23:57 -0500, Patrick Shanahan wrote:
as root, try:
/usr/lib/ups/driver/upsdrvctl -t stop myups
-t is test mode
23:54 wahoo:/home/pat # /usr/lib/ups/driver/upsdrvctl -t start myups Network UPS Tools - UPS driver controller 2.0.4 *** Testing mode: not calling exec/kill exec: /usr/lib/ups/driver/newhidups -a myups
so upsdrvctl merely calls /usr/lib/ups/driver/<driver> to start the process.
Yes, that's correct. But the driver is loaded/run as plain user and it has no permission to access the USB raw, and thus, it fails. When the driver is run as root it works (/usr/lib/ups/driver/megatec_usb -DDD -a myups), but then it can not be daemonized. At least, that's my current hypothesis. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkkAc8ACgkQtTMYHG2NR9UJnQCfW7zuLJapiI5dg8TkljoCBycN oEwAoIzv2jYo2UNzEug3pC5DLulNCR9a =pK63 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
On Tuesday, 2008-11-18 at 23:57 -0500, Patrick Shanahan wrote:
23:54 wahoo:/home/pat # /usr/lib/ups/driver/upsdrvctl -t start myups Network UPS Tools - UPS driver controller 2.0.4 *** Testing mode: not calling exec/kill exec: /usr/lib/ups/driver/newhidups -a myups
so upsdrvctl merely calls /usr/lib/ups/driver/<driver> to start the process.
Yes, that's correct. But the driver is loaded/run as plain user and it has no permission to access the USB raw, and thus, it fails. When the driver is run as root it works (/usr/lib/ups/driver/megatec_usb -DDD -a myups), but then it can not be daemonized.
At least, that's my current hypothesis.
You have a problem in upsd.conf, which contains "access control data", or upsd.users, which sets permissions for the ups daemon. My ups driver and monitor daemons run as user:upsd, which was created in upsd.users which I quoted in a previous mail in this thread. I have a user: upsd UPS daemon 150 daemon -rw------- 1 upsd root 2559 2008-09-03 21:14 upsd.users from upsd.users: # Network UPS Tools: Example upsd.users # # This file sets the permissions for upsd - the UPS network daemon. # Users are defined here, are given passwords, and their privileges are # controlled here too. Since this file will contain passwords, keep it # secure, with only enough permissions for upsd to read it. # -------------------------------------------------------------------------- # Each user gets a section. To start a section, put the username in # brackets on a line by itself. To set something for that user, specify # it under that section heading. The username is case-sensitive, so # admin and AdMiN are two different users. # # Possible settings: # # password: The user's password. This is case-sensitive. # # -------------------------------------------------------------------------- # # allowfrom: ACL names that this user may connect from. ACLs are # defined in upsd.conf. # # -------------------------------------------------------------------------- # # actions: Let the user do certain things with upsd. # # Valid actions are: # # SET - change the value of certain variables in the UPS # FSD - set the "forced shutdown" flag in the UPS # # -------------------------------------------------------------------------- # # instcmds: Let the user initiate specific instant commands. Use "ALL" # to grant all commands automatically. There are many possible # commands, so use 'upscmd -l' to see what your hardware supports. Here # are a few examples: # # test.panel.start - Start a front panel test # test.battery.start - Start battery test # test.battery.stop - Stop battery test # calibrate.start - Start calibration # calibrate.stop - Stop calibration # # -------------------------------------------------------------------------- # # Example: # # [admin] # password = mypass # allowfrom = admworkstation admhome # actions = SET # instcmds = ALL # [root] password = passwd allowfrom = localhost actions = SET instcmds = ALL # # --- Configuring for upsmon # # To add a user for your upsmon, use this example: # # [monuser] # password = pass # allowfrom = bigserver # # upsmon master (or upsmon slave) # # The matching MONITOR line in your upsmon.conf would look like this: # # MONITOR myups@myhost 1 monuser pass master (or slave) [upsd] password = passwd allowfrom = localhost upsmon master [upsslave] password = password allowfrom = localhost upsmon slave [root] password = passwd allowfrom = localhost upsmon master [root] password = passwd allowfrom = localhost upsmon slave and in upsmon.conf: MONITOR myups@localhost 1 upsd passwd master -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2008-11-19 at 08:44 -0500, Patrick Shanahan wrote:
Yes, that's correct. But the driver is loaded/run as plain user and it has no permission to access the USB raw, and thus, it fails. When the driver is run as root it works (/usr/lib/ups/driver/megatec_usb -DDD -a myups), but then it can not be daemonized.
At least, that's my current hypothesis.
You have a problem in upsd.conf, which contains "access control data", or upsd.users, which sets permissions for the ups daemon. My ups driver and monitor daemons run as user:upsd, which was created in upsd.users which I quoted in a previous mail in this thread.
Possibly, but my main problem is not the daemon, but the driver. First I have to get the driver talking to the ups; once that works, I'll worry about the daemon. The init script starts three things: upsdrvctl (message "Starting NUT UPS drivers failed") upsd (Starting NUT UPS server failed) upsmon (Starting NUT UPS monitor failed) As the driver fails, the other two will fail too, so worrying about their permissions is not important yet. My main problem is the driver part, and I think it is also a permission problem. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkkt6EACgkQtTMYHG2NR9WnuACeP2rNLDr/iscOn0gdAsYmHJvw D/UAnjluxMt0PxgDV3sxJssW59WUz0DT =4+XU -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
The init script starts three things:
upsdrvctl (message "Starting NUT UPS drivers failed") upsd (Starting NUT UPS server failed) upsmon (Starting NUT UPS monitor failed)
As the driver fails, the other two will fail too, so worrying about their permissions is not important yet. My main problem is the driver part, and I think it is also a permission problem.
post ups.conf, upsd.conf and upsd.users -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2008-11-19 at 21:14 -0500, Patrick Shanahan wrote:
The init script starts three things:
upsdrvctl (message "Starting NUT UPS drivers failed") upsd (Starting NUT UPS server failed) upsmon (Starting NUT UPS monitor failed)
As the driver fails, the other two will fail too, so worrying about their permissions is not important yet. My main problem is the driver part, and I think it is also a permission problem.
post ups.conf, upsd.conf and upsd.users
ups.conf: [myups] # "BELKIN Active Battery Backup" driver = megatec_usb -DDD port = auto desc = "Local UPS" # user = root the other two are not used. As I say, if the driver fails to load, the script exits and does not start the daemon, so it does not matter how it is configured. I know this for sure, I have done strace on it. And I inserted an "exit" instruction on the script to make absolutely sure the daemon does not attempt to start. The problem is that megatec_usb can not access the USB if run as user. And the driver controller has harcoded to run it as user. Not configurable. Yes, I tried "run_as = root", and "... -u root". No difference. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkk1XoACgkQtTMYHG2NR9U5ZgCeMJDlK5YNy0bVMKmIeAbP4kd7 iw0An3JW5YxMapQY0y5mF5YA2Xqdlmn5 =ObEr -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
On Wednesday, 2008-11-19 at 21:14 -0500, Patrick Shanahan wrote:
post ups.conf, upsd.conf and upsd.users
ups.conf:
[myups] # "BELKIN Active Battery Backup" driver = megatec_usb -DDD port = auto desc = "Local UPS" # user = root
the other two are not used. As I say, if the driver fails to load, the script exits and does not start the daemon, so it does not matter how it is configured.
upsd.conf grants access control and upsd.users sets permissions for the daemon
I know this for sure, I have done strace on it. And I inserted an "exit" instruction on the script to make absolutely sure the daemon does not attempt to start.
The problem is that megatec_usb can not access the USB if run as user. And the driver controller has harcoded to run it as user. Not configurable.
Yes, I tried "run_as = root", and "... -u root". No difference.
yes, but you are trying to make the daemon run from the control
script. You said that you *could* run the daemon as root. The
daemon is not meant to be ran as user, but the <user> defined in the
upsd.users file. I have defined mine to run as user = upsd and
ps aux | grep ups
upsd 11177 0.0 0.0 7496 3980 ? Ss Nov18 0:04 /usr/lib/ups/driver/newhidups -a myups
Try setting up upsd.users and upsd.conf and run the script direct from
the cl:
/usr/lib/ups/driver/megatec_usb -a myups -u
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2008-11-19 at 23:32 -0500, Patrick Shanahan wrote:
the other two are not used. As I say, if the driver fails to load, the script exits and does not start the daemon, so it does not matter how it is configured.
upsd.conf grants access control and upsd.users sets permissions for the daemon
Correct, but the daemon does not start.
I know this for sure, I have done strace on it. And I inserted an "exit" instruction on the script to make absolutely sure the daemon does not attempt to start.
The problem is that megatec_usb can not access the USB if run as user. And the driver controller has harcoded to run it as user. Not configurable.
Yes, I tried "run_as = root", and "... -u root". No difference.
yes, but you are trying to make the daemon run from the control script. You said that you *could* run the daemon as root. The daemon is not meant to be ran as user, but the <user> defined in the upsd.users file. I have defined mine to run as user = upsd and
No, I'm not attempting to run the "daemon". What I was trying to start is the driver. The script starts three programs: 1 - the driver daemon; if it succeeds, then it continues with '2' 2 - the server daemon (aka "the daemon"); if it succeeds, then it continues with '3' 3 - the monitor daemon It fails at '1', and the rest is skipped. User control only affects 2 and 3. Plus, I have inserted an "exit" command to make sure that 2 and 3 do not run.
Try setting up upsd.users and upsd.conf and run the script direct from the cl: /usr/lib/ups/driver/megatec_usb -a myups -u
I'll tell you what was the problem in a second :-) ** ups.conf: maxstartdelay = 70 <====== This. [myups] # "BELKIN Active Battery Backup" driver = megatec_usb -DDD port = auto # port=/dev/hiddev0 desc = "Local UPS" That was all! The timeout. The driver is given by default a timeout of 45 seconds, and if it fails, the controller aborts. When the timeout is increased, it succeeds at about 59 seconds. After that, all works. :-) ** hosts.conf: MONITOR myups@localhost "Local UPS" ** upsd.conf: ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all ** upsd.users: [upsd] password = 123456 allowfrom = localhost upsmon master ** upsmon.conf RUN_AS_USER upsd MONITOR myups@localhost 1 upsd 123456 master And, I have removed the user upsd from groups uucp and daemon. Ie, everything is at default config, except passwords and drivers... and the timeout: that was the problem. Of course, the root problem is why is it so slow. Can you imagine a one minute delay on every boot? - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkl50AACgkQtTMYHG2NR9UMkwCfUrZTvLw4dkSdbQgPUM2ew3BC va4An1qusziKtllnctpjbi90zhTC+2Lt =B99r -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
And, I have removed the user upsd from groups uucp and daemon. Ie, everything is at default config, except passwords and drivers... and the timeout: that was the problem.
Of course, the root problem is why is it so slow. Can you imagine a one minute delay on every boot?
That is *wierd* :^). It must be the ups unit is slow to communicate. One suggestion, the present config walls notification when you go "onbatt", but not when returning. I have changed: NOTIFYFLAG ONLINE SYSLOG to NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC as I cannot find another place to see the status other than grepping /var/log/messages: grep myups /var/log/messages Nov 20 17:08:01 wahoo upsmon[11184]: UPS myups@localhost on battery Nov 20 17:08:31 wahoo upsmon[11184]: UPS myups@localhost on line power It's rather alarming to get notice that you are on battery backup and no notice that normalcy has returned :^) It may be sufficient to use "EXEC" and drop wall as wall writes to every open terminal and EXEC merely opens (In my case) KEdit with a copy of the notice in the active desktop. (iiuc). -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday, 2008-11-20 at 18:03 -0500, Patrick Shanahan wrote:
Of course, the root problem is why is it so slow. Can you imagine a one minute delay on every boot?
That is *wierd* :^). It must be the ups unit is slow to communicate.
No, not that. Once it gets going it prints a message about every five seconds, if you start the driver on console. response to commands is fast. It must be one of the commands or initial tests that fail. I'll think that out some other day. Do you know of a pipe program that precedes every line with a time stamp? I want to get the output of the program to console with each line timed, so that I know well were the stoppage is and thus I can report it to the developers. Like: /usr/lib/ups/driver/megatec_usb -DDD -a myups | timerprogram 00:00.00 Network UPS Tools 2.2.2 - Megatec protocol driver 1.5.14 [megatec_usb]
One suggestion, the present config walls notification when you go "onbatt", but not when returning. I have changed: NOTIFYFLAG ONLINE SYSLOG to NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
as I cannot find another place to see the status other than grepping /var/log/messages:
grep myups /var/log/messages Nov 20 17:08:01 wahoo upsmon[11184]: UPS myups@localhost on battery Nov 20 17:08:31 wahoo upsmon[11184]: UPS myups@localhost on line power
It's rather alarming to get notice that you are on battery backup and no notice that normalcy has returned :^)
I guess! No, I have disabled all "wall" messages. If I'm using the computer, I know that power is out very well, the lights go out in the room ;-) As I don't use it from remote, I don't need it. And the wall messages in the middle of the console are a real nuisance if I want to take emergency measures before the battery runs out, like umounting external media. What I have to investigate is the procedure to automatically hibernate the machine after three minutes on battery. It is documented, I know, I just was busy on getting it to run first. My need for the software is precisely that: hibernate the machine fast if the power fails and I'm not there to do it manually. I don't want to stress the battery for the 10..20 minutes (7Ah batt) it lasts, because it is really stressful and takes 8 hours to recharge. It would be different with a large battery. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkmATgACgkQtTMYHG2NR9VEeQCgl+mzEoifqVvS9KWQbQoqBrO/ VDIAnjlIpazOVkXyOOYAsDibLP9v3fzQ =4BfY -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 20 November 2008 16:30, Carlos E. R. wrote:
On Thursday, 2008-11-20 at 18:03 -0500, Patrick Shanahan wrote:
Of course, the root problem is why is it so slow. Can you imagine a one minute delay on every boot?
That is *wierd* :^). It must be the ups unit is slow to communicate.
No, not that. Once it gets going it prints a message about every five seconds, if you start the driver on console. response to commands is fast. It must be one of the commands or initial tests that fail. I'll think that out some other day.
Do you know of a pipe program that precedes every line with a time stamp?
No such thing exists, nor is it even remotely possible... Still... tstamp: -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc tsFormat='%F_%H.%M.%S' IFS= while read line; do echo "$(date +"$tsFormat: $line")" done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- Adjust the tsFormat variable to create the time-stamp you want. The "date" command has many, many options. Check the help output or the man page.
...
-- Cheers, Carlos Robinson
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 20 November 2008 16:41, Randall R Schulz wrote:
...
tstamp:
OK. I kind of like this one, so I elaborated it a bit: -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc tsFormat='%F_%H.%M.%S' declare -i nErrors=0 for arg; do case "$arg" in +*) tsFormat="${arg#+}" ;; -*) echo "Unrecognized option: \"$arg\"" >&2 let nErrors++ ;; *) echo "Unrecognized argument: \"$arg\"" >&2 let nErrors++ ;; esac done if [ $nErrors -gt 0 ]; then exit $nErrors fi IFS= while read line; do echo "$(date +"$tsFormat: $line")" done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- Examples: % vmstat 2 |tstamp 2008-11-20_16.42.02: procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- 2008-11-20_16.42.02: r b swpd free buff cache si so bi bo in cs us sy id wa 2008-11-20_16.42.02: 3 0 500168 68320 18948 315528 0 1 6 32 34 17 4 4 91 1 2008-11-20_16.42.04: 0 0 500168 68320 18948 315528 0 0 0 0 364 1404 1 3 96 0 2008-11-20_16.42.06: 1 0 500168 68048 18948 315528 0 0 0 25 370 1529 2 4 94 0 2008-11-20_16.42.08: 0 0 500168 66792 18948 315528 0 0 0 74 411 1832 7 4 89 0 % vmstat 2 |tstamp +'Right Now!' Right Now!: procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- Right Now!: r b swpd free buff cache si so bi bo in cs us sy id wa Right Now!: 3 0 500168 95732 19076 315808 0 1 6 32 34 17 4 4 91 1 Right Now!: 0 0 500168 95360 19076 315808 0 0 0 3 361 1471 1 3 96 0 Right Now!: 0 0 500168 95360 19076 315808 0 0 0 0 461 1995 1 3 96 0 Right Now!: 0 0 500168 95268 19076 315808 0 0 0 27 372 1470 1 3 96 0 % vmstat 2 |tstamp +'%F_%H.%M.%S.%N' 2008-11-20_16.49.46.579369000: procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- 2008-11-20_16.49.46.582225000: r b swpd free buff cache si so bi bo in cs us sy id wa 2008-11-20_16.49.46.585086000: 1 0 500168 95216 19108 316072 0 1 6 32 34 18 4 4 91 1 2008-11-20_16.49.48.580113000: 3 0 500168 95216 19108 316072 0 0 0 23 364 1429 1 3 95 0 2008-11-20_16.49.50.583866000: 0 0 500168 95092 19108 316072 0 0 0 3 364 1424 1 3 97 0 % vmstat 2 |tstamp +%s 1227228626: procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- 1227228626: r b swpd free buff cache si so bi bo in cs us sy id wa 1227228626: 2 0 500168 94940 19124 315928 0 1 6 32 34 18 4 4 91 1 1227228628: 3 0 500168 94816 19124 315928 0 0 0 13 408 1619 2 3 95 0 1227228630: 0 0 500168 94692 19124 315928 0 0 0 3 399 1609 1 3 96 0 Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday, 2008-11-20 at 16:41 -0800, Randall R Schulz wrote:
On Thursday 20 November 2008 16:30, Carlos E. R. wrote:
Do you know of a pipe program that precedes every line with a time stamp?
No such thing exists, nor is it even remotely possible...
Not possible? I was considering of programming it myself, it would be quite short. I'd do it on pascal, probably. I was just wondering if it existed.
Still...
tstamp:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc
tsFormat='%F_%H.%M.%S'
IFS= while read line; do echo "$(date +"$tsFormat: $line")" done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
See? Not that difficult :-)
Adjust the tsFormat variable to create the time-stamp you want. The "date" command has many, many options. Check the help output or the man page.
The one most usefull to me would be time since command start. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkmDGIACgkQtTMYHG2NR9VOvQCeP4898y3MG3vYKtN18FScZ3ox cw0AnRFPbmaDvIP6BrlmmjIx//NHcRLv =zzzB -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday, 2008-11-20 at 16:51 -0800, Randall R Schulz wrote:
OK. I kind of like this one, so I elaborated it a bit:
Cute :-) I'll save both, thanks. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkmDO0ACgkQtTMYHG2NR9U3agCfQukl7niW1R3ngThJhvB11Fhb GLoAoImWKqh558KAFXdqx1kghQAWG0Fx =/d4a -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Now that one problem is mostly solved, perhaps someone can comment on the following err msg that I quite frequently get: Nov 20 18:49:56 wahoo kernel: usb 2-2: usbfs: USBDEVFS_CONTROL \ failed cmd newhidups rqt 161 rq 1 len 8 ret -110 -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Patrick Shanahan
Now that one problem is mostly solved, perhaps someone can comment on the following err msg that I quite frequently get:
Nov 20 18:49:56 wahoo kernel: usb 2-2: usbfs: USBDEVFS_CONTROL \ failed cmd newhidups rqt 161 rq 1 len 8 ret -110
I also get a lot of these: usbfs: process 7307 (newhidups) did not claim interface 0 before use -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 20 November 2008 17:18, Carlos E. R. wrote:
On Thursday, 2008-11-20 at 16:41 -0800, Randall R Schulz wrote:
On Thursday 20 November 2008 16:30, Carlos E. R. wrote:
Do you know of a pipe program that precedes every line with a time stamp?
No such thing exists, nor is it even remotely possible...
Not possible? I was considering of programming it myself, it would be quite short. I'd do it on pascal, probably. I was just wondering if it existed.
Still...
tstamp:
...
See? Not that difficult :-)
Just 'cause it's not possible doesn't mean I can't do it.
...
The one most usefull to me would be time since command start.
That's feasible. One of date's format's is (as shown in one of my examples), seconds since the epoch. That in combination with BASH's simple math abilities and its build-in "printf" command (to get fixed-width number rendering) make it straightforward to accomplish this. I'll leave it as "an exercise for the reader..."
-- Cheers, Carlos E. R.
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- Original Message -----
From: "Randall R Schulz"
On Thursday 20 November 2008 16:30, Carlos E. R. wrote:
On Thursday, 2008-11-20 at 18:03 -0500, Patrick Shanahan wrote:
Of course, the root problem is why is it so slow. Can you imagine a one minute delay on every boot?
That is *wierd* :^). It must be the ups unit is slow to communicate.
No, not that. Once it gets going it prints a message about every five seconds, if you start the driver on console. response to commands is fast. It must be one of the commands or initial tests that fail. I'll think that out some other day.
Do you know of a pipe program that precedes every line with a time stamp?
No such thing exists, nor is it even remotely possible...
Still...
tstamp:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc
tsFormat='%F_%H.%M.%S'
IFS= while read line; do echo "$(date +"$tsFormat: $line")" done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
Adjust the tsFormat variable to create the time-stamp you want. The "date" command has many, many options. Check the help output or the man page.
Unecessary sub-shell spwan. I don't see the point in unsetting IFS either. And I'm not sure putting the format string into a variable actually simplifies things. I end up with just one line and no spawned child shell. ---top--- #!/bin/bash --norc while read ;do date "+%F_%H.%M.%S: $REPLY" ;done ---end--- Though really I would suggest this in order to handle the last line of input if input ends without a final linefeed. ---top--- #!/bin/bash --norc DONE=false until $DONE ;do read || DONE=true date "+%Y%m%d%H%M%S: $REPLY" done ---end--- Except, even better than that, why run the date command over and over when other scripting languages have a date call built-in. Now we really only have one process, not even a shell plus date starting and exiting over and over, we just have one single awk: awk '{print strftime("%Y%m%d%H%M%S: ")$0}' or ---top--- #!/usr/bin/awk -f { print strftime("%Y%m%d%H%M%S: ")$0 } ---end--- There is also the logger command which does this already if you don't mind the output going to syslog or to a file configured by syslog.conf -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday, 2008-11-21 at 02:18 +0100, Carlos E. R. wrote:
Do you know of a pipe program that precedes every line with a time stamp?
No such thing exists, nor is it even remotely possible...
Not possible? I was considering of programming it myself, it would be quite short. I'd do it on pascal, probably. I was just wondering if it existed.
Ok, one in pascal (Lazarus flavour): program PipeTimer; {$mode objfpc}{$H+} uses SysUtils; var L: string; Czo, Ahora: TTimeStamp; MS : Comp; begin Czo := DateTimeToTimeStamp(Now); while not eof(input) do begin readln(L); MS:= TimeStampToMSecs(DateTimeToTimeStamp(Now)) - TimeStampToMSecs(Czo); writeln((MS/1000):4:4, ' ', L); end end. Ahh! None works: the "megatec_usb" driver outputs on stderr. Ah, ok, got it... nimrodel:~ # /usr/lib/ups/driver/megatec_usb -DDD -a myups 2>&1 | pipetimer I modify the startup script like this: $UPSDRVCTL_BIN -DDDD start 2>&1 | pipetimer || rc_failed and the output is: nimrodel:~ # rcupsd start Starting NUT UPS drivers 0.0000 Starting UPS: myups 0.0010 exec: /usr/lib/ups/driver/megatec_usb -a myups 42.9370 Megatec protocol UPS detected. 58.8300 Network UPS Tools - UPS driver controller 2.2.2 done Starting NUT UPS server done Starting NUT UPS monitor done nimrodel:~ # Or, if I call up the driver on a console, I get: nimrodel:~ # /usr/lib/ups/driver/megatec_usb -DDD -a myups 2>&1 | pipetimer 0.0030 debug level is '3' 0.1470 Checking device (1D6B/0001) (004/001) 0.1480 - VendorID: 1d6b 0.1490 - ProductID: 0001 0.1500 - Manufacturer: unknown 0.1510 - Product: unknown 0.1510 - Serial Number: unknown 0.1520 - Bus: 004 0.1530 Trying to match device 0.1540 Device does not match - skipping 0.1550 Checking device (1D6B/0001) (003/001) 0.1560 - VendorID: 1d6b 0.1570 - ProductID: 0001 0.1580 - Manufacturer: unknown 0.1590 - Product: unknown 0.1600 - Serial Number: unknown 0.1610 - Bus: 003 0.1610 Trying to match device 0.1620 Device does not match - skipping 0.1630 Checking device (1D6B/0002) (002/001) 0.1640 - VendorID: 1d6b 0.1650 - ProductID: 0002 0.1660 - Manufacturer: unknown 0.1670 - Product: unknown 0.1680 - Serial Number: unknown 0.1690 - Bus: 002 0.1700 Trying to match device 0.1710 Device does not match - skipping 0.1710 Checking device (0665/5161) (001/007) 0.2000 - VendorID: 0665 0.2010 - ProductID: 5161 0.2010 - Manufacturer: Cypress Semiconductor 0.2020 - Product: USB to Serial 0.2030 - Serial Number: unknown 0.2040 - Bus: 001 0.2050 Trying to match device 0.2060 Device matches 5.2280 Starting UPS detection process... 5.2280 Asking for UPS status [Q1]... 10.7020 Q1 => OK [(234.3 234.3 234.3 020 49.9 13.6 25.0 00001001] 10.7020 Asking for UPS status [Q1]... 16.2060 Q1 => OK [(234.3 234.3 234.3 019 49.9 13.6 25.0 00001001] 16.2060 Asking for UPS status [Q1]... 21.7100 Q1 => OK [(234.3 234.3 234.3 023 49.9 13.6 25.0 00001001] 21.7100 Asking for UPS status [Q1]... 27.1820 Q1 => OK [(233.3 233.3 233.3 021 49.9 13.6 25.0 00001001] 27.1820 Asking for UPS status [Q1]... 32.6860 Q1 => OK [(233.3 233.3 233.3 021 49.9 13.6 25.0 00001001] 32.6860 0 out of 5 detection attempts failed (minimum failures: 2). 32.6860 Cancelling any pending shutdown or battery test. 32.6900 Asking for UPS information [I]... 43.0000 I => FAILED [short read] 43.0000 I detail: (0 bytes) => 43.0000 Megatec protocol UPS detected. <============= 43.0000 Parameter [ignoreoff]: [false] 43.0000 Asking for UPS power ratings [F]... 53.3990 F => OK [#230.0 002 12.00 50.0] 53.4000 12.0V battery, interval [9.7V, 13.7V]. 53.4000 Done setting up the UPS. 53.4000 Asking for UPS status [Q1]... 58.8910 Q1 => OK [(234.7 234.7 234.7 021 49.9 13.6 25.0 00001001] 58.8910 Calculated battery charge: 97.5% 58.8920 dstate_init: sock /var/lib/ups/megatec_usb-myups open on fd 5 58.8920 Asking for UPS status [Q1]... 64.3900 Q1 => OK [(234.3 234.3 234.3 019 49.9 13.6 25.0 00001001] 64.3900 Calculated battery charge: 97.5% 66.3900 Asking for UPS status [Q1]... 71.8780 Q1 => OK [(233.3 233.3 233.3 019 49.9 13.6 25.0 00001001] 71.8780 Calculated battery charge: 97.5% 73.8780 Asking for UPS status [Q1]... 79.3660 Q1 => OK [(233.3 233.3 233.3 019 49.9 13.6 25.0 00001001] 79.3660 Calculated battery charge: 97.5% ^C nimrodel:~ # Each Q1 query takes 5..6 seconds, and the driver runs 5 queries before saying it works. Then the information query takes 10 more seconds (and fails). Therefore, till the moment it says "Done setting up the UPS" it has taken 53.4000 seconds! That's the problem, the UPS is simply slow answering. I think. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkmGa4ACgkQtTMYHG2NR9XMhQCgk7H9yvNt3glHL0b2xWu0eTeP KuMAn0TVonL9+wHZK9+vQkCViORR5pZY =mMZi -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday, 2008-11-20 at 20:41 -0500, Patrick Shanahan wrote:
I also get a lot of these:
usbfs: process 7307 (newhidups) did not claim interface 0 before use
Yes, I see some of those during my tests: Nov 20 15:04:24 nimrodel kernel: usb 1-1: usbfs: process 6538 (megatec_usb) did not claim interface 0 before use Nov 20 15:04:24 nimrodel kernel: usb 1-1: usbfs: process 6538 (megatec_usb) did not claim interface 0 before use Nov 20 15:08:28 nimrodel kernel: usb 1-1: usbfs: process 6503 (megatec_usb) did not claim interface 0 before use Nov 20 15:08:28 nimrodel kernel: usb 1-1: usbfs: process 6503 (megatec_usb) did not claim interface 0 before use I /think/ it must be some kind of programming error of the driver. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkmGrMACgkQtTMYHG2NR9Wd4ACfTrDljLskOFiS12n9SjR+6Eo3 ytkAn0ggzE2/bCJwoybDSxToETZ+2X25 =8S6k -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Carlos E. R.
On Thursday, 2008-11-20 at 20:41 -0500, Patrick Shanahan wrote:
I also get a lot of these:
usbfs: process 7307 (newhidups) did not claim interface 0 before use
Yes, I see some of those during my tests:
Nov 20 15:04:24 nimrodel kernel: usb 1-1: usbfs: process 6538 (megatec_usb) did not claim interface 0 before use Nov 20 15:04:24 nimrodel kernel: usb 1-1: usbfs: process 6538 (megatec_usb) did not claim interface 0 before use Nov 20 15:08:28 nimrodel kernel: usb 1-1: usbfs: process 6503 (megatec_usb) did not claim interface 0 before use Nov 20 15:08:28 nimrodel kernel: usb 1-1: usbfs: process 6503 (megatec_usb) did not claim interface 0 before use
I /think/ it must be some kind of programming error of the driver.
If that is so, it's in more that one driver. I did some googling and found claims on the nut-upsuser forum/debian that: Anyway, this is only of historical interest, because whatever caused those messages, does not seem to be present in the newest version of everything (usbdev, libusb, nut). it was signed by --Peter ?? saw this sig on several posts Apparently it is *still* present, but not always faulty :^) also there were claims that "britty" was the cause and it was cured by removing britty, some kind of social networking app? -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
The one most usefull to me would be time since command start.
Easy! in seconds: #!/usr/bin/awk -f BEGIN { S=systime() } { print systime()-S": "$0 } zero-padded seconds for nicer output: #!/usr/bin/awk -f BEGIN { S=systime() } { printf("%08i: %s\n",systime()-S,$0) } Now the good one days:hours:minutes:seconds: #!/usr/bin/awk -f BEGIN { S=systime() } { s=systime()-S m=0 h=0 d=0 if (s>=60) { m=s/60 ; s=s%60 } if (m>=60) { h=m/60 ; m=m%60 } if (h>=24) { d=h/24 ; h=h%24 } printf ("%04i:%02i:%02i:%02i: %s\n",d,h,m,s,$0) } Doing math on units of time larger than days doesn't make sense since months and years do not have fixed/static sizes. So 4 digits for days gives you over 27 years of possible uptime. Should be enough... ;) It's possible to have it consult a calander or the date syscall I guess and piece together that X seconds ago was Y years/months/days/... ago, but I don't think that would make an especially useful piece of data. "3 months and 2 days" is a different actual length of time depending on which particular months and years they were. -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- Original Message -----
From: "Brian K. White"
The one most usefull to me would be time since command start.
#!/usr/bin/awk -f BEGIN { S=systime() } { s=systime()-S m=0 h=0 d=0 if (s>=60) { m=s/60 ; s=s%60 } if (m>=60) { h=m/60 ; m=m%60 } if (h>=24) { d=h/24 ; h=h%24 } printf ("%04i:%02i:%02i:%02i: %s\n",d,h,m,s,$0) }
I tested the various rollover points like this: First, add something to the calculated seconds "s" to bring it close to a rollover point, after s=systime() and before anything that uses "s": s=systime()-S # s=s+58 # add 2 seconds before 1 minute to test minute rollover # s=s+3598 # add 2 seconds before 1 hour to test hour rollover s=s+86398 # add 2 seconds before 1 day to test day rollover m=0 h=0 d=0 if (s>=60) { m=s/60 ; s%=60 } if (m>=60) { h=m/60 ; m%=60 } if (h>=24) { d=h/24 ; h%=24 } printf ("%04i:%02i:%02i:%02i: %s\n",d,h,m,s,$0) Then echo/sleep/echo... (echo this ;sleep 1 ;echo is ;sleep 1 ;echo a ;sleep 1 ;echo test) |tscat unadulterated: 0000:00:00:00: this 0000:00:00:01: is 0000:00:00:02: a 0000:00:00:03: test one minute rollover: 0000:00:00:58: this 0000:00:00:59: is 0000:00:01:00: a 0000:00:01:01: test one hour rollover: 0000:00:59:58: this 0000:00:59:59: is 0000:01:00:00: a 0000:01:00:01: test one day rollover: 0000:23:59:58: this 0000:23:59:59: is 0001:00:00:00: a 0001:00:00:01: test -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (7)
-
Brian K. White
-
Carlos E. R.
-
Carlos E. R.
-
Carlos E. R.
-
David C. Rankin
-
Patrick Shanahan
-
Randall R Schulz