diff options
Diffstat (limited to 'abs/core/linhes-scripts/idle.sh')
-rwxr-xr-x | abs/core/linhes-scripts/idle.sh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh index f95b9fa..13fdb89 100755 --- a/abs/core/linhes-scripts/idle.sh +++ b/abs/core/linhes-scripts/idle.sh @@ -1,11 +1,12 @@ #!/bin/bash usage () { - echo "Usage: $0 [-h] [-s] [-t <minutes_needed>]" + echo "Usage: $0 [-h] [-s] [-t <minutes_needed>] [-l] [-v]" echo echo "-h - Print this help/usage message and quit" echo "-s - Run silently (default is verbose)" echo "-t - Minutes of idle time needed (default is 20)" + echo "-l - Check for user logins (default: false - do not check)" echo "-v - Be more verbose for debugging" echo echo "Silent mode is recommended for use in cron jobs or scripts." @@ -22,14 +23,16 @@ mysql_cmd () { # Command line argument handling VERBOSE=1 +LOGINS=0 TIME_BEFORE=20 TIME_AFTER=5 # Only adjustable by editing here -while getopts "hst:v" OPT ; do +while getopts "hslt:v" OPT ; do case $OPT in h) usage 0 ;; s) VERBOSE=0 ;; t) TIME_BEFORE=$OPTARG ;; + l) LOGINS=1 ;; v) VERBOSE=2 ;; *) usage 1 ;; esac @@ -91,7 +94,19 @@ if [ "$VERBOSE" -ge 2 ] ; then item += 1; }' fi -activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING)) + +if [ "$LOGINS" -ge 1 ] ; then + USERS=`/usr/bin/last | /bin/grep "still logged in" | awk '{ print $1 }'` + if [ -n "$USERS" ] ; then + LOGINS=1 + msg "The following user(s) are still logged in: ${USERS}" + else + LOGINS=0 + msg "No user(s) are logged in..." + fi +fi + +activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $LOGINS)) msg if [ "$activities" -eq 0 ] ; then msg "System is idle" |