-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitolite
executable file
·77 lines (67 loc) · 1.34 KB
/
gitolite
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
74
75
76
77
#!/usr/bin/env bash
# The contents of the log file are given in stdin.
cat /dev/stdin | awk '
function alen(a, i,j) {
j = 0
for( i in a) {
j++
}
return j
}
function print_array(arr, title, i) {
if( alen(arr) > 0 ) {
printf("%s\n======================\n", title)
for(i=0;i<alen(arr);++i) {
printf(" %s\n", arr[i+1])
}
printf("\n")
}
}
BEGIN {
# Fields are separated via \t
FS = "\t"
# count transactions
transactions = 0
# set variable for storing tid
last_tid = ""
}
# record warnings and errors
{
string = $1 " " $4
if( $3 == "warn" ) {
warnings[alen(warnings)+1] = string
} else if( $3 == "die" ) {
errors[alen(errors)+1] = string
}
}
# record created repos
{
if( $3 == "create" ) {
created_repos[alen(created_repos)+1] = $5 " created " $4 " (" $6 ")"
}
}
# count tids
{
if( $2 != last_tid ) {
++transactions;
last_tid=$2
}
}
# record transaction ips
{
if( $3 == "ssh" || $3 == "http") {
ips[$6]++
}
}
# print results
END {
print_array(errors, " ! ERRORS ! ")
print_array(warnings, " warnings")
print_array(created_repos, " created repos")
printf(" transactions\n======================\n")
for(ip in ips) {
printf(" %-5s%s\n", ips[ip], substr(ip, 6))
}
printf("----------------------\n %-5d%s\n", transactions, "total")
}
'