-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcollect_storage_data.sh
129 lines (108 loc) · 2.64 KB
/
collect_storage_data.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
CURR=`dirname $0`
BOOT=$CURR/../bootstrap
MINER1=$CURR/../miner1
MINER2=$CURR/../miner2
TEST=$CURR/../testnode
# Get the block number
BLOCKNUM=`node getBlockNumber.js`
echo $BLOCKNUM
# Add a comma if this isn't the first entry
if [ -a storage.json ]; then
echo "," >> storage.json
fi
# Create new JSON object with blocknum as key
echo -n "\"$BLOCKNUM\": " >> storage.json
echo "{" >> storage.json
echo
# Bootstrap storage info
echo "$CURR/bootstrap"
echo -n "\"bootstrap\": " >> storage.json
echo "*****************************"
# Get list of file sizes
B=`ls -lh --block-size=KB $BOOT/geth/*/ | awk '{print $5}'`
echo $B
# The following creates a json array of the storage
# taken up by the node
TEMP=""
echo "[ " >> storage.json
echo -n " " >> storage.json
for s in $B; do
if [ ! -z $TEMP ]; then
echo -n "\"$TEMP\", " >> storage.json
fi
TEMP=$s
done
if [ ! -z $TEMP ]; then
echo "\"$TEMP\"" >> storage.json
fi
echo "]," >> storage.json
echo "*****************************"
echo
echo "$CURR/miner1"
echo -n "\"miner1\": " >> storage.json
echo "*****************************"
M1=`ls -lh --block-size=KB $MINER1/geth/*/ | awk '{print $5}'`
echo $M1
# The following creates a json array of the storage
# taken up by the node
TEMP=""
echo "[ " >> storage.json
echo -n " " >> storage.json
for s in $M1; do
if [ ! -z $TEMP ]; then
echo -n "\"$TEMP\", " >> storage.json
fi
TEMP=$s
done
if [ ! -z $TEMP ]; then
echo "\"$TEMP\"" >> storage.json
fi
echo "]," >> storage.json
echo "*****************************"
echo
echo "$CURR/miner2"
echo -n "\"miner2\": " >> storage.json
echo "*****************************"
M2=`ls -lh --block-size=KB $MINER2/geth/*/ | awk '{print $5}'`
echo $M2
# The following creates a json array of the storage
# taken up by the node
TEMP=""
echo "[ " >> storage.json
echo -n " " >> storage.json
for s in $M2; do
if [ ! -z $TEMP ]; then
echo -n "\"$TEMP\", " >> storage.json
fi
TEMP=$s
done
if [ ! -z $TEMP ]; then
echo "\"$TEMP\"" >> storage.json
fi
echo "]," >> storage.json
echo "*****************************"
echo
echo "$CURR/testnode"
echo -n "\"testnode\": " >> storage.json
echo "*****************************"
TST=`ls -lh --block-size=KB $TEST/geth/*/ | awk '{print $5}'`
echo $TST
# The following creates a json array of the storage
# taken up by the node
TEMP=""
echo "[ " >> storage.json
echo -n " " >> storage.json
for s in $TST; do
if [ ! -z $TEMP ]; then
echo -n "\"$TEMP\", " >> storage.json
fi
TEMP=$s
done
if [ ! -z $TEMP ]; then
echo "\"$TEMP\"" >> storage.json
fi
echo "]" >> storage.json
echo "*****************************"
# End the JSON object with key $BLOCKNUM
echo "}" >> storage.json