Skip to content

Commit 9d5795d

Browse files
committed
Add more detailed output on get-node-status script
1 parent c962b67 commit 9d5795d

File tree

4 files changed

+121
-13
lines changed

4 files changed

+121
-13
lines changed

bin/get-node-status

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,72 @@
11
#!/bin/bash
22

3+
execute_sudo() {
4+
if sudo -v &> /dev/null; then
5+
if [[ $(id -u) -eq 0 ]]; then
6+
bash -c "$*"
7+
else
8+
sudo bash -c "$*"
9+
fi
10+
else
11+
echo "The user does not have sudo privileges. Exiting the program."
12+
exit 1
13+
fi
14+
}
15+
16+
get_last_committed_block() {
17+
docker exec -it "${container_id}" bash -c "goal node status | grep 'Last committed block' | cut -d' ' -f4 | tr -cd '[:digit:]'"
18+
}
19+
20+
get_account_info() {
21+
if execute_sudo 'test ! -f "/var/lib/voi/algod/data/voitest-v1/accountList.json"'; then
22+
abort "Account list not found. Exiting the program."
23+
fi
24+
25+
accounts_json=$(execute_sudo 'cat /var/lib/voi/algod/data/voitest-v1/accountList.json')
26+
number_of_accounts=$(echo "${accounts_json}" | jq '.Accounts | length')
27+
28+
if [[ ! $number_of_accounts -eq 1 ]]; then
29+
echo "More than one account, or zero, found in wallet."
30+
return 1
31+
fi
32+
33+
account_address=$(echo "$accounts_json" | jq -r '.Accounts | keys[0]')
34+
echo "${account_address}"
35+
}
36+
37+
get_participation_expiration_eta() {
38+
local active_key_last_valid_round=$1
39+
local last_committed_block=$2
40+
local current_key_blocks_remaining=$((active_key_last_valid_round - last_committed_block))
41+
local remaining_seconds
42+
local current_timestamp
43+
local expiration_timestamp
44+
local expiration_date
45+
46+
remaining_seconds=$(echo "${current_key_blocks_remaining}*2.9" | bc)
47+
current_timestamp=$(date +%s)
48+
expiration_timestamp=$(echo "${current_timestamp}+${remaining_seconds}" | bc)
49+
50+
# Convert the new timestamp to a date and time
51+
expiration_date=$(date -d "@${expiration_timestamp}" '+%Y-%m-%d %H:%M')
52+
53+
echo "${expiration_date}"
54+
}
55+
56+
display_participation_key_information() {
57+
local existing_expiration_date
58+
local active_key_last_valid_round
59+
local last_committed_block
60+
last_committed_block=$(get_last_committed_block)
61+
62+
active_key_last_valid_round=$(docker exec -it "${container_id}" bash -c 'goal account listpartkeys' | awk '$1=="yes" {print $6}' | tr -cd '[:digit:]')
63+
existing_expiration_date=$(get_participation_expiration_eta "${active_key_last_valid_round}" "${last_committed_block}")
64+
65+
echo "Participation status: $(docker exec -it "${container_id}" bash -c 'goal account dump -a '"${account_address}"' | jq -r '\''if (.onl == 1) then "online" else "offline" end'\''')"
66+
echo "Participation key expires at block: ${active_key_last_valid_round} (last committed: ${last_committed_block})"
67+
echo "Participation key expected to expire at: ${existing_expiration_date}"
68+
}
69+
370
container_id=$(docker ps -q -f name=voinetwork_algod)
471
if [ -z "${container_id}" ]; then
572
echo "AVM container is not running. Please start it first."
@@ -26,9 +93,35 @@ else
2693
health_checks["Daemon ready (and caught up)"]="false"
2794
fi
2895

