05-07-2009
awk script to count percentage from log file
Hi,
I have a log like this :
Quote:
Object Counter 12:00 12:15 12:30 12:45
30011 pmTotNoRrcConnectReq 71 65 82 70
30011 pmTotNoRrcConnectReqSuccess 71 64 84 70
30012 pmTotNoRrcConnectReq 109 104 112 125
30012 pmTotNoRrcConnectReqSuccess 109 104 112 124
30013 pmTotNoRrcConnectReq 66 64 67 63
30013 pmTotNoRrcConnectReqSuccess 66 64 67 63
30021 pmTotNoRrcConnectReq 139 123 141 149
30021 pmTotNoRrcConnectReqSuccess 139 123 140 149
30022 pmTotNoRrcConnectReq 69 62 83 67
30022 pmTotNoRrcConnectReqSuccess 69 62 84 67
30023 pmTotNoRrcConnectReq 43 66 64 59
30023 pmTotNoRrcConnectReqSuccess 42 66 65 59
30031 pmTotNoRrcConnectReq 409 421 415 418
30031 pmTotNoRrcConnectReqSuccess 410 425 409 417
30032 pmTotNoRrcConnectReq 61 112 89 61
30032 pmTotNoRrcConnectReqSuccess 61 112 87 61
30033 pmTotNoRrcConnectReq 266 281 324 299
30033 pmTotNoRrcConnectReqSuccess 262 280 323 296
30041 pmTotNoRrcConnectReq 44 39 50 41
30041 pmTotNoRrcConnectReqSuccess 44 38 51 41
30042 pmTotNoRrcConnectReq 113 98 119 91
30042 pmTotNoRrcConnectReqSuccess 113 98 116 92
30043 pmTotNoRrcConnectReq 108 116 132 105
30043 pmTotNoRrcConnectReqSuccess 108 115 132 102
30051 pmTotNoRrcConnectReq 194 230 211 200
30051 pmTotNoRrcConnectReqSuccess 194 230 210 199
30052 pmTotNoRrcConnectReq 199 190 177 201
30052 pmTotNoRrcConnectReqSuccess 198 191 177 198
30053 pmTotNoRrcConnectReq 183 203 179 201
30053 pmTotNoRrcConnectReqSuccess 183 201 179 201
30061 pmTotNoRrcConnectReq 468 463 413 435
30061 pmTotNoRrcConnectReqSuccess 468 462 411 435
30062 pmTotNoRrcConnectReq 617 501 555 539
30062 pmTotNoRrcConnectReqSuccess 615 504 553 539
30063 pmTotNoRrcConnectReq 182 204 189 186
30063 pmTotNoRrcConnectReqSuccess 179 207 188 184
30071 pmTotNoRrcConnectReq 434 451 385 324
30071 pmTotNoRrcConnectReqSuccess 431 440 379 323
30072 pmTotNoRrcConnectReq 140 139 122 134
30072 pmTotNoRrcConnectReqSuccess 140 139 122 134
30073 pmTotNoRrcConnectReq 495 505 441 449
30073 pmTotNoRrcConnectReqSuccess 495 496 437 449
30081 pmTotNoRrcConnectReq 881 957 1014 927
30081 pmTotNoRrcConnectReqSuccess 877 953 1013 926
30082 pmTotNoRrcConnectReq 0 0 0 0
30082 pmTotNoRrcConnectReqSuccess 0 0 0 0
30083 pmTotNoRrcConnectReq 0 0 0 0
30083 pmTotNoRrcConnectReqSuccess 0 0 0 0
30091 pmTotNoRrcConnectReq 434 329 347 283
30091 pmTotNoRrcConnectReqSuccess 432 331 347 281
30092 pmTotNoRrcConnectReq 495 463 465 430
30092 pmTotNoRrcConnectReqSuccess 494 462 466 430
30093 pmTotNoRrcConnectReq 344 339 282 415
30093 pmTotNoRrcConnectReqSuccess 342 339 282 415
30101 pmTotNoRrcConnectReq 92 85 97 76
30101 pmTotNoRrcConnectReqSuccess 91 84 96 75
30102 pmTotNoRrcConnectReq 93 87 108 77
30102 pmTotNoRrcConnectReqSuccess 92 87 108 76
30103 pmTotNoRrcConnectReq 103 91 102 110
30103 pmTotNoRrcConnectReqSuccess 105 92 103 111
actually i want to get the log like this :
Quote:
Object Percentage
------------------------------
30011 xx %
30012 xx %
30013
30021
30022
30023
30031
30032
30033
30041
30042
30043
30051
30052
30053
30061
30062
30063
30071
30072
30073
30081
30082
30083
30091
30092
30093
30101
30102
30103
where % can get from :
100 * pmTotNoRrcConnectReqSucc / pmTotNoRrcConnectReq
Thanks in advance..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
how would you calculate percentage by per line? Given a column of 16 lines, grab each line and divide it by the sum of the entire column and multiply by 100?
thanks ... (8 Replies)
Discussion started by: rockiefx
8 Replies
2. Shell Programming and Scripting
Hi
I need a awk script to calculate percentage.
I have to pass the pararmeters in to the awk script and calculate the percentage.
Sum = 50
passed = 43
failed = 7
I need to pass these value in to the awk script and calculate the percentage.
Please advice me. (8 Replies)
Discussion started by: bobprabhu
8 Replies
3. Shell Programming and Scripting
I need a scripting AWK to compare 2 files.
file 1 and 2 are list of keywords
1 is
a
b
c
d
2 is
aa
aaa
b
bb
ccc
d
I want the AWK script to give us the number of times every keyword in file 1 occurs in file 2.
output should be
a 2 (7 Replies)
Discussion started by: anhtt
7 Replies
4. Shell Programming and Scripting
Need an awk script to calculate the percentage of value field and replace
I have a input file called file.txt with the following content:
john|622.5674603562933|8|br:1;cn:3;fr:1;jp:1;us:2
andy|0.0|12|**:3;br:1;ca:2;de:2;dz:1;fr:2;nl:1
in fourth filed of input file, calulate percentage of each... (1 Reply)
Discussion started by: veeruasu
1 Replies
5. UNIX for Dummies Questions & Answers
I have a input file called file.txt with the following content:
john|622.5674603562933|8|br:1;cn:3;fr:1;jp:1;us:2
andy|0.0|12|**:3;br:1;ca:2;de:2;dz:1;fr:2;nl:1
in fourth filed of input file, calulate percentage of each sub filed seperated by ; semicolon and replace value with percentage .
i... (11 Replies)
Discussion started by: veeruasu
11 Replies
6. Shell Programming and Scripting
Hi,
I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1).
Input:
919143110065
919143110065
919143110052
918648846132
919143110012
918648873782
919143110152
919143110152
919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies
7. Shell Programming and Scripting
Hi,
Am trying to count the number of occurrences and then as a percentage from a log to troubleshoot errors, can someone help please
grep -o 'HTTP/1\.1\" 404 3..' access_log | wc -l
6 (5 Replies)
Discussion started by: dmccabe
5 Replies
8. Shell Programming and Scripting
i have a file say test with the below mentioned details
Folder Name Total space Space used
/test/test1 500.1GB 112.0 GB
/test/test2 3.2 TB 5TB
/test/test3 3TB 100GB
i need to calculate percentage of each row based on total space and space used and copy... (9 Replies)
Discussion started by: venkitesh
9 Replies
9. Shell Programming and Scripting
Hello, can someone guide me on this?
I don't know what is the best approach, (awk script, shell script)
I am using RedHat Linux version 6.5. There is a third party application deployed on that server. This app by default generates 5 log files and each file is 20MB. These log rollover... (5 Replies)
Discussion started by: ktisbest
5 Replies
10. HP-UX
having two columns, A and B.. i need to add another column C in a file and calculate the percentage based on the column A and B. (COLUMN B/ COLUMN A *100) . "|" is delimiter separating the A and B.. need C column with the percentage value. Thanks for your help
100|50 |50% ... (6 Replies)
Discussion started by: kartikirans
6 Replies