
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, On 15/07/18 16:33, Russell Coker via luv-main wrote:
What's a good real-time log watching program?
This is something I've wanted for a while but not had the inclination to get it going. The thing that finally made me want to do it is when my workstation gave the below log messages and decided to stop supporting USB 3.0 ports. As the ports that are most convenient for connecting my keyboard and mouse are USB 3.0 that was inconvenient. Removing the xhci modules and loading them again fixed the problem. So what I want in this instance is a program that will detect one of the below messages and then run a script that will run some rmmod and modprobe commands to fix it. I want it to know which log entries it has dealt with to avoid performing the operation twice (which would cause problems) or maybe have a list of log messages in the problem solved category.
Any suggestions?
[18408.111698] xhci_hcd 0000:06:00.0: xHCI host not responding to stop endpoint command. [18408.111716] xhci_hcd 0000:06:00.0: xHCI host controller not responding, assume dead [18408.111738] xhci_hcd 0000:06:00.0: HC died; cleaning up [18408.111747] xhci_hcd 0000:06:00.0: Timeout while waiting for configure endpoint command
Simple bash? $ l --full-time coker* - -rw-r--r-- 1 andrewm andrewm 60 2018-07-15 17:23:06.450452422 +1000 coker-test.log - -rw-r--r-- 1 andrewm andrewm 12 2018-07-15 17:23:06.450452422 +1000 coker-test.action-time - -rw-r--r-- 1 andrewm andrewm 0 2018-07-15 17:23:07.278459755 +1000 coker-test.lastdone In another terminal: $ (tail -n0 -f coker-test.log |egrep --line-buffered '(aaa|aab)') >> coker-test.action-time & (while :;do [[ coker-test.action-time -nt coker-test.lastdone ]] && { echo do stuff;touch coker-test.lastdone;break; };sleep 10;echo -n .;done) Then echo some strings to coker-test.log from first terminal. ( Check status in second terminal each time) $ echo zzz >> coker-test.log $ echo aab >> coker-test.log The echo of aab will cause the second terminal to show the following and quit the loop: ...do stuff The testing each 10 seconds (with sleep), so about 30 seconds in it sees the aab string. $ ls -lart --full-time coker* - -rw-r--r-- 1 andrewm andrewm 68 2018-07-15 17:24:09.579011308 +1000 coker-test.log - -rw-r--r-- 1 andrewm andrewm 16 2018-07-15 17:24:09.579011308 +1000 coker-test.action-time - -rw-r--r-- 1 andrewm andrewm 0 2018-07-15 17:24:13.259043876 +1000 coker-test.lastdone When you are happy that is all working fine, wrap the above to keep it active: while :;do (tail -n0 -f coker-test.log |egrep --line-buffered '(aaa|aab)') >> coker-test.action-time & (while :;do [[ coker-test.action-time -nt coker-test.lastdone ]] && { echo do stuff;touch coker-test.lastdone;break; };sleep 10;echo -n .;done);done Cheers A. -----BEGIN PGP SIGNATURE----- iF4EAREIAAYFAltK+UIACgkQqBZry7fv4vtQbwEAo5cVG3CPAxg22bPcEO4DPeXo onMvipitnY0b9AoNevcA/RFx1eZKvqgx24okoRVw7RKSIaioTCNjeoML+9i9Xwjs =YJA3 -----END PGP SIGNATURE-----