-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnode_status.sh
executable file
·40 lines (35 loc) · 1.73 KB
/
node_status.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
#!/bin/bash
group_name=$1
vmss_name=$2
node_list=$(az vmss list-instances -g ${group_name} -n ${vmss_name})
nic_list=$(az vmss nic list -g ${group_name} --vmss-name ${vmss_name})
nodes=$(echo $node_list| jq '. | length')
echo "Status of $group_name, $vmss_name"
echo "Number of nodes: $nodes\n"
n=0
echo "Node \t| Id \t| Node name \t| IP \t| Provisioning \t| Extension \t| Logfile \t| Log modified \t|"
echo "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
while [ "$n" -lt "$nodes" ]; do
instanceid=$(echo $node_list | jq .[$n] | jq .instanceId | tr -d '"')
nodename=$(echo $node_list | jq .[$n] | jq .osProfile.computerName | tr -d '"')
nicid=$(echo $node_list | jq .[$n] | jq .networkProfile.networkInterfaces[0].id | tr -d '"')
ip=$(echo $nic_list | jq "map(select(.id == \"$nicid\")) | .[0].ipConfigurations[0].privateIpAddress" | tr -d '"')
pstate=$(echo $node_list| jq .[$n].provisioningState | tr -d '"')
epstate=$(echo $node_list| jq .[$n].resources[0].provisioningState | tr -d '"')
logfile="/gtmount/gtlog/${nodename}/gadgetron.log"
LT="MISSING LOG FILE !!"
if [ -e "$logfile" ]; then
ecode=124
try_count=0
while [ "$ecode" -eq 124 ] && [ "$try_count" -lt 10 ]; do
LT=$(timeout 2 sh -c "tac $logfile | grep -m1 -oP '(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})'")
ecode=$?
try_count=`expr $try_count + 1`
done
if [ "$try_count" -ge 10 ]; then
LT="TIMEOUT ON LOG FILE"
fi
fi
echo "$n \t| $instanceid \t| $nodename \t| $ip \t| $pstate \t| $epstate \t| $logfile \t| $LT \t|"
n=`expr $n + 1`
done