ccollect/tools/ccollect_analyse_logs.sh

100 lines
4.7 KiB
Bash
Raw Normal View History

#!/bin/sh
# Nico Schottelius
# written for Netstream (www.netstream.ch)
# Date: Di 21. Aug 17:10:15 CEST 2007
# Analyse existing logs
2007-08-27 16:59:10 +00:00
version=0.1
date=2007-08-24
fullversion="${version} (${date})"
args=iwe
usage() {
echo "$(basename "$0") ${fullversion}: [iwe]"
echo ""
echo " i: print informational messages"
echo " w: print warning messages"
echo " e: print error messages"
echo ""
echo "Reading input from stdin, displaying to stdout."
exit 1
}
#
# read and verify argv
#
if [ "$#" -ne 1 ]; then
usage
fi
argv="$1"; shift
wrong="$(echo ${argv} | grep -e "[^${args}]")"
if [ "${wrong}" ]; then
usage
fi
# set output levels
search_err="$(echo ${argv} | grep 'e')"
search_warn="$(echo ${argv} | grep 'w')"
search_info="$(echo ${argv} | grep 'i')"
#
# Interesting strings in the logs: errors
# ---------------------------------------
if [ "$search_err" ]; then
set -- "$@" "-e" 'Read from remote host .*: Connection timed out$'
set -- "$@" "-e" 'Read from remote host .*: Connection reset by peer$'
set -- "$@" "-e" 'rsync: .*: Invalid argument (22)$'
set -- "$@" "-e" 'rsync: .*: Input/output error (5)$'
set -- "$@" "-e" 'cannot send long-named file "'
set -- "$@" "-e" 'ERROR: .* failed verification -- update discarded.$'
fi
# known error strings:
#[ddba049.netstream.ch] receiving file list ... rsync: readdir("/proc"): Invalid argument (22)
#[ddba033.netstream.ch] rsync: readlink "/usr/local/inetpub2/webmailroot/2wire.ch/royal@2wire.ch" failed: Input/output error (5)
#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5)
2007-08-27 16:59:10 +00:00
#[zrha165.netstream.ch] Read from remote host zrha165.netstream.ch: Connection reset by peer
#[ddba017.netstream.ch] receiving file list ... cannot send long-named file "/usr/local/www/apache22/cgi-bin/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/bac kup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup /backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ba ckup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backu p/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/back"
#[ddba033.netstream.ch] ERROR: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded.
2007-08-27 16:59:10 +00:00
#
# Interesting strings in the logs: warnings
# -----------------------------------------
#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5)
2007-08-27 16:59:10 +00:00
# [ddba015.netstream.ch] send_files failed to open /usr/local/dnscache/log/main/@4000000046ca0f3616939c14.s: No such file or directory
# [ddba015.netstream.ch] 2007-08-21-02:17:28: Finished backup (rsync return code: 23).
# [ddba017.netstream.ch] file has vanished: "/var/spool/postfix/active/657575D686"
#[ddba026.netstream.ch] 2007-08-21-05:35:13: Finished backup (rsync return code: 24).
#[ddba045.netstream.ch] send_files failed to open /data/hsphere/local/var/named/logs/@4000000046c98fa9079f39ac.s: No such file or directory
# file has vanished: ".*"
2007-08-27 16:59:10 +00:00
if [ "$search_warn" ]; then
# warn on non-zero exit code
set -- "$@" "-e" 'Finished backup (rsync return code: [^0]'
set -- "$@" "-e" 'WARNING: .* failed verification -- update discarded (will try again).'
fi
# known warnings:
#[ddba033.netstream.ch] WARNING: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded (will try again).
#
2007-08-27 16:59:10 +00:00
# Interesting strings in the logs: informational
# ----------------------------------------------
if [ "$search_info" ]; then
set -- "$@" "-e" 'total size is [[:digit:]]* speedup is'
set -- "$@" "-e" 'Backup lasted: [[:digit:]]*:[[:digit:]]\{1,2\}:[[:digit:]]* (h:m:s)$'
set -- "$@" "-e" 'send [[:digit:]]* bytes received [0-9]* bytes [0-9]* bytes/sec$'
fi
2007-08-27 16:59:10 +00:00
# info includes:
#[ddba012.netstream.ch] total size is 22384627486 speedup is 13.75
# [u0160.nshq.ch.netstream.com] 2007-08-20-18:26:06: Backup lasted: 0:43:34 (h:m:s)
#[ddba012.netstream.ch] sent 3303866 bytes received 1624630525 bytes 122700.92 bytes/sec
2007-08-27 16:59:10 +00:00
grep "$@"