- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script to calculate the total idle minutes
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
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
тАО02-20-2007 09:29 PM
тАО02-20-2007 09:29 PM
Re: Script to calculate the total idle minutes
(( idle_min = 10#$(echo $idle|cut -f1 -d':') * 60 + 10#$(echo $idle|cut -f2 -d':') ))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 01:20 AM
тАО02-21-2007 01:20 AM
Re: Script to calculate the total idle minutes
Please consider the following free advice, worth every penny.
1) This particular wheel has been invented many times over. Please look around for existing commercial or freeware solutions.
It looks simple enough now, but it is probably too simple. You'll soon need exclusion lists and time ranges and stuff like that.
2) Every Unix sysadm MUST try to aquire some awk and perl skills. Not saying you should start doing everything with those (allthough you could :-), but for your own career you MUST get going on those powerful tools.
3) Idle killers suck... IMHO. They suck computer resources, they suck positive energy out of users, they suck at providing security, they suck admin time. They do exactly waht their name implies, but not what you want: They kill idleness and replace it with busyness. Sounds like a bad virus to me!
4) Consider replacing the "ge" in you script with a simple ">". The leading zero minute field compares nicely as a string instead of numbers.
5) Just to trigger your cusiosity consider this perl script reading the smaple input your gave:
#perl -lne 'if (/(\d+):(\d\d)$/) { ($u,$t,$i)=split; print qq($u on $t idle for $i) if ($1>0 or $2>30)}' tmp.txt
kwchow on pts/tr idle for 0:54
mmak on pts/tk idle for 1:16
#perl -lne -e = cmmand follows, -l=print newlines, -n=loop throug input Not printing.
if (/(\d+):(\d\d)$/){ = Look for decimals, a colong and two decimals at the end of the line.
If found remember in $1 and $2 and execute block.
($u,$t,$i)=split; # AAyup that's what it does.
print qq($u on $t idle for $i) if # conditional statement
($1>0 or $2>30)} # The hour not 0, or minutes greate than 30
Cheers,
Hein.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 03:44 AM
тАО02-21-2007 03:44 AM
Re: Script to calculate the total idle minutes
(( idle_min = $(echo $idle|cut -f1 -d':') * 60 + $(echo $idle|cut -f2 -d':'
) ))
with...
(( idle_min = $(echo $idle|cut -f1 -d':') * 60 + $(echo $idle|cut -f2 -d':' | bc
) ))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 03:53 AM
тАО02-21-2007 03:53 AM
Re: Script to calculate the total idle minutes
please see my bc solution posted at 08:58:06
;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 06:40 AM
тАО02-21-2007 06:40 AM
Re: Script to calculate the total idle minutes
On 11.23, this UNIX95 has been removed. In all cases it:
... will be processed according to ISOC standard
- Tags:
- UNIX95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2007 05:50 PM
тАО02-22-2007 05:50 PM
Re: Script to calculate the total idle minutes
I found more than 1 solution, but I choose the most understanable one, the "|bc", also rewrote this script which is written few years ago in a more structured format
Correct, I need to acquire to learn some awk knowledge & someone else in my team is learning Perl, so may rewrite this script in Perl later
Thanks,
Rita
- « Previous
-
- 1
- 2
- Next »