- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script assistance
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
Forums
Discussions
Discussions
Discussions
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
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-23-2003 10:07 AM
01-23-2003 10:07 AM
Script assistance
I have a script that runs every hour:
userse=`who -u | grep 10.10. | wc -l `
who -u|grep 10.10|sort -k6
This shows me the users idle time sorted.
I then need to look in a /database/dbname.log file to see if they are still logged in. I do this manually now and this is what I want to automate.
In the log file, it shows the following:
08:55:28 Usr 9: Login by userid on /dev/ttyqa. (452)
I then run a manual script that emails a warning to the idle users to please logoff if not in use. This script emails users that have been idle for greater than 1 hour:
get_user()
{
USER=$(echo $LINE|awk '{print $1}')
IDLE=$(echo $LINE|awk '{print $6}')
if [ "$IDLE" = "old" ]
then
echo $MESSAGE |mailx -s $SUBJECT nickd
else
IDLE_HOURS=$(echo $IDLE|awk '{FS=":";print $1}')
if [ "$IDLE_HOURS" -ge 1 ]
then
#echo $MESSAGE |mailx -s $ SUBJECT $USER
#echo "Subject: Idle user Report" >>/tmp/idlemail.$$
#cat /usr/local/bin/scripts/idlemail >>/tmp/idlemail.$$
#sendmail nickd sendmail $USER fi
fi
}
who -u|while read LINE
do
get_user $LINE
done
I would like to enhance my script so it looks for idle users > than 1 hour, looks in the log and if the users does not have the word logout in the entry, then it emails them and it also copies the userid to a log file somewhere ie /home1/nickd/idleuser.log.
This will allow me to keep track of users and log them as they are not abiding by our policies.
Your assistance is appreciated.
Script newbie.
Nickd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 11:06 AM
01-23-2003 11:06 AM
Re: Script assistance
--
Thom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 11:14 AM
01-23-2003 11:14 AM
Re: Script assistance
Most of our users are in telnet app and TMEOUT doesn't help with that.
I find your script pretty innovative already.
If I were to let the sendmail go to the users' they'd get pretty mad. They violently defend their right to log in and not log out here.
Why do you think the word logout is going to be anywhere in a log?
Anyway, I'm taking your script and running a few tests on it to see if I can help you with it.
P
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 11:21 AM
01-23-2003 11:21 AM
Re: Script assistance
/database/dbname.log ?
If so, you can pull the username out of the output from your first line and then
grep $USERNAME | grep -v logout
This will get the username line if it doesn't have logout in it.
At this point you'd be well on your way to making this really slick script work.
When I ran your command line on my user system the value I get in the $userse variable is 0
The screen ouput shows all users, idle or not, sorted in ascending order, which is what you want. Am I getting a valid value in $userse?
It would be nice to see what dbname.log has in it so I can play with this. Just a sample example, I can play with.
P
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2003 12:23 PM
01-23-2003 12:23 PM
Re: Script assistance
here are my two scripts that I run - zipped with winzip
the first one is ewusers
it shows me all the users in our NJ building, based on IP address sorted by most idle time
The second one is the idle.sh script that checks for all users that are idle for more than 1 hour, regardless of whether they are in our db app or not and sends them a nice email to please logoff when not in use.
This is what our log file looks like:
5:06:30 Usr 15: Logout by petrecca on /dev/ttypd. (453)
15:09:58 Usr 15: Login by rarcoman on /dev/ttyr9. (452)
This means taht petrecca has logged off the db application and is cool, but the user rarcoman is logged on but not necessarily off.
I know this is a tricky script/process and I do appreciate your help.
By the way, you were right. The TMOUT is dangerous when it comes to db's. If the users are logged into the db application and sitting idle in the middle of editing a record, just think of the trouble that can be caused by a disconnect by the Operating system.
Cheers,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2003 12:19 PM
02-04-2003 12:19 PM