- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getting and graphing user login totals
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
04-18-2001 11:57 AM
04-18-2001 11:57 AM
What I really need is just the number value that comes after # users=
Anybody know how I can accomplish this and then set cron to get the value every 5 minutes?
I'll worry about how to graph it on a web page later, unless you all have some suggestions about this as well.
Thanks for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:04 PM
04-18-2001 12:04 PM
Re: Getting and graphing user login totals
How about this:
Create a script called get_num_users
#!/sbin/sh
/usr/bin/who -q | grep users | awk -F= '{ print $2 }' >> /dir/num_users
Then put the following entry in cron for root ('crontab -e'):
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /dirname/get_num_users
This should run the get_num_users script every 5 minutes, 24 hours a day, 7 days a week, and append the output to a file called get_num_users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:06 PM
04-18-2001 12:06 PM
Re: Getting and graphing user login totals
# 0,5,10,15,20,25,30,35,40,45,50,55 * * * * who|wc -l >> /tmp/usercount
A crontab entry like this will write the usercount into the file /tmp/usercount every 5-minutes.
See man 'crontab' for more information.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:31 PM
04-18-2001 12:31 PM
Re: Getting and graphing user login totals
Excellent! I knew it had to be AWK or SED, but I'm a complete moron with scripting stuff.
Another wrinkle I forgot. Do you think it is possible to add the date and time in the file as well?
I'd like to have it read like this:
25,date (with time)
rather than have it append the date after (below) the user value using >>
That way I could import it into Excel or something and graph it that way.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:49 PM
04-18-2001 12:49 PM
Re: Getting and graphing user login totals
Here's a new script for you:
#!/sbin/sh
num_user=`/usr/bin/who -q | grep users | awk -F= '{ print $2 }'`
date1=`date '+%x %X'`
echo "$num_user,$date1" >> /tmp/pww/numuser
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2001 02:01 AM
04-20-2001 02:01 AM
Re: Getting and graphing user login totals
and make an HTML table...
Graphing it would be a little bit more complicated...
#!/sbin/sh
num_user=`/usr/bin/who -q | grep users | awk -F= '{ print $2 }'`
date1=`date '+%x %X'`
echo "$num_user,$date1" >> /tmp/pww/numuser.html
## HTML Table builder
echo "
echo "
" >> /tmp/pww/numuser.html echo "$num_user" >> /tmp/pww/numuser.html echo " | " >> /tmp/pww/numuser.html echo "$date1" >> /tmp/pww/numuser.html echo " | " >> /tmp/pww/numuser.html
cp /tmp/pww/numuser.html
$WEB_SERVER/html
This way you would always have a "real time" table to Examine in numuser.html
Of course you can add fancy stuff to it...
Ed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2001 02:02 AM
04-20-2001 02:02 AM
Re: Getting and graphing user login totals
and make an HTML table...
Graphing it would be a little bit more complicated...
#!/sbin/sh
num_user=`/usr/bin/who -q | grep users | awk -F= '{ print $2 }'`
date1=`date '+%x %X'`
echo "$num_user,$date1" >> /tmp/pww/numuser.html
## HTML Table builder
echo "
echo "
" >> /tmp/pww/numuser.html echo "$num_user" >> /tmp/pww/numuser.html echo " | " >> /tmp/pww/numuser.html echo "$date1" >> /tmp/pww/numuser.html echo " | " >> /tmp/pww/numuser.html
cp /tmp/pww/numuser.html
$WEB_SERVER/html
This way you would always have a "real time" table to Examine in numuser.html
Of course you can add fancy stuff to it...
Ed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2001 06:05 AM
04-20-2001 06:05 AM
Re: Getting and graphing user login totals
You could still use the other script tips that were offered and you would have a more efficient script.
Hey, it's Friday... don't work so hard ;)
Cheers,
David