-
Notifications
You must be signed in to change notification settings - Fork 6
/
rexec-summary.awk
executable file
·73 lines (61 loc) · 1.18 KB
/
rexec-summary.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/awk -f
# A log parser for rset(1) parallel workers
# Displays a summary of each session
# fields:
# $1 session ID
# $2 timestamp
# $3 execution stage
# $4 label or hostname
# $5 error code
function max(a, b) {
if (a > b) return a
return b
}
BEGIN {
if (ARGC < 2) {
print "release: ${release}" > "/dev/stderr"
print "usage: rexec-summary file [file ...]" > "/dev/stderr"
exit 1
}
FS = "|"
}
NF != 5 {
next
}
/^[0-9a-f]{8}/ {
if ($3=="HOST_CONNECT_ERROR")
connect_error[$1]++
if ($3=="HOST_CONNECT")
connect[$1]=$4
if ($3=="EXEC_BEGIN")
exec_begin[$1]++
if ($3=="EXEC_END")
exec_end[$1]++
if ($3=="EXEC_ERROR")
exec_error[$1]++
logfile[$1] = FILENAME
}
END {
# determine the width of the hostname column
len = 8
for (id in connect)
len = max(len, length(connect[id]))
entries = 0
for (id in connect) {
entries++
printf("%s %-"len+2"s", id, connect[id])
if (connect_error[id] > 0) {
printf("connect fail")
}
else {
printf("%d/%d complete", exec_end[id], exec_begin[id])
}
printf(" >> " logfile[id])
printf("\n")
}
# rewind
if (ARGV[ARGC-1] != "/dev/null") {
printf("\033[%dA", entries)
fflush(stdout)
}
}