Skip to content

Commit 82e93cc

Browse files
authored
Merge pull request #23 from djerfy/improve/add-pvc-utilization
Improvements of pvc and minor fixes
2 parents 10c2cb3 + 6df6778 commit 82e93cc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Nagios-style checks against Kubernetes API. Designed for usage with Nagios, Icin
5454
Check apiserver health using tokenfile:
5555

5656
./check_kubernetes.sh -m apiserver -H https://<...>:6443 -t /path/to/tokenfile
57-
OK. Kuberenetes apiserver health is OK
57+
OK. Kubernetes apiserver health is OK
5858

5959
Check whether all deployments are available using token:
6060

@@ -106,6 +106,12 @@ Checked failed jobs named 'good':
106106
./check_kubernetes.sh -m jobs -n good
107107
OK: 0 failed jobs is below threshold
108108

109+
Check utilization if pvc (if consumes more than %):
110+
111+
./check_kubernetes.sh -m pvc
112+
CRITICAL. Very high storage utilization on pvc prometheus-data: 93% (86106636288/157459890176 Bytes)
113+
114+
109115
## Brief mode
110116

111117
All modes support the -b brief option. In this mode, a single numerical output is returned. The number is positive on success and zero or negative on error.

check_kubernetes.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ mode_pvc() {
266266
CRIT=${CRIT:-90}
267267
WARN_ERROR=0
268268
CRIT_ERROR=0
269+
PVC_COUNT=0
270+
269271
data="$(getJSON "get nodes" "api/v1/nodes")"
270272
[ $? -gt 0 ] && die "$data"
271273
nodes=($(echo "$data" | jq -r ".items[].metadata.name"))
@@ -274,7 +276,6 @@ mode_pvc() {
274276
data="$(getJSON "get nodes" "api/v1/nodes/$node/proxy/stats/summary")"
275277
[ $? -gt 0 ] && die "$data"
276278
pods=($(echo "$data" | jq -r ".pods[].podRef.name"))
277-
278279
for pod in "${pods[@]}"; do
279280
pod_volumes="$(echo "$data" | jq -r ".pods[] | select(.podRef.name==\"$pod\") | .volume" 2>/dev/null)"
280281
[ "$pod_volumes" == "null" ] && continue
@@ -292,6 +293,9 @@ mode_pvc() {
292293
volume_inodes_capacity=$(echo "$pvc_volumes" | jq -r ". | select(.name==\"$volume_name\") | .inodes")
293294
volume_bytes_utilization=$(echo "100 * $volume_bytes_used / $volume_bytes_capacity" | bc)
294295
volume_inodes_utilization=$(echo "100 * $volume_inodes_used / $volume_inodes_capacity" | bc)
296+
297+
((PVC_COUNT++))
298+
295299
if [ "$volume_bytes_utilization" -gt "$WARN" ] && [ "$volume_bytes_utilization" -lt "$CRIT" ]; then
296300
echo "WARNING. High storage utilization on pvc $volume_name (namespace:$volumes_namespace): \
297301
$volume_bytes_utilization% ($volume_bytes_used/$volume_bytes_capacity Bytes)"
@@ -319,7 +323,7 @@ mode_pvc() {
319323
done
320324

321325
if [ "$WARN_ERROR" -eq "0" ] && [ "$CRIT_ERROR" -eq "0" ]; then
322-
echo "OK. No problem on pvc storage"
326+
echo "OK. No problem on $pvc_count pvc storage"
323327
elif [ "$WARN_ERROR" -ne "0" ] && [ "$CRIT_ERROR" -eq "0" ]; then
324328
exit 1
325329
elif [ "$CRIT_ERROR" -ne "0" ]; then

0 commit comments

Comments
 (0)