Hi all,
i have written this script:
Code:
awk -F';' '
BEGIN {
printf "\n"
printf "\n"
printf "\n"
printf "----------------------------------------------\n"
print " For test "
printf "----------------------------------------------\n"
test_200 = 0
test_300 = 0
test_500 = 0
test_1000 = 0
test_nok = 0
test_ok = 0
}
$5 == 200.0 {test_200++}
$5 == 300.0 {test_300++}
$5 == 500.0 {test_500++}
$5 == 1100.0 {test_1000++}
$6 !~ /SUCCESS/ {test_nok++}
$6 ~ /SUCCESS/ {test_ok++}
{count[$6]++}
NF>5&&!a[$6,$2]++{e[$6]++}
END {
for(j in count) printf "%-30s %-6d\n", j, count[j]
print ""
printf "%-30s %-6d\n", "test 200 ", test_200
printf "%-30s %-6d\n", "test 300 ", test_300
printf "%-30s %-6d\n", "test 500 ", test_500
printf "%-30s %-6d\n", "test 1000 ", test_1000
printf "\n"
printf "---------------------------------------------------\n"
printf "%-30s %-6d\n", "test unsuccessful ", test_nok
printf "%-30s %-6d\n", "test successful ", test_ok
printf "---------------------------------------------------\n"
for (i in e) printf "%-30s %-6d\n", i, e
}
' cdr
in order to process these logs:
Code:
25-04-2012;192.168.70.44;1254545454545110;300.0;SUCCESS
25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS
30-04-2012;192.168.70.33;e;null;null;General_ERROR_23
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-201;192.168.70.34;e;null;null;ERROR_22
30-04-2012;192.168.70.37;e;null;null;INVALID_NUMBER
30-04-2012;192.168.70.10;e;null;null;Failure
30-04-2012;192.168.70.20;1254545454125417;1100.0;SUCCESS
The script works ok, but i want to format the output.
I want the output to be like this(2 tables, with headers and columns):
Code:
*******************************************
Message name | Number of errors | Numbers of unique IPs
*******************************************
Failure ----------------5 ------------------2----------
ERROR_22
INVALID_NUMBER
SUCCESS
*******************************************
test_200 | test_300 | test_500 | test_1000
*******************************************
0 --------------1---------1------------ 0
etc etc....
I want everything to be formated in some way.
Maybe my script need also some improvement except formatting...i dont know.
Please, take a look at my script, i really need this for my work.
Thank you in advance,
i have written this script:
Code:
awk -F';' '
BEGIN {
printf "\n"
printf "\n"
printf "\n"
printf "----------------------------------------------\n"
print " For test "
printf "----------------------------------------------\n"
test_200 = 0
test_300 = 0
test_500 = 0
test_1000 = 0
test_nok = 0
test_ok = 0
}
$5 == 200.0 {test_200++}
$5 == 300.0 {test_300++}
$5 == 500.0 {test_500++}
$5 == 1100.0 {test_1000++}
$6 !~ /SUCCESS/ {test_nok++}
$6 ~ /SUCCESS/ {test_ok++}
{count[$6]++}
NF>5&&!a[$6,$2]++{e[$6]++}
END {
for(j in count) printf "%-30s %-6d\n", j, count[j]
print ""
printf "%-30s %-6d\n", "test 200 ", test_200
printf "%-30s %-6d\n", "test 300 ", test_300
printf "%-30s %-6d\n", "test 500 ", test_500
printf "%-30s %-6d\n", "test 1000 ", test_1000
printf "\n"
printf "---------------------------------------------------\n"
printf "%-30s %-6d\n", "test unsuccessful ", test_nok
printf "%-30s %-6d\n", "test successful ", test_ok
printf "---------------------------------------------------\n"
for (i in e) printf "%-30s %-6d\n", i, e
}
' cdr
in order to process these logs:
Code:
25-04-2012;192.168.70.44;1254545454545110;300.0;SUCCESS
25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS
30-04-2012;192.168.70.33;e;null;null;General_ERROR_23
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-201;192.168.70.34;e;null;null;ERROR_22
30-04-2012;192.168.70.37;e;null;null;INVALID_NUMBER
30-04-2012;192.168.70.10;e;null;null;Failure
30-04-2012;192.168.70.20;1254545454125417;1100.0;SUCCESS
The script works ok, but i want to format the output.
I want the output to be like this(2 tables, with headers and columns):
Code:
*******************************************
Message name | Number of errors | Numbers of unique IPs
*******************************************
Failure ----------------5 ------------------2----------
ERROR_22
INVALID_NUMBER
SUCCESS
*******************************************
test_200 | test_300 | test_500 | test_1000
*******************************************
0 --------------1---------1------------ 0
etc etc....
I want everything to be formated in some way.
Maybe my script need also some improvement except formatting...i dont know.
Please, take a look at my script, i really need this for my work.
Thank you in advance,