1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,47 @@
package kube_inventory
import (
"context"
"strings"
corev1 "k8s.io/api/core/v1"
"github.com/influxdata/telegraf"
)
func collectPersistentVolumes(ctx context.Context, acc telegraf.Accumulator, ki *KubernetesInventory) {
list, err := ki.client.getPersistentVolumes(ctx)
if err != nil {
acc.AddError(err)
return
}
for i := range list.Items {
gatherPersistentVolume(&list.Items[i], acc)
}
}
func gatherPersistentVolume(pv *corev1.PersistentVolume, acc telegraf.Accumulator) {
phaseType := 5
switch strings.ToLower(string(pv.Status.Phase)) {
case "bound":
phaseType = 0
case "failed":
phaseType = 1
case "pending":
phaseType = 2
case "released":
phaseType = 3
case "available":
phaseType = 4
}
fields := map[string]interface{}{
"phase_type": phaseType,
}
tags := map[string]string{
"pv_name": pv.Name,
"phase": string(pv.Status.Phase),
"storageclass": pv.Spec.StorageClassName,
}
acc.AddFields(persistentVolumeMeasurement, fields, tags)
}