-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheck_nodes_1.sh
executable file
·211 lines (198 loc) · 9.38 KB
/
eck_nodes_1.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
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
#!/usr/bin/env bash
# count of array
count=`jq '.items | length' "${1}"`
if [ ${count} = 0 ]; then
exit
fi
echo "========================================================================================="
echo "ITEMS TO NOTES:"
echo " - Health Summary - any true other than ready"
echo " - Metrics Summary - Anything under pressure"
echo " - Container Image List - any images missing?"
echo "========================================================================================="
echo ""
echo "========================================================================================="
echo "WORKER NODE Host OS Summary"
echo "========================================================================================="
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"ARCH": (.status.nodeInfo.architecture // "-"),
"INSTANCE": (.metadata.labels."node.kubernetes.io/instance-type" // "-"),
"OS": (.status.nodeInfo.operatingSystem // "-"),
"OS image": (.status.nodeInfo.osImage // "-"),
"KERNEL": (.status.nodeInfo.kernelVersion // "-"),
"REGION": (.metadata.labels."topology.kubernetes.io/region" // "-"),
"ZONE": (.metadata.labels."topology.kubernetes.io/zone" // "-"),
"kubelet Version": (.status.nodeInfo.kubeletVersion // "-"),
"Runtime Version": (.status.nodeInfo.containerRuntimeVersion // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "========================================================================================="
echo "WORKER NODE Health Summary"
echo "========================================================================================="
echo ""
echo "== PRESSURE -----------------------------------------------------------------------------"
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"CPU ALLOCATED": (.status.allocatable.cpu // "-"),
"CPU LIMIT": (.status.capacity.cpu // "-"),
"PID PRESSURE": ((.status.conditions[] | select(.type=="PIDPressure") | .status) // "-"),
"MEM ALLOCATED": (.status.allocatable.memory // "-"),
"MEM LIMIT": (.status.capacity.memory // "-"),
"MEM PRESSURE": ((.status.conditions[] | select(.type=="MemoryPressure") | .status) // "-"),
"DISK ALLOCATED": (.status.allocatable."ephemeral-storage" // "-"),
"DISK LIMIT": (.status.capacity."ephemeral-storage" // "-"),
"DISK PRESSURE": ((.status.conditions[] | select(.type=="DiskPressure") | .status) // "-"),
"POD LIMIT": (.status.capacity.pods // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "== SCHEDULED ----------------------------------------------------------------------------"
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"REBOOT": ((.status.conditions[] | select(.type=="RebootScheduled") | .status) // "-"),
"TERMINATE": ((.status.conditions[] | select(.type=="TerminateScheduled") | .status) // "-"),
"PREEMPT": ((.status.conditions[] | select(.type=="PreemptScheduled") | .status) // "-"),
"REDEPLOY": ((.status.conditions[] | select(.type=="RedeployScheduled") | .status) // "-"),
"FREEZE": ((.status.conditions[] | select(.type=="FreezeScheduled") | .status) // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "== RESTART ------------------------------------------------------------------------------"
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"FREQ DDOCKER": ((.status.conditions[] | select(.type=="FrequentDockerRestart") | .status) // "-"),
"FREQ KUBLET": ((.status.conditions[] | select(.type=="FrequentKubeletRestart") | .status) // "-"),
"FREQ CONTAINER": ((.status.conditions[] | select(.type=="FrequentContainerdRestart") | .status) // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "== PROBLEM ------------------------------------------------------------------------------"
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"KUBELET": ((.status.conditions[] | select(.type=="KubeletProblem") | .status) // "-"),
"CONTAINER RUNTIME": ((.status.conditions[] | select(.type=="ContainerRuntimeProblem") | .status) // "-"),
"FS CORRUPTION": ((.status.conditions[] | select(.type=="FilesystemCorruptionProblem") | .status) // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "== OTHER --------------------------------------------------------------------------------"
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"RO FILESYSTEM": ((.status.conditions[] | select(.type=="ReadonlyFilesystem") | .status) // "-"),
"FREQ UNREG NET DEVICES": ((.status.conditions[] | select(.type=="FrequentUnregisterNetDevice") | .status) // "-"),
"KERNEL DEADLOCK": ((.status.conditions[] | select(.type=="KernelDeadlock") | .status) // "-"),
"CORRUPT OVERLAY": ((.status.conditions[] | select(.type=="CorruptDockerOverlay2") | .status) // "-"),
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "========================================================================================="
echo "WORKER NODE Container Image List - elastic only. Full list at bottom"
echo "========================================================================================="
echo ""
# FIX - we can iterate with jq - something like but did not work - needs eyes - also same on the end without the filter
# FIX - need to do .names[] --> (.names[]|last) but its not working
#jq -r '["NODE","IMAGE","SIZE"],
#(.items[]| .metadata.name as $nodename
#| (.status.images[] | select(.names[] | contains("elastic"))
#| [ $nodename, .names[], (.sizeBytes // "-")]))|join(",")' nodes.json | column -t -s ","
for ((i=0; i<$count; i++))
do
host=`jq -r '.items['$i'].metadata.name' "${1}"`
echo "---------- WORKER NODE: ${host} -----------------------------------------------------------------"
jq -r '
[.items['$i'].status.images[]
| select(.names[]
| contains("elastic"))
| {
"IMAGE NAME": (.names |last // "-"),
"IMAGE SIZE": (.sizeBytes // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
done
echo ""
echo "========================================================================================="
echo "WORKER NODE Network Summary"
echo "========================================================================================="
echo ""
jq -r '
[.items[]
| {
"HOST": (.metadata.name // "-"),
"ZONE": (.metadata.labels."topology.kubernetes.io/zone" // "-"),
"REGION": (.metadata.labels."topology.kubernetes.io/region" // "-"),
"INTERNAL IP": ((.status.addresses[] | select(.type=="InternalIP") | .address) // "-"),
"EXTERNAL IP": ((.status.addresses[] | select(.type=="ExternalIP") | .address) // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
echo "========================================================================================="
echo "WORKER NODE Storage Summary - Attached volumes"
echo "========================================================================================="
echo ""
jq -r '["NODE","VOLUME NAME", "DEVICE PATH"],
(.items[]
| .metadata.name as $nodename
| (.status.volumesAttached[]
| [ $nodename,
(.name // "-"),
(.devicePath // "-")])) | join(",")' "${1}" 2>/dev/null | column -t -s ","
echo ""
echo "========================================================================================="
echo "WORKER NODE Storage Summary - Volumes in USE"
echo "========================================================================================="
echo ""
jq -r '["NODE", "VOLUME IN USE"],
(.items[]
| .metadata.name as $nodename
| .status.volumesInUse[]?
| [$nodename, . ]) | join(",")' "${1}" 2>/dev/null | column -t -s ","
echo ""
echo "========================================================================================="
echo "WORKER NODE Annotations & Labels"
echo "========================================================================================="
echo ""
for ((i=0; i<$count; i++))
do
host=`jq -r '.items['${i}'].metadata.name' "${1}"`
echo "---------- WORKER NODE: ${host} -----------------------------------------------------------------"
echo "Annotations:"
echo ""
jq -r '.items['${i}'].metadata.annotations | to_entries | .[] | .key,(.value | if try fromjson catch false then fromjson else . end)," "' "${1}" 2>/dev/null
echo ""
echo "Labels:"
echo ""
jq -r '.items['${i}'].metadata.labels | (to_entries[] | "\(.key)=\(.value)") | select(length >0)' "${1}" 2>/dev/null
echo ""
done
echo ""
echo "========================================================================================="
echo "WORKER NODE Container Image List - Full"
echo "========================================================================================="
echo ""
for ((i=0; i<$count; i++))
do
host=`jq -r '.items['$i'].metadata.name' "${1}"`
echo "---------- WORKER NODE: ${host} -----------------------------------------------------------------"
jq -r '
[.items['$i'].status.images[]
| select(.names[])
| {
"IMAGE NAME": (.names |last // "-"),
"IMAGE SIZE": (.sizeBytes // "-")
}]| (.[0] |keys_unsorted | @tsv),(.[]|.|map(.) |@tsv)' "${1}" 2>/dev/null | column -ts $'\t'
echo ""
done
echo ""
echo ""