source: tags/libIGCM_v1/libIGCM_sys/IGCM_analyse_rsync_out.awk @ 1456

Last change on this file since 1456 was 2, checked in by mmaipsl, 16 years ago

MM: import first trunk version of libIGCM.

File size: 2.5 KB
Line 
1#!/usr/bin/awk -f
2# IGCM_analyse_rsync_out - filter rsync output in a job output :
3# command :
4# IGCM_analyse_rsync_out.awk [-d] job_output.out
5
6
7#**************************************************************
8# Author: Martial.Mancip
9# Contact: Martial.Mancip_ipsl.jussieu.fr
10# $Date: 2006/12/21 20:51:49 $
11# $Name: libIGCM_v1 $
12# $Revision: 1.2 $
13# IPSL (2006)
14#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
15# History:
16# Modification:
17#
18#**************************************************************
19
20#==========================
21function myprint(str) {
22  if (debug) {
23     print str
24  }
25}
26
27
28#==========================
29BEGIN {
30#  print "traitement de " ARGV[1]
31
32  nbarg=ARGC
33
34  if (match(ARGV[1],"-d")) {
35    debug=1
36    file=ARGV[2]
37    delete ARGV[1] 
38    nbarg--
39  } else {
40    debug=0
41    file=ARGV[1]
42  }
43
44  exit_value=0
45  if (nbarg != 2) {
46        print "Usage: analyse_rsync_out.awk [-d] file"
47        exit_value=-1
48        exit
49  }
50   
51  rsync_found=0
52  speedup_found=0
53  counter=0
54  thisfile[1]=""
55  errcounter=0
56  errorfile[1]=""
57}
58
59#==========================
60{
61
62  myprint($0) 
63
64  if (rsync_found == 0 && match($0, ".*/rsync .*")) {
65    speedup_found = 0
66    rsync_found=1
67    counter=counter+1
68
69    nb=split($0,felts, " ")
70    myprint("nb  :" nb)
71    for (elt in felts) {
72        myprint(elt "- elt  :" felts[elt])
73    }
74    myprint("elts_split  :" felts[4])
75
76    thisfile[counter]=felts[4]
77  }
78  else if (rsync_found == 1 && match($0, ".* speedup is .*")) {
79    myprint("speedup_found = 1")
80    speedup_found = 1
81  }
82  else if (speedup_found == 1 && match($0, "rsync error:.*")) {
83    errcounter=errcounter+1
84    errorfile[errcounter]=thisfile[counter]
85    myprint("=============================================")
86    myprint("WARNING : Rsync ERROR for " ARGV[1])
87    myprint("counter  :" counter)
88    myprint("file  :" thisfile[counter])
89    thisfile[counter]=""
90    counter=counter-1
91  } 
92  else {
93    if ( speedup_found == 1 ) {
94      rsync_found=0
95      speedup_found=0
96    }
97  }
98}
99
100#==========================
101END {
102  if ( exit_value != -1 ) {
103
104    myprint("=============================================")
105    myprint("Rsync for " ARGV[1])
106    myprint("counter  :" counter)
107    for (i=1; i<=counter; i++) { 
108      myprint("file  :" thisfile[i])
109    }
110    if (errcounter > 0) {
111      debug=1
112      myprint("Error counter  :" errcounter)
113      for (i=1; i<=errcounter; i++) { 
114        myprint("Error file  :" errorfile[i])
115      }
116      exit_value=errcounter
117      print exit_value
118      exit exit_value
119    } 
120    exit_value=0
121    exit 0
122  }
123}
Note: See TracBrowser for help on using the repository browser.