read contents of objset file (#1632)

* added objread functionality

Signed-off-by: Sudharshann D <sudhar287@gmail.com>
This commit is contained in:
Sudhar287 2020-05-13 15:06:00 -04:00 committed by GitHub
commit 6807e5319b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 238 additions and 6 deletions

View file

@ -34,17 +34,19 @@ func init() {
}
type zfsCollector struct {
linuxProcpathBase string
linuxZpoolIoPath string
linuxPathMap map[string]string
logger log.Logger
linuxProcpathBase string
linuxZpoolIoPath string
linuxZpoolObjsetPath string
linuxPathMap map[string]string
logger log.Logger
}
// NewZFSCollector returns a new Collector exposing ZFS statistics.
func NewZFSCollector(logger log.Logger) (Collector, error) {
return &zfsCollector{
linuxProcpathBase: "spl/kstat/zfs",
linuxZpoolIoPath: "/*/io",
linuxProcpathBase: "spl/kstat/zfs",
linuxZpoolIoPath: "/*/io",
linuxZpoolObjsetPath: "/*/objset-*",
linuxPathMap: map[string]string{
"zfs_abd": "abdstats",
"zfs_arc": "arcstats",
@ -113,3 +115,20 @@ func (c *zfsCollector) constPoolMetric(poolName string, sysctl zfsSysctl, value
poolName,
)
}
func (c *zfsCollector) constPoolObjsetMetric(poolName string, datasetName string, sysctl zfsSysctl, value uint64) prometheus.Metric {
metricName := sysctl.metricName()
return prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, "zfs_zpool_dataset", metricName),
string(sysctl),
[]string{"zpool", "dataset"},
nil,
),
prometheus.UntypedValue,
float64(value),
poolName,
datasetName,
)
}