Skip to content

Instantly share code, notes, and snippets.

@tawateer
Created December 20, 2016 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tawateer/6b954e19f30e7e38c4819bce91e6d7ae to your computer and use it in GitHub Desktop.
Save tawateer/6b954e19f30e7e38c4819bce91e6d7ae to your computer and use it in GitHub Desktop.
过滤系统日志
#!/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