Created
December 20, 2016 16:11
-
-
Save tawateer/6b954e19f30e7e38c4819bce91e6d7ae to your computer and use it in GitHub Desktop.
过滤系统日志
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 | |
key_word="USB|usb|eth1|CPU|time|softirq|CD-ROM|IPMI|ipmi|tcpdump|flooding|debugging|ffffffff|UDP|cf_|wzp" | |
if [ -f "/var/log/message" ];then | |
log_time=`date -r /var/log/message +%s` | |
real_time=`date +%s` | |
diff_time=`expr $real_time - $log_time` | |
if [ $diff_time -lt 60 ];then | |
tail -n 1 /var/log/message |egrep $key_word &>/dev/null | |
if [ "$?" -ne "0" ];then | |
echo -e "BS_KERNEL_LOG : 1" | |
else | |
echo -e "BS_KERNEL_LOG : 0" | |
fi | |
else | |
echo -e "BS_KERNEL_LOG : 0" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment