From 3fe5e7f8fa0d7c0354304521ac4f74782efc1582 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Tue, 15 Mar 2016 14:01:08 +0100 Subject: [PATCH 1/3] Add ignored fs types --- collector/filesystem_bsd.go | 5 +++++ collector/filesystem_common.go | 13 +++++++++++-- collector/filesystem_linux.go | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/collector/filesystem_bsd.go b/collector/filesystem_bsd.go index ffe916b3..24b92af6 100644 --- a/collector/filesystem_bsd.go +++ b/collector/filesystem_bsd.go @@ -33,6 +33,7 @@ import "C" const ( defIgnoredMountPoints = "^/(dev)($|/)" + defIgnoredFsTypes = "^devfs$" MNT_RDONLY = 0x1 ) @@ -55,6 +56,10 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { device := C.GoString(&mnt[i].f_mntfromname[0]) fstype := C.GoString(&mnt[i].f_fstypename[0]) + if c.ignoredFsTypesPattern.MatchString(fstype) { + log.Debugf("Ignoring fs type: %s", fstype) + continue + } var ro float64 if (mnt[i].f_flags & MNT_RDONLY) != 0 { diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index b92f2123..9bf4d0a9 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -25,6 +25,7 @@ import ( // Arch-dependent implementation must define: // * defIgnoredMountPoints +// * defIgnoredFsTypes // * filesystemLabelNames // * filesystemCollector.GetStats @@ -34,11 +35,17 @@ var ( defIgnoredMountPoints, "Regexp of mount points to ignore for filesystem collector.") + ignoredFsTypes = flag.String( + "collector.filesystem.ignored-fs-types", + defIgnoredFsTypes, + "Regexp of filesystem types to ignore for filesystem collector.") + filesystemLabelNames = []string{"device", "mountpoint", "fstype"} ) type filesystemCollector struct { ignoredMountPointsPattern *regexp.Regexp + ignoredFsTypesPattern *regexp.Regexp sizeDesc, freeDesc, availDesc, filesDesc, filesFreeDesc, roDesc *prometheus.Desc } @@ -56,7 +63,8 @@ func init() { // Filesystems stats. func NewFilesystemCollector() (Collector, error) { subsystem := "filesystem" - pattern := regexp.MustCompile(*ignoredMountPoints) + mountPointPattern := regexp.MustCompile(*ignoredMountPoints) + fsTypePatter := regexp.MustCompile(*ignoredFsTypes) sizeDesc := prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "size"), @@ -95,7 +103,8 @@ func NewFilesystemCollector() (Collector, error) { ) return &filesystemCollector{ - ignoredMountPointsPattern: pattern, + ignoredMountPointsPattern: mountPointPattern, + ignoredFsTypesPattern: fsTypesPattern, sizeDesc: sizeDesc, freeDesc: freeDesc, availDesc: availDesc, diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 02f2c4a1..156f4b43 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -26,6 +26,7 @@ import ( const ( defIgnoredMountPoints = "^/(sys|proc|dev)($|/)" + defIgnoredFsTypes = "^(sys|proc)fs$" ST_RDONLY = 0x1 ) @@ -47,6 +48,10 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { log.Debugf("Ignoring mount point: %s", mpd.mountPoint) continue } + if c.ignoredFsTypesPatter.MatchString(mpd.fsType) { + log.Debugf("Ignoring fs type: %s", mpd.fsType) + continue + } buf := new(syscall.Statfs_t) err := syscall.Statfs(mpd.mountPoint, buf) if err != nil { From bf88b6ee0fd932324668197205daf2f63526dac3 Mon Sep 17 00:00:00 2001 From: Sharif Nassar Date: Fri, 13 May 2016 13:38:14 -0700 Subject: [PATCH 2/3] Fix typos, and initialisms from comments in #217 --- collector/filesystem_bsd.go | 4 ++-- collector/filesystem_common.go | 12 ++++++------ collector/filesystem_linux.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/collector/filesystem_bsd.go b/collector/filesystem_bsd.go index 24b92af6..f51f0eee 100644 --- a/collector/filesystem_bsd.go +++ b/collector/filesystem_bsd.go @@ -33,7 +33,7 @@ import "C" const ( defIgnoredMountPoints = "^/(dev)($|/)" - defIgnoredFsTypes = "^devfs$" + defIgnoredFSTypes = "^devfs$" MNT_RDONLY = 0x1 ) @@ -56,7 +56,7 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { device := C.GoString(&mnt[i].f_mntfromname[0]) fstype := C.GoString(&mnt[i].f_fstypename[0]) - if c.ignoredFsTypesPattern.MatchString(fstype) { + if c.ignoredFSTypesPattern.MatchString(fstype) { log.Debugf("Ignoring fs type: %s", fstype) continue } diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index 9bf4d0a9..f12b9608 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -25,7 +25,7 @@ import ( // Arch-dependent implementation must define: // * defIgnoredMountPoints -// * defIgnoredFsTypes +// * defIgnoredFSTypes // * filesystemLabelNames // * filesystemCollector.GetStats @@ -35,9 +35,9 @@ var ( defIgnoredMountPoints, "Regexp of mount points to ignore for filesystem collector.") - ignoredFsTypes = flag.String( + ignoredFSTypes = flag.String( "collector.filesystem.ignored-fs-types", - defIgnoredFsTypes, + defIgnoredFSTypes, "Regexp of filesystem types to ignore for filesystem collector.") filesystemLabelNames = []string{"device", "mountpoint", "fstype"} @@ -45,7 +45,7 @@ var ( type filesystemCollector struct { ignoredMountPointsPattern *regexp.Regexp - ignoredFsTypesPattern *regexp.Regexp + ignoredFSTypesPattern *regexp.Regexp sizeDesc, freeDesc, availDesc, filesDesc, filesFreeDesc, roDesc *prometheus.Desc } @@ -64,7 +64,7 @@ func init() { func NewFilesystemCollector() (Collector, error) { subsystem := "filesystem" mountPointPattern := regexp.MustCompile(*ignoredMountPoints) - fsTypePatter := regexp.MustCompile(*ignoredFsTypes) + FSTypesPattern := regexp.MustCompile(*ignoredFSTypes) sizeDesc := prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "size"), @@ -104,7 +104,7 @@ func NewFilesystemCollector() (Collector, error) { return &filesystemCollector{ ignoredMountPointsPattern: mountPointPattern, - ignoredFsTypesPattern: fsTypesPattern, + ignoredFSTypesPattern: FSTypesPattern, sizeDesc: sizeDesc, freeDesc: freeDesc, availDesc: availDesc, diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 156f4b43..ceb99fa7 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -26,7 +26,7 @@ import ( const ( defIgnoredMountPoints = "^/(sys|proc|dev)($|/)" - defIgnoredFsTypes = "^(sys|proc)fs$" + defIgnoredFSTypes = "^(sys|proc)fs$" ST_RDONLY = 0x1 ) @@ -48,7 +48,7 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { log.Debugf("Ignoring mount point: %s", mpd.mountPoint) continue } - if c.ignoredFsTypesPatter.MatchString(mpd.fsType) { + if c.ignoredFSTypesPattern.MatchString(mpd.fsType) { log.Debugf("Ignoring fs type: %s", mpd.fsType) continue } From f0630d5cbb9de7acd630bc9dab546fd23896afb8 Mon Sep 17 00:00:00 2001 From: Sharif Nassar Date: Mon, 6 Jun 2016 11:10:50 -0700 Subject: [PATCH 3/3] Do not export the filesystem type pattern --- collector/filesystem_common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index f12b9608..cbd609de 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -64,7 +64,7 @@ func init() { func NewFilesystemCollector() (Collector, error) { subsystem := "filesystem" mountPointPattern := regexp.MustCompile(*ignoredMountPoints) - FSTypesPattern := regexp.MustCompile(*ignoredFSTypes) + filesystemsTypesPattern := regexp.MustCompile(*ignoredFSTypes) sizeDesc := prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "size"), @@ -104,7 +104,7 @@ func NewFilesystemCollector() (Collector, error) { return &filesystemCollector{ ignoredMountPointsPattern: mountPointPattern, - ignoredFSTypesPattern: FSTypesPattern, + ignoredFSTypesPattern: filesystemsTypesPattern, sizeDesc: sizeDesc, freeDesc: freeDesc, availDesc: availDesc,