initial commit of file from CVS for smeserver-audittools on Mon 10 Jul 08:35:16 BST 2023
This commit is contained in:
25
root/sbin/e-smith/audittools/logcheck
Normal file
25
root/sbin/e-smith/audittools/logcheck
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#logcheck [days] [location]
|
||||
re='^[0-9]+$'
|
||||
days=2
|
||||
location=/tmp
|
||||
|
||||
# If there is a second arg, use it as the location
|
||||
if ! [ -z "$2" ]; then
|
||||
location=$2
|
||||
fi
|
||||
|
||||
# If first arg is a number, then set days.
|
||||
if ! [ -z "$1" ]; then
|
||||
if [[ $1 =~ $re ]] ; then
|
||||
days=$1
|
||||
else
|
||||
location=$1
|
||||
fi;
|
||||
fi
|
||||
|
||||
echo "Log file: $location/log$(date +'%m%d%y')"
|
||||
find /var/log/ -mtime -$days -print -exec sh -c 'cat "{}" | tai64nlocal | egrep -i "useless|warn|fail|error|disable|remov|unable|exit"' \; > "$location/log$(date +'%m%d%y')" 2>&1
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user