Hi All, i believe this is not very efficient. another method would be appreciated for these. basically i read a file with tab delimited column and pass the column to another perl script.
while read line
do
timestamp=`echo "$line"|awk -F"\t" '{print $1}'`
severity=`echo "$line"|awk -F"\t" '{print $2}'`
server=`echo "$line"|awk -F"\t" '{print $5}'`
message=`echo "$line"|awk -F"\t" '{print $4,$8}'`
converter.pl -r MS_OVO_PROXY -c "$severity" -t T -i ORA_PERF_ALERT -h "$server" -e ORA -m "$messsage"
done < /opt/application.log
exit 0
while read TIME SEV x MESS1 SERV x x MESS2 junk; do
converter.pl -r MS_OVO_PROXY -c "$SEV" -t T -i ORA_PERF_ALERT -h "$SERV" -e ORA -m "$MESS1 $MESS2"
done < file
thanks for the suggestion, yeah thought so, is there an alternative using all using awk? i forgot to mention that the column exceeds $9 it reaches around 19 columns
i can get the column using below but i dont know how to pass it to converter.perl.
looks like while loop is much efficient in this case. im actually learning awk so im figuring out how to do this via awk but i guess i should stick to while loop in this case then. thanks
---------- Post updated at 06:29 PM ---------- Previous update was at 06:20 PM ----------
The tab delimiter was ignored, it opted to use space delimiter instead via while loop
actually there are many spaces in the input file so i will need to work on using tabs. see 1 line sample below.
2013/08/07 05:07:38:642 CRITICAL Oracle Oracle:server.ecs.testpoc.com:Customer D: Oracle Database Server 11G - Basic:Database Counter: Instance Status server.ecs.testpoc.com Metric 'Alert has no defined Metric' changed status from 'good' to 'error' Metric 'Alert has no defined Metric' crossed 'back to default' with value 'null' DatabaseCounter Alert has no defined Metric server.ecs.testpoc.com:287a96af-9af1-4431-b689-e1293f612786:Alert has no defined Metric::CRITICAL server.ecs.testpoc.com:287a96af-9af1-4431-b689-e1293f612786:Alert has no defined Metric CiHint:@@server.ecs.testpoc.com ::null Oracle@@server.ecs.testpoc.com http://server.ecs.testpoc.com:8080/Oracle/servlet/Main?activeid=200708448&activerighttop=dashboard&view=new&dashboard_view=Details&dashboard_model=true&sis_silent_login_type=encrypted&login=%28sisp%29knjxbqDESkAn5mKcvgTmj%2FyFwHH5Ke3m%0D%0A&password=%28sisp%29EzqXbIXEFD%2BJbE1N1T%2FZlELjja0DKaN7%0D%0A OracleMonitor:OracleDatabaseServer11GBasic:200708448 1
This actually breaks while loop limit which can accept 9 variables.
nah, i cant do that the error messages will have variable spacing in them, especially for long or short error messages. so the only way is to delimit using tabs.
---------- Post updated at 07:03 PM ---------- Previous update was at 06:44 PM ----------
none of the above works, tried with IFS="\t", literal tab control v and control i. hmmm
[oracle@server logs]$ head -1 /opt/application.log | awk 1 RS='\t'
2013/08/07 04:48:36:685
NORMAL
Oracle
Oracle:server.testpoc.com:Health:Connection Statistics Monitor
server.testpoc.com
Metric 'SSH connections. Total failed to open V2' changed status from 'warning' to 'good'
Metric 'SSH connections. Total failed to open V2' crossed 'back to default' with value '0'
Connection Statistics Monitor
SSH connections. Total failed to open V2
server.testpoc.com::SSH connections. Total failed to open V2:Unknown:NORMAL
server.testpoc.com::SSH connections. Total failed to open V2
CiHint:@@server.testpoc.com
Unknown:Unknown:0
Oracle@@server.testpoc.com
Oracle:server.testpoc.com:SSH connections. Total failed to open V2
http://server.testpoc.com:8080/Oracle/servlet/Main?activeid=10006&activerighttop=dashboard&view=new&dashboard_view=Details&dashboard_model=true&sis_silent_login_type=encrypted&login=%28sisp%29knjxbqDESkAn5mKcvgTmj%2FyFwHH5Ke3m%0D%0A&password=%28sisp%29EzqXbIXEFD%2BJbE1N1T%2FZlELjja0DKaN7%0D%0A
OracleMonitor:__Health__:10006
1
[oracle@server logs]$
im echoing first column
while IFS=" " read line timestamp severity x msg1 server y z msg2
do
message="$msg1 $msg2"
echo "$timestamp"
done < /opt/application.log
exit 0
[oracle@server logs]$ ./Log_converter.sh
NORMAL
NORMAL
MINOR
MINOR
NORMAL
NORMAL
CRITICAL
NORMAL
NORMAL
NORMAL
NORMAL
CRITICAL
CRITICAL
NORMAL
CRITICAL
MINOR
NORMAL
MINOR
MINOR
CRITICAL
MINOR
CRITICAL
NORMAL
NORMAL
CRITICAL
NORMAL
NORMAL
NORMAL
NORMAL
CRITICAL
CRITICAL
[oracle@server logs]$
while IFS=" " read timestamp severity x msg1 server y z msg2 junk; do
...
done
$ cat -n args.txt
1 2013/08/07 04:48:36:685
2 NORMAL
3 Oracle
4 Oracle:server.testpoc.com:Health:Connection Statistics Monitor
5 server.testpoc.com
6 Metric 'SSH connections. Total failed to open V2' changed status from 'warning' to 'good'
7 Metric 'SSH connections. Total failed to open V2' crossed 'back to default' with value '0'
8 Connection Statistics Monitor
9 SSH connections. Total failed to open V2
10 server.testpoc.com::SSH connections. Total failed to open V2:Unknown:NORMAL
11 server.testpoc.com::SSH connections. Total failed to open V2
12 CiHint:@@server.testpoc.com
13 Unknown:Unknown:0
14 Oracle@@server.testpoc.com
15 Oracle:server.testpoc.com:SSH connections. Total failed to open V2
16 http://server.testpoc.com:8080/Oracle/servlet/Main?activeid=10006&activerighttop=dashboard&view=new&dashboard_view=Details&dashboard_model=true&sis_silent_login_type=encrypted&login=%28sisp%29knjxbqDESkAn5mKcvgTmj%2FyFwHH5Ke3m%0D%0A&password=%28sisp%29EzqXbIXEFD%2BJbE1N1T%2FZlELjja0DKaN7%0D%0A
17 OracleMonitor:__Health__:10006
18 1