mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 06:59:44 -08:00
Adding support for evaluating octal characters in mountpoint (#954)
Signed-off-by: Brad Beam <brad.beam@b-rad.info>
This commit is contained in:
parent
cd217b77f5
commit
e3cf1d5187
|
@ -87,6 +87,12 @@ func mountPointDetails() ([]filesystemLabels, error) {
|
|||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
parts := strings.Fields(scanner.Text())
|
||||
|
||||
// Ensure we handle the translation of \040 and \011
|
||||
// as per fstab(5).
|
||||
parts[1] = strings.Replace(parts[1], "\\040", " ", -1)
|
||||
parts[1] = strings.Replace(parts[1], "\\011", "\t", -1)
|
||||
|
||||
filesystems = append(filesystems, filesystemLabels{
|
||||
device: parts[0],
|
||||
mountPoint: parts[1],
|
||||
|
|
72
collector/filesystem_linux_test.go
Normal file
72
collector/filesystem_linux_test.go
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Copyright 2015 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !nofilesystem
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func TestMountPointDetails(t *testing.T) {
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "./fixtures/proc"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]string{
|
||||
"/": "",
|
||||
"/sys": "",
|
||||
"/proc": "",
|
||||
"/dev": "",
|
||||
"/dev/pts": "",
|
||||
"/run": "",
|
||||
"/sys/kernel/security": "",
|
||||
"/dev/shm": "",
|
||||
"/run/lock": "",
|
||||
"/sys/fs/cgroup": "",
|
||||
"/sys/fs/cgroup/systemd": "",
|
||||
"/sys/fs/pstore": "",
|
||||
"/sys/fs/cgroup/cpuset": "",
|
||||
"/sys/fs/cgroup/cpu,cpuacct": "",
|
||||
"/sys/fs/cgroup/devices": "",
|
||||
"/sys/fs/cgroup/freezer": "",
|
||||
"/sys/fs/cgroup/net_cls,net_prio": "",
|
||||
"/sys/fs/cgroup/blkio": "",
|
||||
"/sys/fs/cgroup/perf_event": "",
|
||||
"/proc/sys/fs/binfmt_misc": "",
|
||||
"/dev/mqueue": "",
|
||||
"/sys/kernel/debug": "",
|
||||
"/dev/hugepages": "",
|
||||
"/sys/fs/fuse/connections": "",
|
||||
"/boot": "",
|
||||
"/run/rpc_pipefs": "",
|
||||
"/run/user/1000": "",
|
||||
"/run/user/1000/gvfs": "",
|
||||
"/var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/[vsanDatastore] bafb9e5a-8856-7e6c-699c-801844e77a4a/kubernetes-dynamic-pvc-3eba5bba-48a3-11e8-89ab-005056b92113.vmdk": "",
|
||||
"/var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/[vsanDatastore] bafb9e5a-8856-7e6c-699c-801844e77a4a/kubernetes-dynamic-pvc-3eba5bba-48a3-11e8-89ab-005056b92113.vmdk": "",
|
||||
}
|
||||
|
||||
filesystems, err := mountPointDetails()
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
|
||||
for _, fs := range filesystems {
|
||||
if _, ok := expected[fs.mountPoint]; !ok {
|
||||
t.Errorf("Got unexpected %s", fs.mountPoint)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,3 +28,5 @@ rpc_pipefs /run/rpc_pipefs rpc_pipefs rw,relatime 0 0
|
|||
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
|
||||
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=808860k,mode=700,uid=1000,gid=1000 0 0
|
||||
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
|
||||
/dev/sda /var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/[vsanDatastore]\040bafb9e5a-8856-7e6c-699c-801844e77a4a/kubernetes-dynamic-pvc-3eba5bba-48a3-11e8-89ab-005056b92113.vmdk ext4 rw,relatime,data=ordered 0 0
|
||||
/dev/sda /var/lib/kubelet/plugins/kubernetes.io/vsphere-volume/mounts/[vsanDatastore]\011bafb9e5a-8856-7e6c-699c-801844e77a4a/kubernetes-dynamic-pvc-3eba5bba-48a3-11e8-89ab-005056b92113.vmdk ext4 rw,relatime,data=ordered 0 0
|
||||
|
|
Loading…
Reference in a new issue