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