Operating System - HP-UX
1847843 Members
2844 Online
104021 Solutions
New Discussion

idle users - notify with email

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

idle users - notify with email

All,

This should be an easy one, however, the HPUX TMOUT parameter is not an option. If the O/S times out while the user has a db connection, we run the risk of data corruption.

I am looking for a script that will be run every 1/2 hour that will check to see if any users are idle for more than 1 hour and then it will send them an email.

Can someone suggest something that might help me out please?

Thanks,
Always learning
5 REPLIES 5
Paula J Frazer-Campbell
Honored Contributor

Re: idle users - notify with email

Nick

Use a script on the who -u and pick up from that their idle time and if over a certain limit then email that user.

Paula
If you can spell SysAdmin then you is one - anon
Nick D'Angelo
Super Advisor

Re: idle users - notify with email

Thanks, but I am not very good at scripts yet.
Always learning
Paula J Frazer-Campbell
Honored Contributor

Re: idle users - notify with email

Nick

check out the handy scripts thread I think there was somthing there.

Paula
If you can spell SysAdmin then you is one - anon
Paula J Frazer-Campbell
Honored Contributor

Re: idle users - notify with email

Link


http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html


Paula
If you can spell SysAdmin then you is one - anon
Sridhar Bhaskarla
Honored Contributor
Solution

Re: idle users - notify with email

Hi,

See if this works,

#!/usr/bin/ksh
HOST=$(hostname)
EVERY=1

MESSAGE="please consider logging out"
SUBJECT="You are IDLE on $HOST"

get_user()
{
USER=$(echo $LINE|awk '{print $1}')
IDLE=$(echo $LINE|awk '{print $6}')
if [ "$IDLE" = "old" ]
then
echo $MESSAGE |mailx -s $ SUBJECT $USER
else
IDLE_HOURS=$(echo $IDLE|awk '{FS=":";print $1}')
if [ "$IDLE_HOURS" -ge 1 ]
then
echo $MESSAGE |mailx -s $ SUBJECT $USER
fi
fi
}
who -u|while read LINE
do
get_user $LINE
done

-Sri
You may be disappointed if you fail, but you are doomed if you don't try