Calculate total of log by hour


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calculate total of log by hour
# 8  
Old 09-26-2011
did u give space between [ and :

Code:
 
-F"[ :]"

This User Gave Thanks to itkamaraj For This Post:
# 9  
Old 09-26-2011
Hi,

Apologies in advance, the cmd works for /var/adm/messages, but in the other log(abit sensitive to show)
Code:
adm@hsbc1> nawk -F"[ :]" '{print $3}' log.log | sort | uniq -c

  24 11
  18 12
  52 13
  56 14
  30 15
  39 16
  46 17
 178 18
 329 19
  47 20
  14 21
  16 22
  22 23
  24 24
  28 25
  35 26
  71 27
  10 28
   9 29
   4 30
   5 31
  23 32
  22 33
  24 34
  79 35
  20 36
  14 37
  12 38
  40 39
  43 40
  42 41
  24 42
  18 43
   5 44
   4 45
   4 46
   1 47
   4 48
  32 49
  96 50
  21 51
  17 52
  38 53
  34 54
  36 55


Last edited by Scott; 09-26-2011 at 08:39 AM.. Reason: Code tags
# 10  
Old 09-26-2011
Code:
 
awk -F"[ :]" '{print $2}' log.log  | sort | uniq -c

This User Gave Thanks to itkamaraj For This Post:
# 11  
Old 09-26-2011
oh, that was easy Smilie ...thanks very much, can you explain what is 3 or 2 that you changed ?
# 12  
Old 09-26-2011
-F"[ :]" --> you are splits the entire line by space and : as delimeter.

In the below line

2011-09-26 03:11:58,015 Thread-20565591 HTTP op [/createtemplatename

$1 --> 2011-09-26
$2 --> 03
$3 --> 11
$4 --> 58,015 and so.. on
$5 --> Thread-20565591
This User Gave Thanks to itkamaraj For This Post:
# 13  
Old 09-26-2011
superb!! many thanks !!!
# 14  
Old 09-28-2011
Hi again,

Now I have the list of total count by hours, is there any possibilities to extract the MAX from the total count, and count them in minutes ?

Something like,

PHP Code:
10342 00
51300 01
82801 02
2900 03
3306 04
4148 05
5560 06
16882 07
396 08
4608 09
2686 10
8635 11
8798 12
8402 13
763 14
805 15
930 16
1735 17
1575 18
954 19
805 20
605 21
301 22
250 23 
Hour 02 is the higher, then I want to extract this hour and count by minutes on this hour ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculate total memory using free -m

Hi I am trying to calculate memory used by Linux System free -m total used free shared buffers cached Mem: 32109 31010 1099 0 3600 7287 -/+ buffers/cache: 20121 11987 Swap: 10239 1282 8957 Now according to my requirement Im calculating memory using below cmd free -m | awk 'NR==3{printf... (2 Replies)
Discussion started by: sam@sam
2 Replies

2. Shell Programming and Scripting

Calculate the total

Hi All , I have the following script as below , I tried to modify to meet the requirement , could someone help ? very thanks ================================================================================================ while read STR NAME; do Total=0 MyString="$STR" GetData () {... (18 Replies)
Discussion started by: ust3
18 Replies

3. Shell Programming and Scripting

Calculate total value from a row

HI I have a file # cat marks.txt MARKS LIST 2013 Name english french chinese latin total_marks wer 34 45 67 23 wqa 12 39 10 56 wsy 23 90 23 78 Now i need to find the total marks of each student using... (11 Replies)
Discussion started by: Priya Amaresh
11 Replies

4. 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

5. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

6. Shell Programming and Scripting

Calculate total sum from a file

The file content is dynamic and using this format: name1 number1 name2 number2 name3 number3 name4 number4 .................... Need a smooth way to calculate the sum of all the numbers in that file (number1 + number2 + number3 + number4........ = total ) (11 Replies)
Discussion started by: TehOne
11 Replies

7. Shell Programming and Scripting

awk script to calculate total

Hi First field is the Record Type. A Record Type 5 can have multiple Record Type 6's before another Record Type 5 appears. I want to calculate the total of fields at position 8-11 on Record type 6 when Record Type 5 has a field at position 11-14 equals to '2222'. then it should delete the lines... (2 Replies)
Discussion started by: appsguy616
2 Replies

8. Shell Programming and Scripting

Awk help needed to calculate total

Hi all, I have a flat file like 10 steven 25 mike 47 Charles 127 Nancy 34 steven 23 mike 67 Charles 7761 Nancy 8 steven 54 mike 88 Charles 1267 Nancy I need to calculate the total of steven and all the members , for this I am using like grep "`sed -n 1p patterns.txt`"... (7 Replies)
Discussion started by: senthilkumar_ak
7 Replies

9. Shell Programming and Scripting

how to calculate busy hour

Dear All, please tell me any script which can able to calculate the bus hours by claculating the volume for example hour volume 1 100 2 200 3 300 4 7000 5 50 6 80 7 77 8 77 9 165 10 888 11 99 12 89 13 33 14 676 15 878 16 90 17 56 (14 Replies)
Discussion started by: shary
14 Replies
Login or Register to Ask a Question