29-
# Print all health checks
30-
echo "Health checks:"
96+
echo "Voi Swarm Docker status:"
97+
echo "**************"
98+
swarm_running_image=$(docker inspect --format='{{.Image}}' "${container_id}" | cut -d':' -f2)
99+
echo "Running container image (sha256): ${swarm_running_image}"
100+
echo ""
101+
102+
echo "AVM version:"
103+
echo "**************"
104+
algod_version=$(docker exec -it "${container_id}" bash -c 'goal version -v')
105+
account_address=$(get_account_info)
106+
echo "${algod_version}"
107+
echo ""
108+
109+
echo "Node health checks:"
31110
echo "**************"
32111
for check in "${!health_checks[@]}"; do
33112
echo "$check: ${health_checks[$check]}"
34113
done
114+
echo ""
115+
116+
echo "Account status:"
117+
echo "**************"
118+
echo "Address: ${account_address}"
119+
echo "Balance: $(docker exec -it "${container_id}" bash -c 'goal account balance -a '"${account_address}"'')"
120+
display_participation_key_information
121+
122+
echo ""
123+
echo "Telemetry status:"
124+
echo "**************"
125+
echo "Enabled: $(execute_sudo "cat /var/lib/voi/algod/data/logging.config | jq -r .Enable")"
126+
echo "Name: $(execute_sudo "cat /var/lib/voi/algod/data/logging.config | jq -r .Name")"
127+
echo "Short GUID: $(execute_sudo "cat /var/lib/voi/algod/data/logging.config | jq -r .GUID | cut -c 1-13")"

docs/cli-tools.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,30 @@ Open a bash shell in the AVM container with the following command:
8080
~/voi/bin/start-shell
8181
```
8282

83-
### Getting Basic Node Health
83+
### Getting Node Health
8484

85-
To retrieve basic health information about your node, execute the following command:
85+
To retrieve health information about your node, execute the following command:
8686

8787
```bash
8888
~/voi/bin/get-node-status
8989
```
9090

91-
The `get-node-status` command performs checks using:
92-
93-
- `goal node status` to connect to the running daemon and retrieve basic node information
94-
- `/health`: This API endpoint checks the reported health of the node. [REST API /health documentation](https://developer.algorand.org/docs/rest-apis/algod/#get-health).
95-
- `/ready`: This API endpoint checks the reported readiness of the node and if fully caught up. [REST API /ready documentation](https://developer.algorand.org/docs/rest-apis/algod/#get-ready).
91+
The `get-node-status` command prints out the following information
92+
93+
- Running Voi Swarm image identifier
94+
- AVM version
95+
- Node health status
96+
- High-level service status
97+
- Health status and if service is running
98+
- If the node is fully caught up with the chain
99+
- Account status
100+
- Address
101+
- Balance
102+
- Participation key status
103+
- Telemetry status
104+
- Enablement
105+
- Name
106+
- Short GUID
96107

97108
### Set Telemetry Name and GUID
98109

docs/installation/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export VOINETWORK_IMPORT_ACCOUNT=1
2828
???+ info
2929
While the installation detects existing host-based setups (such as D13) on the same host
3030
and offers migration automatically,
31-
it is important to familiarize yourself with the [migration steps](../../migrating/) in particular
31+
it is important to familiarize yourself with the [migration steps](../../migrating/), in particular,
3232
if you are [migrating from a different host](../../migrating/#installing-on-a-new-server).

install.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ bold=$(tput bold)
1212
normal=$(tput sgr0)
1313

1414
execute_sudo() {
15-
if [[ ${is_root} -eq 1 ]]; then
16-
bash -c "$1"
15+
if sudo -v &> /dev/null; then
16+
if [[ $(id -u) -eq 0 ]]; then
17+
bash -c "$1"
18+
else
19+
sudo bash -c "$1"
20+
fi
1721
else
18-
sudo bash -c "$1"
22+
abort "Your user does not have sudo privileges. Exiting the program."
1923
fi
2024
}
2125

0 commit comments

Comments
 (0)