agapoff / check_kubernetes

Nagios/Icinga/Zabbix style plugin for checking Kubernetes
64 stars 36 forks source link

Error Message "integer expression expected" when pvc with same name exists on same node #32

Closed dbrau closed 1 year ago

dbrau commented 1 year ago

Hello,

we are using this script to check our Kubernetes environments. One mode we are using is the "mode_pvc".

We found out that the script will thrown following message if more than one pvc name exists with the same name in the cluster but exists in different namespaces.

Example: List of pvc kubectl get pvc -A | grep smsd-db

NS1 smsd-db-smsd-db-0 Bound pvc-...-...-...-ec7b798e7586 1Gi RWO ceph-rbd 136d NS2 smsd-db-smsd-db-0 Bound pvc-...-...-...-bb86-3cf213ba4331 1Gi RWO ceph-rbd 264d NS3 smsd-db-smsd-db-0 Bound pvc-...-...-...-8b11-cfc8255fe33e 1Gi RWO ceph-rbd 139d

./check_kubernetes.sh' '-H' 'https://<HOSTNAME/k8s/clusters/' '-T' 'token-...:...6tp9cb' '-m' 'pvc' '-o' '60' check_kubernetes.sh: line 255: [: 4972544000 49815552 0 186155008 186155008: integer expression expected

Line 255 is: `((PVC_COUNT++))

                    **if [ "$volume_bytes_utilization" -gt "$WARN" ] && [ "$volume_bytes_utilization" -lt "$CRIT" ]; then**
                         OUTPUT="${OUTPUT}High storage utilization on pvc $volume_name (namespace:$volumes_namespace): $volume_bytes_utilization% ($volume_bytes_used/$volume_bytes_capacity Bytes)\n"
                        ((WARN_ERROR++))
                    fi`

Now if the pods mounting the PVC are running on the same node the above error message will occur.

We are using following specification: Kubernetes v1.23.7 Plugin Version Current Version

Thanks you in advanced

kristous commented 1 year ago

I am running into the same problem. Even filtering by namespace does not help.

agapoff commented 1 year ago

I was unable to reproduce the issue but I've rewritten the pvc mode from scratch. It's supposed to be much faster and more reliable. Also it supports kubectl mode now. Please check whether your issue is resolved.