Operating System - HP-UX
1748136 Members
3514 Online
108758 Solutions
New Discussion

Re: some help needed for scripting

 
SOLVED
Go to solution
zxcv
Super Advisor

some help needed for scripting

Hi ,

 

pfa my file which contains many jobs.

my reqmnt is to print all o/p from SY3100 . i.e start and end timings .

it also must print only single entries and no duplicate entries.

15 REPLIES 15
Dennis Handly
Acclaimed Contributor

Re: some help needed for scripting

It appears you can just use grep:  grep SY3100 file

 

I only see the Start and End lines, no duplicates to handle.

 

rariasn
Honored Contributor

Re: some help needed for scripting

Hi:

 

$ grep SY3100 smartlog.20120117 | uniq -n

 

rgs

Riccardo_Marini
Regular Visitor

Re: some help needed for scripting

try this :

grep SY3100 FILENAME |awk '/Start|End/ { {printf "%s : %s %s %s %s %s %s ",$2,$6,$7,$8,$9,$10,$11  } ;  if ( $2 == "End")  {printf "\n"  } }' |sort -u

 

zxcv
Super Advisor

Re: some help needed for scripting

Hi guys,

Really sorry for not making my reqmnt clean.

i want to grep start and end timings from this file along with jobs name for ex sy3100

it shold give me o/p like, it sould subtract timings

job name   time taken

sy3100         20 min

 

Also if i have multistreams A,B,C,D it should display the max time taken for that job.

Dennis Handly
Acclaimed Contributor

Re: some help needed for scripting

>I want to grep start and end timings from this file along with jobs name for ex sy3100

>sy3100         20 min

 

Do you want it to do ALL jobs in the file or just the one selected?

 

>if I have multistreams A,B,C,D it should display the max time taken for that job.

 

What do you mean by "multistreams"?

zxcv
Super Advisor

Re: some help needed for scripting

Hi Dennis ,

PFA file from which i want all jobs, after this specific  job SY3100 with total time taken

i.e end time - start time .

 

the o/p should be like ;

 

SY3100   0 sec/min

 

 

zxcv
Super Advisor

Re: some help needed for scripting

Hi Dennis ,

 

I hope my reqmnt is clear now.

i just need a hint to subtract time.

Dennis Handly
Acclaimed Contributor

Re: some help needed for scripting

>I hope my requirement is clear now.

 

I still don't know what multistreams are?

 

>I just need a hint to subtract time.

 

# subtract times
# Tue Jan 17 21:56:18 IST 2012 End: Tue Jan 17 21:56:18 IST 2012
grep sy3100 smartlog.20120117.txt |
  awk '
# day of month, HH:MM:SS (24 hour clock)
function convert_to_secs(day, hhmmss) {
#   print day, hhmmss
   split(hhmmss, t_hhmmss, ":")
   return (((day - 1) * 24 + t_hhmmss[1]) * 60 + t_hhmmss[2]) * 60 +  t_hhmmss[3]
}
BEGIN {
   print "job name   time"
}
$2 == "Start" {
   yyyymmmddzz[$4] = $7 $11 $10  # check for unhandled date straddling
   start_time[$4] = convert_to_secs($8, $9)
   next
}

$2 == "End" {
   if (yyyymmmddzz[$4] == "") {
      print "Cannot find Start time for", $4
      next
   }
   stop_yyyymmmddzz = $7 $11 $10  # check for unhandled date straddling
   if (stop_yyyymmmddzz != yyyymmmddzz[$4]) {
      print "Start/stop for", $4", straddles complex date boundary",  stop_yyyymmmddzz
   }
   stop_time = convert_to_secs($8, $9)
#   printf "%s: %d\n", $4, start_time[$4]
#   printf "%s: %d\n", $4, stop_time
   printf "%-12s %.1f min\n", $4, (stop_time - start_time[$4]) / 60
   next
}'

 

This doesn't handle the case where the times span month boundaries.  It does detect it.

zxcv
Super Advisor

Re: some help needed for scripting

Hi Dennis ,

 

After grepping the required pattern from logfile  m  getting ;

 

GB_PROD /home//sysout > grep "IN0800" smartlog.??????.txt
*** Start of  IN0800A  at  Mon Nov 28 15:21:22 IST 2011
*** End   of  IN0800A  at  Mon Nov 28 15:21:24 IST 2011  - RC =  0
*** Start of  IN0800B  at  Mon Nov 28 15:21:27 IST 2011
*** End   of  IN0800B  at  Mon Nov 28 15:21:29 IST 2011  - RC =  0
*** Start of  IN0800C  at  Mon Nov 28 15:21:32 IST 2011
*** End   of  IN0800C  at  Mon Nov 28 15:21:33 IST 2011  - RC =  0
*** Start of  IN0800D  at  Mon Nov 28 15:21:37 IST 2011
*** End   of  IN0800D  at  Mon Nov 28 15:21:38 IST 2011  - RC =  0
*** Start of  IN0800E  at  Mon Nov 28 15:21:42 IST 2011
*** End   of  IN0800E  at  Mon Nov 28 15:21:44 IST 2011  - RC =  0
*** Start of  IN0800F  at  Mon Nov 28 15:21:47 IST 2011
*** End   of  IN0800F  at  Mon Nov 28 15:21:48 IST 2011  - RC =  0
*** Start of  IN0800G  at  Mon Nov 28 15:21:52 IST 2011
*** End   of  IN0800G  at  Mon Nov 28 15:21:53 IST 2011  - RC =  0
*** Start of  IN0800H  at  Mon Nov 28 15:21:57 IST 2011
*** End   of  IN0800H  at  Mon Nov 28 15:21:58 IST 2011  - RC =  0

==========================================================

I tried running that time function ;

 

i got o/p as ;

 

job name   time
IN0800A      0.0 min
IN0800B      0.0 min
IN0800C      0.0 min
IN0800D      0.0 min
IN0800E      0.0 min
IN0800F      0.0 min
IN0800G      0.0 min
IN0800H      0.0 min

I understand some column paramters needs to be edited ,new to scripting .

Any more help  would be great.

Thanks .