-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_stat.sh
65 lines (61 loc) · 1.09 KB
/
node_stat.sh
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
#!/bin/bash
awk '
function toDatetime(data, ret)
{
ret=mktime(substr(data, 1, 4) " " substr(data, 5, 2) " " substr(data, 7, 2) " " substr(data, 9, 2) " " substr(data, 11, 2) " " substr(data, 13, 2) );
return ret;
}
function min(arr, rowsize, name, ret)
{
first=0
for(i=1; i<=rowsize; i++)
{
#print arr[i, name]
if(arr[i, name] == "") continue;
if(first==0)
{
ret=arr[i, name];
first=1
}
if(ret > arr[i, name])
{
ret=arr[i, name];
}
}
return ret;
}
function max(arr, rowsize, name, ret)
{
first=0
for(i=1; i<=rowsize; i++)
{
#print arr[i, name]
if(arr[i, name] == "") continue;
if(first==0)
{
ret=arr[i, name];
first=1
}
if(ret < arr[i, name])
{
ret=arr[i, name];
}
}
return ret;
}
# Load all fields of each record into recs.
BEGIN{FS="[{},:\"]+"}
{
totalcol=0
for (i = 3; i <= NF; i+=2)
{
recs[NR, $(i-1)] = $i;
totalcol+=1;
}
totalrow+=1;
}
END {
print min(recs, totalrow, "pc");
print max(recs, totalrow, "pc");
#print recs[1, "pc"]
}' $1