feat: PBS — Disk-Auslastung via df, laufende Tasks, Kacheln kleiner ohne Debian-Version

This commit is contained in:
cynfo3000
2026-03-07 00:08:01 +01:00
parent 6487c2cf59
commit 3c83cf11de
2 changed files with 46 additions and 20 deletions
+26 -4
View File
@@ -37,6 +37,7 @@ type PBSTask struct {
Duration int64 `json:"duration,omitempty"`
User string `json:"user,omitempty"`
Datastore string `json:"datastore,omitempty"`
Running bool `json:"running,omitempty"`
}
type PBSGCStatus struct {
@@ -90,10 +91,28 @@ func CollectPBS() *PBSInfo {
if avail, ok := d["avail"].(float64); ok {
ds.Available = int64(avail)
}
// Backup-Anzahl: alle Timestamp-Verzeichnisse zaehlen
// Struktur: <path>/<type>/<id>/<timestamp> oder <path>/ns/<ns>/<type>/<id>/<timestamp>
// Timestamp-Format: 2026-02-18T18:24:36Z
// Disk-Auslastung via df
if ds.Path != "" {
dfCmd := exec.Command("/bin/df", "-B1", "--output=size,used,avail", ds.Path)
if out, err := dfCmd.Output(); err == nil {
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
if len(lines) >= 2 {
fields := strings.Fields(lines[1])
if len(fields) >= 3 {
if v, err := strconv.ParseInt(fields[0], 10, 64); err == nil {
ds.Total = v
}
if v, err := strconv.ParseInt(fields[1], 10, 64); err == nil {
ds.Used = v
}
if v, err := strconv.ParseInt(fields[2], 10, 64); err == nil {
ds.Available = v
}
}
}
}
// Backup-Anzahl: alle Timestamp-Verzeichnisse zaehlen
countCmd := exec.Command("/bin/sh", "-c",
`find `+ds.Path+` -type d 2>/dev/null | grep -cE '/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$'`)
if out, err := countCmd.Output(); err == nil {
@@ -131,11 +150,14 @@ func CollectPBS() *PBSInfo {
if start, ok := t["starttime"].(float64); ok {
task.StartTime = int64(start)
}
if end, ok := t["endtime"].(float64); ok {
if end, ok := t["endtime"].(float64); ok && end > 0 {
task.EndTime = int64(end)
if task.StartTime > 0 {
task.Duration = task.EndTime - task.StartTime
}
} else {
task.Running = true
task.Status = "running"
}
if user, ok := t["user"].(string); ok {
task.User = user