Extended ZFS states
This commit is contained in:
@@ -26,17 +26,26 @@ type zfsMetricComponent struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
var zfsStateValues = map[string]float64{
|
||||
"ONLINE": 1,
|
||||
"DEGRADED": 2,
|
||||
"FAULTED": 3,
|
||||
"OFFLINE": 4,
|
||||
"REMOVED": 5,
|
||||
"UNAVAIL": 6,
|
||||
}
|
||||
|
||||
// NewPveNodeZfsCollector creates a ZFS metrics collector.
|
||||
func NewPveNodeZfsCollector(apiClient *proxmox.PveApiClient, registry *TTLRegistry) *PveNodeZfsCollector {
|
||||
c := PveNodeZfsCollector{apiClient: apiClient, registry: registry}
|
||||
labelNames := []string{"cluster", "node", "pool", "component", "path", "leaf"}
|
||||
componentLabelNames := []string{"cluster", "node", "pool", "component", "path", "leaf"}
|
||||
|
||||
c.state = NewTTLGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "pve_node_zfs_state",
|
||||
Help: "ZFS pool component state (1 = ONLINE, 0 = any other state).",
|
||||
Help: "ZFS pool component state (0 = UNKNOWN, 1 = ONLINE, 2 = DEGRADED, 3 = FAULTED, 4 = OFFLINE, 5 = REMOVED, 6 = UNAVAIL).",
|
||||
},
|
||||
labelNames,
|
||||
componentLabelNames,
|
||||
5*time.Minute,
|
||||
)
|
||||
c.registry.Register(c.state)
|
||||
@@ -46,7 +55,7 @@ func NewPveNodeZfsCollector(apiClient *proxmox.PveApiClient, registry *TTLRegist
|
||||
Name: "pve_node_zfs_read_errors",
|
||||
Help: "ZFS pool component read error count.",
|
||||
},
|
||||
labelNames,
|
||||
componentLabelNames,
|
||||
5*time.Minute,
|
||||
)
|
||||
c.registry.Register(c.readErrors)
|
||||
@@ -56,7 +65,7 @@ func NewPveNodeZfsCollector(apiClient *proxmox.PveApiClient, registry *TTLRegist
|
||||
Name: "pve_node_zfs_write_errors",
|
||||
Help: "ZFS pool component write error count.",
|
||||
},
|
||||
labelNames,
|
||||
componentLabelNames,
|
||||
5*time.Minute,
|
||||
)
|
||||
c.registry.Register(c.writeErrors)
|
||||
@@ -66,7 +75,7 @@ func NewPveNodeZfsCollector(apiClient *proxmox.PveApiClient, registry *TTLRegist
|
||||
Name: "pve_node_zfs_checksum_errors",
|
||||
Help: "ZFS pool component checksum error count.",
|
||||
},
|
||||
labelNames,
|
||||
componentLabelNames,
|
||||
5*time.Minute,
|
||||
)
|
||||
c.registry.Register(c.checksumErrors)
|
||||
@@ -146,8 +155,8 @@ func appendZfsComponent(components *[]zfsMetricComponent, component proxmox.PveZ
|
||||
}
|
||||
|
||||
func zfsStateNumeric(state string) float64 {
|
||||
if strings.EqualFold(state, "ONLINE") {
|
||||
return 1
|
||||
if value, ok := zfsStateValues[strings.ToUpper(state)]; ok {
|
||||
return value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user