Mini Shell

Direktori : /proc/self/root/opt/sharedrads/
Upload File :
Current File : //proc/self/root/opt/sharedrads/check_boxtrapper

#!/bin/bash


LINESDEF="900000"

test "$2" == "--lines" && LINES=$3

MAIL_LOG="/var/log/exim_mainlog";
if [ ! -f $MAIL_LOG ]; then
        echo "Can't find $MAIL_LOG - bailing."
        exit 1;
fi

function pusage () {

    echo;echo "$0 --logs"
    echo "This will check the exim_mainlog for boxtrapper wars.  It's the
    most effective way to find a boxtrapper going on now, and is the default
    action taken by this script"


    echo;echo "$0 --scan"
    echo "This script will review the size of all boxtrapper log
    folders - it is intensive and can take up to an hour to complete
    if the server is heavily loaded.  Use with care."
#
#echo "Flags for this script are taken from 'du' flags. Common
#usage is described below:"
#
#echo;echo "$0 --logs  -h"
#echo "Human readable sizes";echo;
#
#echo;echo "$0 --logs  -b"
#echo "Display directory size in bytes (best when piped to sort
#-nk1 for directory listing - $0 --logs -b | sort -nk2)";echo;
#
#echo;echo "$0 --help"
#echo "This information blob.";
#
#


}

check_exim_boxtrapper () {
    echo "Scanning $MAIL_LOG for boxtrapper wars - big numbers are bad (usually 1k-> >100K).  You can ignore 'transport'."
    tail -${LINES:-$LINESDEF} /var/log/exim_mainlog | awk '/boxtrapper/{print $6}' | sort | uniq -c | sort -nk1
}


if [ -z $1 ];
then
    pusage
fi

case $1 in
--help)
    pusage
    ;;
--scan)
    DUOPT=""
    #{.2} == /home/ and /home2/
    for account in /home{,2}/*/etc/*/*/
    do
        if [ -d "${account}boxtrapper/log" ]
        then
            du -h --max-depth=1 ${account}boxtrapper/log
        fi
    done
    ;;

--logs)
    check_exim_boxtrapper
    ;;
    *)
    check_exim_boxtrapper
    ;;
esac

Zerion Mini Shell 1.0