Created
March 17, 2017 03:29
-
-
Save flashvoid/fbdad915d1cb839143a89506d7b3054d to your computer and use it in GitHub Desktop.
monitor dmesg
This file contains hidden or 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
#!/bin/bash | |
period=$1 | |
shift | |
pattern=$@ | |
last_timestamp= | |
while :; do | |
line=$(dmesg | grep "$pattern" | tail -n 1) | |
timestamp=$(echo $line | cut -d" " -f1 | sed 's/[]\[]//g') | |
if [[ $timestamp != $last_timestamp ]]; then | |
echo "Found new occurance of pattern with timestamp $timestamp" | |
last_timestamp=$timestamp | |
fi | |
sleep $period | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment