filesystem: Code cleanup.
parent
462b708742
commit
78bf63ffd8
|
@ -8,8 +8,8 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,7 +38,8 @@ func init() {
|
||||||
Factories["filesystem"] = NewFilesystemCollector
|
Factories["filesystem"] = NewFilesystemCollector
|
||||||
}
|
}
|
||||||
|
|
||||||
// filesystems stats.
|
// Takes a prometheus registry and returns a new Collector exposing
|
||||||
|
// Filesystems stats.
|
||||||
func NewFilesystemCollector() (Collector, error) {
|
func NewFilesystemCollector() (Collector, error) {
|
||||||
var filesystemLabelNames = []string{"filesystem"}
|
var filesystemLabelNames = []string{"filesystem"}
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ func NewFilesystemCollector() (Collector, error) {
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: Namespace,
|
Namespace: Namespace,
|
||||||
Subsystem: filesystemSubsystem,
|
Subsystem: filesystemSubsystem,
|
||||||
Name: "size",
|
Name: "size_bytes",
|
||||||
Help: "Filesystem size in bytes.",
|
Help: "Filesystem size in bytes.",
|
||||||
},
|
},
|
||||||
filesystemLabelNames,
|
filesystemLabelNames,
|
||||||
|
@ -57,7 +58,7 @@ func NewFilesystemCollector() (Collector, error) {
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: Namespace,
|
Namespace: Namespace,
|
||||||
Subsystem: filesystemSubsystem,
|
Subsystem: filesystemSubsystem,
|
||||||
Name: "free",
|
Name: "free_bytes",
|
||||||
Help: "Filesystem free space in bytes.",
|
Help: "Filesystem free space in bytes.",
|
||||||
},
|
},
|
||||||
filesystemLabelNames,
|
filesystemLabelNames,
|
||||||
|
@ -66,7 +67,7 @@ func NewFilesystemCollector() (Collector, error) {
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: Namespace,
|
Namespace: Namespace,
|
||||||
Subsystem: filesystemSubsystem,
|
Subsystem: filesystemSubsystem,
|
||||||
Name: "avail",
|
Name: "avail_bytes",
|
||||||
Help: "Filesystem space available to non-root users in bytes.",
|
Help: "Filesystem space available to non-root users in bytes.",
|
||||||
},
|
},
|
||||||
filesystemLabelNames,
|
filesystemLabelNames,
|
||||||
|
@ -75,7 +76,7 @@ func NewFilesystemCollector() (Collector, error) {
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: Namespace,
|
Namespace: Namespace,
|
||||||
Subsystem: filesystemSubsystem,
|
Subsystem: filesystemSubsystem,
|
||||||
Name: "files",
|
Name: "file_nodes",
|
||||||
Help: "Filesystem total file nodes.",
|
Help: "Filesystem total file nodes.",
|
||||||
},
|
},
|
||||||
filesystemLabelNames,
|
filesystemLabelNames,
|
||||||
|
@ -84,7 +85,7 @@ func NewFilesystemCollector() (Collector, error) {
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: Namespace,
|
Namespace: Namespace,
|
||||||
Subsystem: filesystemSubsystem,
|
Subsystem: filesystemSubsystem,
|
||||||
Name: "files_free",
|
Name: "file_free_nodes",
|
||||||
Help: "Filesystem total free file nodes.",
|
Help: "Filesystem total free file nodes.",
|
||||||
},
|
},
|
||||||
filesystemLabelNames,
|
filesystemLabelNames,
|
||||||
|
@ -102,10 +103,9 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
|
|
||||||
mnt := (*[1 << 30]C.struct_statfs)(unsafe.Pointer(mntbuf))
|
mnt := (*[1 << 30]C.struct_statfs)(unsafe.Pointer(mntbuf))
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
//printf("path: %s\t%lu\n", mntbuf[i].f_mntonname, mntbuf[i].f_bfree)
|
|
||||||
name := C.GoString(&mnt[i].f_mntonname[0])
|
name := C.GoString(&mnt[i].f_mntonname[0])
|
||||||
if c.ignoredMountPointsPattern.MatchString(name) {
|
if c.ignoredMountPointsPattern.MatchString(name) {
|
||||||
glog.V(1).Infof("Ignoring mount point: %s", name)
|
log.Debugf("Ignoring mount point: %s", name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.size.WithLabelValues(name).Set(float64(mnt[i].f_blocks) * float64(mnt[i].f_bsize))
|
c.size.WithLabelValues(name).Set(float64(mnt[i].f_blocks) * float64(mnt[i].f_bsize))
|
||||||
|
|
Loading…
Reference in New Issue