Anzahl der Muster in syslog nach Wochentag
# cat check-syslog.sh
#
# $0 [-q] "pattern" ["syslog-file"]
#
if test ":$1" = ":-q"
then
shift
DEBUG=0
fi
PAT=$1
shift
if test -z "$1"
then
LIST=/var/log/syslog
else
LIST=$(echo $*)
fi
for i in $LIST
do
test -z "$DEBUG" && echo "file: $i " >&2
if file $i| grep -q gzip
then
gzip -cd $i | grep -i "$PAT"
else
grep -i "$PAT" $i
fi
done | cut -c-16 | sort | while read date; do date -d "$date" "+%a"; done | sort | uniq -c
Beispiele:
# ./check-syslog.sh smart
file: /var/log/syslog
21 Wed
# ./check-syslog.sh smart /var/log/syslog /var/log/syslog.1
file: /var/log/syslog
file: /var/log/syslog.1
111 Tue
21 Wed
# ./check-syslog.sh -q smart /var/log/syslog*
92 Fri
85 Mon
87 Sat
76 Sun
85 Thu
111 Tue
101 Wed