Last active
September 17, 2016 21:57
-
-
Save darconeous/e2975c25b98422ba753c9e6bca1818f3 to your computer and use it in GitHub Desktop.
syslog-ng automatic reboot upon USB failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These next three lines monitor the log for indications | |
# that the USB device has gotten into a bad state. When we | |
# notice that the USB device is in a bad state, we want to | |
# reboot. However, in order to avoid reboot loops, we only | |
# allow a reboot to occur if the system has been up for | |
# longer than 5 minutes. -- RQ 2016-09-17 | |
filter f_usbfail { program("pcscd") and match("LIBUSB_ERROR_PIPE" value("MESSAGE")); }; | |
destination usbfail_monitor { program("awk '/LIBUSB_ERROR_PIPE/ { system(\"test \$(cut -f 1 -d . /proc/uptime) -gt \$((5*60)) && reboot\") }'"); }; | |
log { source(src); filter(f_usbfail); destination(usbfail_monitor); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment