Need help in logic


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help in logic
# 1  
Old 09-11-2008
Need help in logic

I have big large snapshot file which contains every process start time and end time. One server snapshot contains many Application handle. My task is to identify the process id for which the end time is not there or empty also if the completion time is not on the same date then I need to kill.

The process is noted in the log file like “Application handle = 189” and the 14th and 15th line contains the time stamp like

Connection request start timestamp = 06/11/2008 02:56:45.952566
Connect request completion timestamp = 06/11/2008 02:56:45.954183

Please suggest some logic for this.

I think I need to separate the file in pieces by the searching the string Application handle, then using awk take the start time and compared to end time.

Thanks,
Senthilkumar
# 2  
Old 09-11-2008
Please post the log for a couple of "Application handle" worth of lines.
# 3  
Old 09-11-2008
I have attached the complete file.
# 4  
Old 09-14-2008
jim,

do you need any more information..?
# 5  
Old 09-14-2008
Try this:

Code:
awk '{
if ($0 ~/^Connection request start/) st=$(NF -1);
if ($0 ~ /^Connect request completion /) et=$(NF -1);
if ($0 ~ /^Process ID of client /) {
 if (st != et)print st" "et " PID="$NF;
}  }'  snapshot_file

# 6  
Old 09-14-2008
There might be several ways of doing this, probably by simply counting lines and predicting where the "Connection request*" and "Process ID*" lines are.

My logic for this solution is storing every line into an $app var and when I find /Application Snapshot/ and I'm not on the first line or it's the EOF (END {}), I process $app which contains all the lines referring to the "last" application entry. So after processing I could choose to print $app or not ...

Code:
perl -ne 'BEGIN { sub analyze { $app =~ /Connection request.*?=\s(.*?)\n.*?Process ID.*?=(.*?)\n/sg;  print "$1 $2\n"; $app = "";  } } if (/Application Snapshot/ and $app !~ /^$/) { analyze(); } else { $app .= $_; } END { analyze(); }' samplesnapshot.txt

In print "$1 $2\n"; $app = ""; It could have something like if ($1 something and $2 something) { print $app; } $app = "";
Thus only printing $app if the requirement fits the need.
# 7  
Old 09-17-2008
dennis, this give me the Process ID but i want the first line Application Handle
 
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

If Then Else Logic

I am obviously new to Unix Script writing, and I think I am trying to do this in SQL when im not in a SQL environment. What I need to do is the following EXTRACT_ROW_COUNT=`grep Number $REFERENCE_LOG"extract_concern.log" | sed '/Number of rows exported:/s/.*:*\(*\)$/\1/'` LOADED_ROW_COUNT=`db2... (7 Replies)
Discussion started by: jadionne
7 Replies
Login or Register to Ask a Question