- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: easy way to tell idle time for interactive log...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 04:53 PM
тАО01-12-2003 04:53 PM
if I do a w - I get:
ogriza01 pts/tYd 9:20am 30 11:13 11:13
this is all cool, but if the person isn't idle, the 30 is null.
I guess I need some way of splitting the line so that I can cater for the "is idle null" situation.
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 04:53 PM
тАО01-12-2003 04:53 PM
Re: easy way to tell idle time for interactive login
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 05:49 PM
тАО01-12-2003 05:49 PM
Re: easy way to tell idle time for interactive login
The first thing you need to do is get the information into columns so that you can segregate the column that has a "null" value.
Here is a start:
w | awk '{print $1"|"$3"|"$4"|"$7"|"}'
Once you've done that you'll have to get the 'null' and remove them. I guess that's a challenge. I would reckon that perl will do this quite well. I'll have an experiment, and see what I can come up with. (time permitting...)
Cheers
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 05:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 05:56 PM
тАО01-12-2003 05:56 PM
Re: easy way to tell idle time for interactive login
while read user tty login idle jcpu pcpu what
do
idlenull=$(echo $idle | grep -c ":")
if [ $idlenull -eq 0 ]
then
name=$(grep $user /etc/passwd | awk -F":" '{print $5}')
echo "$user - $name on $tty has been idle for $idle minutes and has a cumulative cpu of $jcpu"
fi
done
it's just grepping for the time component, which I know exists. If I get $idle (output from w) with what looks like a time component, it means that the idle is null.
Not very nice, just wondering if there's a better way.
Scott.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 06:00 PM
тАО01-12-2003 06:00 PM
Re: easy way to tell idle time for interactive login
Check this script
#!/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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 06:28 PM
тАО01-12-2003 06:28 PM
Re: easy way to tell idle time for interactive login
as soon as I started to use the who -T stuff, I came up with something very similar.
Sort of.
I'm also looking for high cumulative CPU time. This in combination with idle time lets me know those people who are running large jobs online during the day.
When I find them, they'll get a call from their friend unix admin with a suggestion that they can run whatever they're running overnight.
Thanks for all the help guys.
Scott.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 06:33 PM
тАО01-12-2003 06:33 PM
Re: easy way to tell idle time for interactive login
If the goal is to divest yourself of sessions without activity for n-seconds, consider setting the TMOUT variable. If set to a value greater than zero (seconds), the shell will terminate TMOUT seconds after a PS1 prompt is issued and no input is received.
You could set the TMOUT value in the user's profile. Setting the TMOUT 'readonly' will prevent the user from overriding it:
# TMOUT=10;readonly TMOUT
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2003 06:37 PM
тАО01-12-2003 06:37 PM
Re: easy way to tell idle time for interactive login
I'm trying to find out people who log in three times and run huge reports or whatever during the day.
I guess I'm trying to identify those people, find out what they're doing, then try to get them to run this stuff overnight.