Added ZFS state metrics
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
@@ -212,6 +213,37 @@ func (instance *PveApiClient) GetNodeDisksList(node string) (*[]PveDisk, error)
|
||||
return &disks, nil
|
||||
}
|
||||
|
||||
// Get ZFS pools configured on a PVE node.
|
||||
func (instance *PveApiClient) GetNodeZfsPools(node string) (*[]PveZfsPool, error) {
|
||||
res, err := instance.apiClient.PerformRequest("GET", "/nodes/"+node+"/disks/zfs", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pools []PveZfsPool
|
||||
if err := json.Unmarshal(res.Data, &pools); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pools, nil
|
||||
}
|
||||
|
||||
// Get detailed status and topology of a ZFS pool on a PVE node.
|
||||
func (instance *PveApiClient) GetNodeZfsPoolStatus(node string, pool string) (*PveZfsPoolStatus, error) {
|
||||
path := "/nodes/" + node + "/disks/zfs/" + url.PathEscape(pool)
|
||||
res, err := instance.apiClient.PerformRequest("GET", path, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var status PveZfsPoolStatus
|
||||
if err := json.Unmarshal(res.Data, &status); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
// Get PVE node time info.
|
||||
func (instance *PveApiClient) GetNodeTime(node string) (*PveNodeTime, error) {
|
||||
res, err := instance.apiClient.PerformRequest("GET", "/nodes/"+node+"/time", nil)
|
||||
|
||||
Reference in New Issue
Block a user