diff --git a/collector/bonding_linux_test.go b/collector/bonding_linux_test.go index de3d3230..564cf01e 100644 --- a/collector/bonding_linux_test.go +++ b/collector/bonding_linux_test.go @@ -18,7 +18,7 @@ import ( ) func TestBonding(t *testing.T) { - bondingStats, err := readBondingStats("fixtures/bonding") + bondingStats, err := readBondingStats("fixtures/sys/class/net") if err != nil { t.Fatal(err) } diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 50f8eddf..405bf281 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -19,7 +19,7 @@ import ( ) func TestDiskStats(t *testing.T) { - file, err := os.Open("fixtures/diskstats") + file, err := os.Open("fixtures/proc/diskstats") if err != nil { t.Fatal(err) } diff --git a/collector/filefd_linux_test.go b/collector/filefd_linux_test.go index 4ab4412e..11781eb7 100644 --- a/collector/filefd_linux_test.go +++ b/collector/filefd_linux_test.go @@ -19,7 +19,7 @@ import ( ) func TestFileFDStats(t *testing.T) { - file, err := os.Open("fixtures/file-nr") + file, err := os.Open("fixtures/proc/sys/fs/file-nr") if err != nil { t.Fatal(err) } diff --git a/collector/fixtures/net/ip_vs_result.txt b/collector/fixtures/ip_vs_result.txt similarity index 100% rename from collector/fixtures/net/ip_vs_result.txt rename to collector/fixtures/ip_vs_result.txt diff --git a/collector/fixtures/diskstats b/collector/fixtures/proc/diskstats similarity index 100% rename from collector/fixtures/diskstats rename to collector/fixtures/proc/diskstats diff --git a/collector/fixtures/interrupts b/collector/fixtures/proc/interrupts similarity index 100% rename from collector/fixtures/interrupts rename to collector/fixtures/proc/interrupts diff --git a/collector/fixtures/proc/loadavg b/collector/fixtures/proc/loadavg new file mode 100644 index 00000000..8897b7ce --- /dev/null +++ b/collector/fixtures/proc/loadavg @@ -0,0 +1 @@ +0.21 0.37 0.39 1/719 19737 diff --git a/collector/fixtures/mdstat b/collector/fixtures/proc/mdstat similarity index 100% rename from collector/fixtures/mdstat rename to collector/fixtures/proc/mdstat diff --git a/collector/fixtures/meminfo b/collector/fixtures/proc/meminfo similarity index 100% rename from collector/fixtures/meminfo rename to collector/fixtures/proc/meminfo diff --git a/collector/fixtures/proc/mounts b/collector/fixtures/proc/mounts new file mode 100644 index 00000000..97d5f6fc --- /dev/null +++ b/collector/fixtures/proc/mounts @@ -0,0 +1,30 @@ +rootfs / rootfs rw 0 0 +sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 +proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 +udev /dev devtmpfs rw,relatime,size=10240k,nr_inodes=1008585,mode=755 0 0 +devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 +tmpfs /run tmpfs rw,nosuid,relatime,size=1617716k,mode=755 0 0 +/dev/dm-2 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0 +securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 +tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 +tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0 +tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 +cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 +pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 +cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 +cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0 +cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 +cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 +cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0 +cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 +cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0 +systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0 +mqueue /dev/mqueue mqueue rw,relatime 0 0 +debugfs /sys/kernel/debug debugfs rw,relatime 0 0 +hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0 +fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 +/dev/sda3 /boot ext2 rw,relatime 0 0 +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 diff --git a/collector/fixtures/net-dev b/collector/fixtures/proc/net/dev similarity index 100% rename from collector/fixtures/net-dev rename to collector/fixtures/proc/net/dev diff --git a/collector/fixtures/net/ip_vs b/collector/fixtures/proc/net/ip_vs similarity index 100% rename from collector/fixtures/net/ip_vs rename to collector/fixtures/proc/net/ip_vs diff --git a/collector/fixtures/net/ip_vs_stats b/collector/fixtures/proc/net/ip_vs_stats similarity index 100% rename from collector/fixtures/net/ip_vs_stats rename to collector/fixtures/proc/net/ip_vs_stats diff --git a/collector/fixtures/netstat b/collector/fixtures/proc/net/netstat similarity index 100% rename from collector/fixtures/netstat rename to collector/fixtures/proc/net/netstat diff --git a/collector/fixtures/proc/net/snmp b/collector/fixtures/proc/net/snmp new file mode 100644 index 00000000..80a92b47 --- /dev/null +++ b/collector/fixtures/proc/net/snmp @@ -0,0 +1,12 @@ +Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates +Ip: 1 64 57740232 0 25 397750 0 0 57340175 55365537 0 54 0 0 0 0 0 0 0 +Icmp: InMsgs InErrors InCsumErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps +Icmp: 104 0 0 104 0 0 0 0 0 0 0 0 0 0 120 0 120 0 0 0 0 0 0 0 0 0 0 +IcmpMsg: InType3 OutType3 +IcmpMsg: 104 120 +Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors +Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0 +Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors +Udp: 88542 120 0 53028 0 0 0 +UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors +UdpLite: 0 0 0 0 0 0 0 diff --git a/collector/fixtures/sockstat b/collector/fixtures/proc/net/sockstat similarity index 100% rename from collector/fixtures/sockstat rename to collector/fixtures/proc/net/sockstat diff --git a/collector/fixtures/tcpstat b/collector/fixtures/proc/net/tcpstat similarity index 100% rename from collector/fixtures/tcpstat rename to collector/fixtures/proc/net/tcpstat diff --git a/collector/fixtures/proc/stat b/collector/fixtures/proc/stat new file mode 100644 index 00000000..dabb96f7 --- /dev/null +++ b/collector/fixtures/proc/stat @@ -0,0 +1,16 @@ +cpu 301854 612 111922 8979004 3552 2 3944 0 0 0 +cpu0 44490 19 21045 1087069 220 1 3410 0 0 0 +cpu1 47869 23 16474 1110787 591 0 46 0 0 0 +cpu2 46504 36 15916 1112321 441 0 326 0 0 0 +cpu3 47054 102 15683 1113230 533 0 60 0 0 0 +cpu4 28413 25 10776 1140321 217 0 8 0 0 0 +cpu5 29271 101 11586 1136270 672 0 30 0 0 0 +cpu6 29152 36 10276 1139721 319 0 29 0 0 0 +cpu7 29098 268 10164 1139282 555 0 31 0 0 0 +intr 8885917 17 0 0 0 0 0 0 0 1 79281 0 0 0 0 0 0 0 231237 0 0 0 0 250586 103 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 223424 190745 13 906 1283803 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 38014093 +btime 1418183276 +processes 26442 +procs_running 2 +procs_blocked 0 +softirq 5057579 250191 1481983 1647 211099 186066 0 1783454 622196 12499 508444 diff --git a/collector/fixtures/file-nr b/collector/fixtures/proc/sys/fs/file-nr similarity index 100% rename from collector/fixtures/file-nr rename to collector/fixtures/proc/sys/fs/file-nr diff --git a/collector/fixtures/bonding/bond0/bonding/slaves b/collector/fixtures/sys/class/net/bond0/bonding/slaves similarity index 100% rename from collector/fixtures/bonding/bond0/bonding/slaves rename to collector/fixtures/sys/class/net/bond0/bonding/slaves diff --git a/collector/fixtures/bonding/bonding_masters b/collector/fixtures/sys/class/net/bonding_masters similarity index 100% rename from collector/fixtures/bonding/bonding_masters rename to collector/fixtures/sys/class/net/bonding_masters diff --git a/collector/fixtures/bonding/dmz/bonding/slaves b/collector/fixtures/sys/class/net/dmz/bonding/slaves similarity index 100% rename from collector/fixtures/bonding/dmz/bonding/slaves rename to collector/fixtures/sys/class/net/dmz/bonding/slaves diff --git a/collector/fixtures/bonding/dmz/slave_eth0/operstate b/collector/fixtures/sys/class/net/dmz/slave_eth0/operstate similarity index 100% rename from collector/fixtures/bonding/dmz/slave_eth0/operstate rename to collector/fixtures/sys/class/net/dmz/slave_eth0/operstate diff --git a/collector/fixtures/bonding/dmz/slave_eth4/operstate b/collector/fixtures/sys/class/net/dmz/slave_eth4/operstate similarity index 100% rename from collector/fixtures/bonding/dmz/slave_eth4/operstate rename to collector/fixtures/sys/class/net/dmz/slave_eth4/operstate diff --git a/collector/fixtures/bonding/int/bonding/slaves b/collector/fixtures/sys/class/net/int/bonding/slaves similarity index 100% rename from collector/fixtures/bonding/int/bonding/slaves rename to collector/fixtures/sys/class/net/int/bonding/slaves diff --git a/collector/fixtures/bonding/int/slave_eth1/operstate b/collector/fixtures/sys/class/net/int/slave_eth1/operstate similarity index 100% rename from collector/fixtures/bonding/int/slave_eth1/operstate rename to collector/fixtures/sys/class/net/int/slave_eth1/operstate diff --git a/collector/fixtures/bonding/int/slave_eth5/operstate b/collector/fixtures/sys/class/net/int/slave_eth5/operstate similarity index 100% rename from collector/fixtures/bonding/int/slave_eth5/operstate rename to collector/fixtures/sys/class/net/int/slave_eth5/operstate diff --git a/collector/interrupts_linux_test.go b/collector/interrupts_linux_test.go index 2977ee52..f076fe8a 100644 --- a/collector/interrupts_linux_test.go +++ b/collector/interrupts_linux_test.go @@ -19,7 +19,7 @@ import ( ) func TestInterrupts(t *testing.T) { - file, err := os.Open("fixtures/interrupts") + file, err := os.Open("fixtures/proc/interrupts") if err != nil { t.Fatal(err) } diff --git a/collector/ipvs_test.go b/collector/ipvs_test.go index ed1bc6a3..90287839 100644 --- a/collector/ipvs_test.go +++ b/collector/ipvs_test.go @@ -120,7 +120,7 @@ var ( ) func TestIPVSCollector(t *testing.T) { - if err := flag.Set("collector.procfs", "fixtures"); err != nil { + if err := flag.Set("collector.procfs", "fixtures/proc"); err != nil { t.Fatal(err) } collector, err := newIPVSCollector() @@ -182,7 +182,7 @@ func (c miniCollector) Describe(ch chan<- *prometheus.Desc) { } func TestIPVSCollectorResponse(t *testing.T) { - if err := flag.Set("collector.procfs", "fixtures"); err != nil { + if err := flag.Set("collector.procfs", "fixtures/proc"); err != nil { t.Fatal(err) } collector, err := NewIPVSCollector() @@ -194,7 +194,7 @@ func TestIPVSCollectorResponse(t *testing.T) { rw := httptest.NewRecorder() prometheus.Handler().ServeHTTP(rw, &http.Request{}) - metricsFile := "fixtures/net/ip_vs_result.txt" + metricsFile := "fixtures/ip_vs_result.txt" wantMetrics, err := ioutil.ReadFile(metricsFile) if err != nil { t.Fatalf("unable to read input test file %s: %s", metricsFile, err) diff --git a/collector/mdadm_test.go b/collector/mdadm_test.go index fa70b3f9..75108b36 100644 --- a/collector/mdadm_test.go +++ b/collector/mdadm_test.go @@ -18,7 +18,7 @@ import ( ) func TestMdadm(t *testing.T) { - mdStates, err := parseMdstat("fixtures/mdstat") + mdStates, err := parseMdstat("fixtures/proc/mdstat") if err != nil { t.Fatalf("parsing of reference-file failed entirely: %s", err) diff --git a/collector/meminfo_linux_test.go b/collector/meminfo_linux_test.go index ccb116db..c42bdf03 100644 --- a/collector/meminfo_linux_test.go +++ b/collector/meminfo_linux_test.go @@ -19,7 +19,7 @@ import ( ) func TestMemInfo(t *testing.T) { - file, err := os.Open("fixtures/meminfo") + file, err := os.Open("fixtures/proc/meminfo") if err != nil { t.Fatal(err) } diff --git a/collector/netdev_linux_test.go b/collector/netdev_linux_test.go index 04d3116f..9f27e433 100644 --- a/collector/netdev_linux_test.go +++ b/collector/netdev_linux_test.go @@ -20,7 +20,7 @@ import ( ) func TestNetDevStats(t *testing.T) { - file, err := os.Open("fixtures/net-dev") + file, err := os.Open("fixtures/proc/net/dev") if err != nil { t.Fatal(err) } diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index 8a35882f..c4eaa4c3 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go @@ -18,7 +18,7 @@ import ( "testing" ) -var fileName = "fixtures/netstat" +var fileName = "fixtures/proc/net/netstat" func TestNetStats(t *testing.T) { file, err := os.Open(fileName) diff --git a/collector/sockstat_linux_test.go b/collector/sockstat_linux_test.go index 6f4754b7..989a93b3 100644 --- a/collector/sockstat_linux_test.go +++ b/collector/sockstat_linux_test.go @@ -20,7 +20,7 @@ import ( ) func TestSockStats(t *testing.T) { - file, err := os.Open("fixtures/sockstat") + file, err := os.Open("fixtures/proc/net/sockstat") if err != nil { t.Fatal(err) } diff --git a/collector/tcpstat_linux_test.go b/collector/tcpstat_linux_test.go index 4681a040..da0bc1c6 100644 --- a/collector/tcpstat_linux_test.go +++ b/collector/tcpstat_linux_test.go @@ -19,7 +19,7 @@ import ( ) func TestTCPStat(t *testing.T) { - file, err := os.Open("fixtures/tcpstat") + file, err := os.Open("fixtures/proc/net/tcpstat") if err != nil { t.Fatal(err) }