how to calculate busy hour

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to calculate busy hour
# 8  
Old 01-28-2008
echo "Busy Hour = "`sort -k2nr file | sed q |awk '{print $1}'`

works to produce the outpit you requested...
# 9  
Old 01-28-2008
just modified a little bit

can u try it out
cat <<filename>> | sort -nr -t',' -k2 | head -1 | awk -F"," 'END{ print $1" :- is BUSY Hour"}'
# 10  
Old 01-29-2008

Just to inform you that i have tried your last given command and again its not returning any value.
Just displaying Busy Hour.

and regarding your previous command
echo "Busy Hour = "`sort -k2nr file | sed q |awk '{print $1}'`
when i am executing this one it will give me the wrong value instead of giving me the max value from 2nd col and should give the left most col value.

so please kindly check it again.

# 11  
Old 01-29-2008
I guess all the above solutions should work without any issues. I have tested mine and it works fine as well. Seems like it can be field seperator issue in the file which you are trying.
# 12  
Old 01-29-2008
but i am using the field sperator "," comma.
# 13  
Old 01-29-2008
Try this:

awk 'BEGIN{FS=","}NR==1{next}$2>m{h=$1;m=$2}END{print "BUSY HOUR = " h}' file

# 14  
Old 01-29-2008
thanx alot its working.
please if you dont mind can you explain me the last statement i cannot able to understand what is happening inside the awk like next,NR etc...
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

2. Shell Programming and Scripting

Calculate total of log by hour

Hi, Just wondering, is there anyway I can get the total of logs generated by hours ? Let say I have these logs, Sep 23 04:48:43 hsbcufs: NOTICE: realloccg /: file system full Sep 23 04:48:47 hsbcufs: NOTICE: alloc: /: file system full Sep 23 04:48:51 hsbcufs: NOTICE: realloccg /: file... (14 Replies)
Discussion started by: dehetoxic
14 Replies

3. Linux

How to Calculate Disk Queue length and Disk Busy Time

Hi, Am doing an enhancements related to monitoring a Linux disk I/O statistics. The /proc/diskstats file is used to get the each disk I/O statistics. But, It returns the raw value. How to calculate the Disk Queue Length and Disk Busy time from the raw values. Guide me. (1 Reply)
Discussion started by: maruthu
1 Replies

4. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

5. Shell Programming and Scripting

Grep string from logs of last 1 hour on files of 2 different servers and calculate count

Hi, I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files. File structure is same on both servers and for reference as follows: 27-Aug-2010... (4 Replies)
Discussion started by: poweroflinux
4 Replies

6. UNIX for Advanced & Expert Users

Filesystem mystery: disks are not busy on one machine, very busy on a similar box

Hi, We have a filesystem mystery on our hands. Given: 2 machines, A and Aa. Machine Aa is the problem machine. Machine A is running Ubuntu, kernel #1 SMP Wed Feb 20 08:46:16 CST 2008 x86_64 GNU/Linux. Machine Aa is running RHEL5.3, kernel 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38... (2 Replies)
Discussion started by: mschwage
2 Replies

7. UNIX for Dummies Questions & Answers

an hour less in 24 hour system

My program: __________________________________ #!/bin/ksh DAY=`date +%y%m%d` H=`date +%H` M=`date +%M` day=`date +%m/%d/%y` let h=$H-1 echo DAY $DAY echo H $H echo M $M echo day $day echo h $h _____________________________________ My result: (3 Replies)
Discussion started by: bobo
3 Replies
Login or Register to Ask a Question