-----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