Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: collect per node connection statistics #45

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions resources/scripts/resource-usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ while true; do
echo "Report for $(date)"
echo "------------------------------------------------------"
echo "Checking $(hostname) on $(hostname -I | awk '{print $1}')"
printf "%-52s %-8s %-10s %-10s %s\n" \
printf "%-52s %-8s %-10s %-10s %-20s %-10s\n" \
"Node " \
"PID" \
"Memory (MB)" \
"CPU (%)" \
"Record Count"
"Record Count" \
"Connections"
running_process_count=0
for folder in $NODE_DATA_DIR_PATH/*; do
if [ ! -d "$folder" ]; then continue; fi
Expand All @@ -32,15 +33,19 @@ while true; do
rss=$(ps -p $pid -o rss=)
cpu=$(top -b -n1 -p $pid | awk 'NR>7 {print $9}')
count=$(find "$folder/record_store" -name '*' -not -name '*.pid' -type f | wc -l)
printf "%-52s %-8s %-10s %-10s %s\n" \
con_count=$(ss -tunpa | grep ESTAB | grep =$pid -c)
printf "%-52s %-8s %-10s %-10s %-20s %-10s\n" \
"$peer_id" \
"$pid" \
"$(awk "BEGIN {print $rss/1024}")" \
"$cpu" \
"$count"
"$count" \
"$con_count"
running_process_count=$((running_process_count + 1))
done
echo "Total node processes: $running_process_count"
total_connections=$(ss -tunpa | grep ESTAB | grep safenode -c)
echo "Total live connections: $total_connections"

# sleep 15 minutes before running again
sleep 900
Expand Down
Loading