-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmonitor
More file actions
executable file
·230 lines (207 loc) · 6.74 KB
/
monitor
File metadata and controls
executable file
·230 lines (207 loc) · 6.74 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
if [[ "$1" == "health" ]]
then
function="health"
shift
fi
RIPPLED=${1:-$( dirname $0 )/rippled}
RPC_IP=${2:-127.0.0.1}
RPC_PORT=${3:-5015}
PEER_PORT=${4:-51235}
shift 4
unset LAST_LEDGER_FILE
if [[ $# -gt 0 ]]
then
if [[ -f "${1}" ]]
then
LAST_LEDGER_FILE="${1}"
shift
else
echo "File not found: ${1}"
exit 1
fi
fi
rd()
{
${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} "$@"
}
if [[ "${function}" == "health" ]]
then
set -e
output=$( mktemp )
rd server_info > "${output}"
cat "${output}" | jq '.result.info | {
server_state,
build_version,
peers,
validated_ledger_age: .validated_ledger.age,
validated_ledger_seq: .validated_ledger.seq,
validated_ledger_hash: .validated_ledger.hash,
complete_ledgers,
load_factor,
last_close_time_s: .last_close.converge_time_s,
peer_disconnects
}' || ( c=$? && gvim "${output}" && exit $c )
rd consensus_info > "${output}"
cat "${output}" | jq '.result.info |
{
acquired: (.acquired // []) | length,
close_resolution, converge_percent,
disputes: (.disputes // []) | length,
active_disputes: (.disputes // []) |
map_values(select(.yays > 0 and .nays > 0)) | length,
have_time_consensus, ledger_seq,
peer_positions: (.peer_positions // []) | length,
phase, current_ms, previous_mseconds, previous_proposers,
proposers, proposing, synched, validating
}' || ( c=$? && gvim "${output}" && exit $c )
rd peers > "${output}"
cat "${output}" | jq \
'.result.peers | {
peer_count: .| length
} +
(
[.[] | {address, latency}]
| {
worst_peer: . | max_by(.latency),
best_peer: . | min_by(.latency),
}
) +
(
[.[] | {version}]
| {
versions: . | group_by(.version) |
map({key: .[0].version, value: length}) |
from_entries
}
)' || ( c=$? && gvim "${output}" && echo $c )
rd get_counts > "${output}"
cat "${output}" | jq '.result | {
dbKBTotal,
ledger_hit_rate,
AL_hit_rate,
write_load,
node_reads_total,
node_writes
}'
rd validators > "${output}"
cat "${output}" | jq -S \
'.result | { publisher_lists: .publisher_lists |
map(. + {size: (.list // []) | length} | del(.list)),
trusted_validator_keys: (.trusted_validator_keys // []) | length,
validation_quorum, validator_list
}' || ( c=$? && gvim "${output}" && echo $c )
rm -f "${output}"
rd feature > "${output}"
cat "${output}" | jq -S \
'.result.features |
map(
select(.enabled == false and .supported == true and
.vetoed != "Obsolete") | {key: .name, value: .count}
) | from_entries'
exit
fi
#
# echo $RIPPLED $RPC_PORT $PEER_PORT
if type -t tmux >& /dev/null
then
if tmux attach -t monitor
then
exit
fi
tmuxcommand=( tmux new-window -d -a -t monitor:$ )
if [[ -z "${TMUX}" ]]
then
cmd=( tmux new-session -d -s monitor -n sleep sleep 60 )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
fi
cmd=( "${tmuxcommand[@]}"
-n health
watch -d "$0 health ${RIPPLED} ${RPC_IP} ${RPC_PORT} ${PEER_PORT}"
)
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n server_info
watch -c -d server_info ${RIPPLED} ${RPC_IP} ${RPC_PORT} )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n balance
watch -d=permanent balance ${RIPPLED} ${RPC_IP} ${RPC_PORT} )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n transactions
$( dirname $0)/redirect \
"transactions ${RPC_IP}:${RPC_PORT} localhost ${RPC_PORT} ${LAST_LEDGER_FILE}" \
${HOME}/rippled/transactions-output.txt )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
# tmux set-option -w -t monitor:transactions remain-on-exit on
# --tab-with-profile=Persistent -t transactions --command="$( dirname $0)/redirect \"transactions ${RPC_IP}:${RPC_PORT} localhost ${RPC_PORT}\" ${HOME}/rippled/transactions-output.txt" \
cmd=( "${tmuxcommand[@]}"
-n peerfinder
watch -d "${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} print | jq \
'.result.app.peers.peerfinder | del(.livecache) | del(.bootcache)'"
)
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n get_counts
watch -c -d ${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} get_counts 1 )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n crawl
watch -d curl -k https://${RPC_IP}:${PEER_PORT}/crawl )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n vl
watch -d curl -k
https://${RPC_IP}:${PEER_PORT}/vl/ED2677ABFFD1B33AC6FBC3062B71F1E8397C1505E1C42C64D11AD1B28FF73F4734
)
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n top
top )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n bandwidth
redirect 'bwm-ng -o csv -c 0 -t 10000' ${HOME}/rippled/bandwidth.csv
)
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( "${tmuxcommand[@]}"
-n fee
watch -c -d ${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} fee )
echo "Run: ${cmd[@]}"
"${cmd[@]}" || true
cmd=( tmux select-window -t monitor:health )
echo "Run: ${cmd[@]}"
"${cmd[@]}"
cmd=( tmux kill-window -t monitor:sleep )
echo "Run: ${cmd[@]}"
"${cmd[@]}"
if [[ -z "${TMUX}" ]]
then
cmd=( tmux attach -t monitor )
echo "Run: ${cmd[@]}"
"${cmd[@]}"
fi
else
gnome-terminal --window-with-profile=Unnamed -t server_info --command="watch -c -d server_info ${RIPPLED} ${RPC_IP} ${RPC_PORT}" \
--tab-with-profile=Persistent -t balance --command="watch -d=permanent balance ${RIPPLED} ${RPC_IP} ${RPC_PORT}" \
--tab-with-profile=Persistent -t transactions --command="$( dirname $0)/redirect \"transactions ${RPC_IP}:${RPC_PORT} localhost ${RPC_PORT}\" ${HOME}/rippled/transactions-output.txt" \
--tab-with-profile=Persistent -t peerfinder --command="watch -d \"${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} print | jq '.result.app.peers.peerfinder | del(.livecache) | del(.bootcache)'\"" \
--tab-with-profile=Persistent -t get_counts --command="watch -c -d ${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} get_counts 1" \
--tab-with-profile=Persistent -t crawl --command="watch -d curl -k https://${RPC_IP}:${PEER_PORT}/crawl" \
--tab-with-profile=Persistent -t vl --command="watch -d curl -k https://${RPC_IP}:${PEER_PORT}/vl/ED2677ABFFD1B33AC6FBC3062B71F1E8397C1505E1C42C64D11AD1B28FF73F4734" \
--tab-with-profile=Persistent -t top --command="top" \
--tab-with-profile=Persistent -t bandwidth --command="redirect 'bwm-ng -o csv -c 0 -t 10000' ${HOME}/rippled/bandwidth.csv" \
--tab-with-profile=Persistent -t fee --command="watch -c -d ${RIPPLED} -q --rpc_ip=${RPC_IP}:${RPC_PORT} fee"
fi