feat: PBS — Disk-Auslastung via df, laufende Tasks, Kacheln kleiner ohne Debian-Version
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user