Fixed storage content label sorting
This commit is contained in:
@@ -85,7 +85,7 @@ func (c *PveStorageCollector) CollectMetrics() error {
|
||||
"node": node.Name,
|
||||
"storage": storage.Storage,
|
||||
"type": storage.Type,
|
||||
"content": storage.Content,
|
||||
"content": storage.GetContentSorted(),
|
||||
"shared": strconv.Itoa(storage.Shared),
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package proxmox
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PveVersion represents the version information of a PVE (Proxmox Virtual Environment).
|
||||
@@ -492,3 +494,11 @@ func (r *PveClusterStatus) GetClusterName() string {
|
||||
}
|
||||
return r.Name
|
||||
}
|
||||
|
||||
// GetContentSorted returns sorted storage content.
|
||||
// This is crucial for labeling because PVE API returns these walues randomly sorted.
|
||||
func (r *PveStorage) GetContentSorted() string {
|
||||
parts := strings.Split(r.Content, ",")
|
||||
sort.Strings(parts)
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user