Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/sharedrads/oldrads/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/sharedrads/oldrads/check_secs

#!/bin/bash
# Shared RADS Tools, written by Erik Soroka (eriks@imhadmin.net, ext 834)

#####################################################################
### DISPLAY CPU SECONDS LIVE
#####################################################################

echo

#load functions + banners
if [ -f /opt/sharedrads/radsfunctions.sh ]; then
    source /opt/sharedrads/radsfunctions.sh
else
    source /opt/dedrads/radsfunctions.sh
fi
smradsbanner


if [ -f /var/log/sa/rads/.lastcomm.lock ]; then
       	# remove any stale lock file (it should never be older than 1 minute)
        CHECKLOCK=$(find /var/log/sa/rads/.lastcomm.lock -mmin +2 -name "*" -print)

        if [ "$CHECKLOCK" == "" ]; then
		echo
        else
            	rm -f /var/log/sa/rads/.lastcomm.lock
        fi
fi


echo
echo -n " Please wait."
echo -e "\033[40;37;2m CPU usage: `date +%H`:00-`date +%H:%M` \033[0m" > /var/log/sa/rads/.lastcomm.cache

while [ -f /var/log/sa/rads/.lastcomm.lock ] ;
do
	RUNNING=TRUE
	echo -n "."
        sleep 5.5
done

	echo -n ".."

	if [ "$RUNNING" == "TRUE" ]; then
		#we already have up to the minute data, just show the cache
		echo
		echo
		cat /var/log/sa/rads/lastcomm.cache
		echo
		exit 0
	fi

#lock it up
touch /var/log/sa/rads/.lastcomm.lock

#get list of users
userlist=$(/usr/sbin/sa -cm | egrep -v 'root|nobody' | head -21 | tail -20 | awk '{ print $1 }')

       	echo -n ".."

for acct in $userlist; \
do
echo -n -e "$acct cp sec: "; /usr/bin/lastcomm $acct | grep "`date +%b\ %e\ %H`" \
| awk '{TOTAL+=$(NF-5)}END{print TOTAL}'
done | egrep -v ': 0$' | sort -nk4 -r | head -15 >>/var/log/sa/rads/.lastcomm.cache

	echo -n ".."

mv -f /var/log/sa/rads/.lastcomm.cache /var/log/sa/rads/lastcomm.cache

echo
echo
cat /var/log/sa/rads/lastcomm.cache
echo

#remove the lock
rm -f /var/log/sa/rads/.lastcomm.lock

echo

## EOF ##

Zerion Mini Shell 1.0