├── .circleci └── config.yml ├── .dockerignore ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── golangci-lint.yml │ └── main.yml ├── .gitignore ├── .golangci.yml ├── .promu-cgo.yml ├── .promu.yml ├── .yamllint ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── MAINTAINERS.md ├── Makefile ├── Makefile.common ├── NOTICE ├── README.md ├── SECURITY.md ├── VERSION ├── checkmetrics.sh ├── collector ├── arp_linux.go ├── bcache_linux.go ├── bonding_linux.go ├── bonding_linux_test.go ├── boot_time_bsd.go ├── boot_time_solaris.go ├── btrfs_linux.go ├── btrfs_linux_test.go ├── buddyinfo.go ├── cgroups_linux.go ├── collector.go ├── collectorPerconaExtensions.go ├── conntrack_linux.go ├── cpu_common.go ├── cpu_darwin.go ├── cpu_dragonfly.go ├── cpu_dragonfly_test.go ├── cpu_freebsd.go ├── cpu_linux.go ├── cpu_linux_test.go ├── cpu_openbsd.go ├── cpu_solaris.go ├── cpufreq_linux.go ├── cpufreq_solaris.go ├── device_filter.go ├── device_filter_test.go ├── devstat_dragonfly.go ├── devstat_freebsd.c ├── devstat_freebsd.go ├── devstat_freebsd.h ├── diskstats_common.go ├── diskstats_darwin.go ├── diskstats_linux.go ├── diskstats_linux_test.go ├── diskstats_openbsd.go ├── diskstats_openbsd_amd64.go ├── dmi.go ├── drbd_linux.go ├── drm_linux.go ├── edac_linux.go ├── entropy_linux.go ├── ethtool_linux.go ├── ethtool_linux_test.go ├── exec_bsd.go ├── fibrechannel_linux.go ├── filefd_linux.go ├── filefd_linux_test.go ├── filesystem_bsd.go ├── filesystem_common.go ├── filesystem_freebsd.go ├── filesystem_linux.go ├── filesystem_linux_test.go ├── filesystem_openbsd_amd64.go ├── fixtures │ ├── e2e-64k-page-output.txt │ ├── e2e-output.txt │ ├── ethtool │ │ ├── bond0 │ │ │ └── statistics │ │ └── eth0 │ │ │ ├── driver │ │ │ ├── settings │ │ │ └── statistics │ ├── ip_vs_result.txt │ ├── ip_vs_result_lbs_local_address_local_port.txt │ ├── ip_vs_result_lbs_local_port.txt │ ├── ip_vs_result_lbs_none.txt │ ├── proc │ │ ├── 1 │ │ │ ├── mounts │ │ │ └── stat │ │ ├── 10 │ │ │ ├── mountinfo │ │ │ ├── mountstats │ │ │ └── stat │ │ ├── 11 │ │ │ ├── .missing_stat │ │ │ └── stat │ │ ├── buddyinfo │ │ ├── cgroups │ │ ├── cpuinfo │ │ ├── diskstats │ │ ├── drbd │ │ ├── interrupts │ │ ├── loadavg │ │ ├── mdstat │ │ ├── meminfo │ │ ├── net │ │ │ ├── arp │ │ │ ├── ip_vs │ │ │ ├── ip_vs_stats │ │ │ ├── netstat │ │ │ ├── rpc │ │ │ │ ├── nfs │ │ │ │ └── nfsd │ │ │ ├── snmp │ │ │ ├── snmp6 │ │ │ ├── sockstat │ │ │ ├── sockstat6 │ │ │ ├── softnet_stat │ │ │ ├── stat │ │ │ │ ├── arp_cache │ │ │ │ ├── ndisc_cache │ │ │ │ └── nf_conntrack │ │ │ └── udp │ │ ├── pressure │ │ │ ├── cpu │ │ │ ├── io │ │ │ └── memory │ │ ├── schedstat │ │ ├── self │ │ ├── slabinfo │ │ ├── spl │ │ │ └── kstat │ │ │ │ └── zfs │ │ │ │ ├── abdstats │ │ │ │ ├── arcstats │ │ │ │ ├── dbuf_stats │ │ │ │ ├── dmu_tx │ │ │ │ ├── dnodestats │ │ │ │ ├── fm │ │ │ │ ├── pool1 │ │ │ │ ├── io │ │ │ │ ├── objset-1 │ │ │ │ ├── objset-2 │ │ │ │ └── state │ │ │ │ ├── poolz1 │ │ │ │ ├── io │ │ │ │ ├── objset-1 │ │ │ │ ├── objset-2 │ │ │ │ └── state │ │ │ │ ├── vdev_cache_stats │ │ │ │ ├── vdev_mirror_stats │ │ │ │ ├── xuio_stats │ │ │ │ ├── zfetchstats │ │ │ │ └── zil │ │ ├── stat │ │ ├── sys │ │ │ ├── fs │ │ │ │ └── file-nr │ │ │ ├── kernel │ │ │ │ ├── pid_max │ │ │ │ ├── random │ │ │ │ │ ├── entropy_avail │ │ │ │ │ └── poolsize │ │ │ │ ├── seccomp │ │ │ │ │ └── actions_avail │ │ │ │ └── threads-max │ │ │ ├── net │ │ │ │ └── netfilter │ │ │ │ │ ├── nf_conntrack_count │ │ │ │ │ └── nf_conntrack_max │ │ │ ├── pid_max │ │ │ └── threads-max │ │ ├── vmstat │ │ └── zoneinfo │ ├── qdisc │ │ └── results.json │ ├── sys.ttar │ ├── textfile │ │ ├── client_side_timestamp.out │ │ ├── client_side_timestamp │ │ │ └── metrics.prom │ │ ├── different_metric_types.out │ │ ├── different_metric_types │ │ │ └── metrics.prom │ │ ├── glob_extra_dimension.out │ │ ├── histogram.out │ │ ├── histogram │ │ │ └── metrics.prom │ │ ├── histogram_extra_dimension.out │ │ ├── histogram_extra_dimension │ │ │ └── metrics.prom │ │ ├── inconsistent_metrics.out │ │ ├── inconsistent_metrics │ │ │ └── metrics.prom │ │ ├── metrics_merge_different_help.out │ │ ├── metrics_merge_different_help │ │ │ ├── a.prom │ │ │ └── b.prom │ │ ├── metrics_merge_empty_help.out │ │ ├── metrics_merge_empty_help │ │ │ ├── a.prom │ │ │ └── b.prom │ │ ├── metrics_merge_no_help.out │ │ ├── metrics_merge_no_help │ │ │ ├── a.prom │ │ │ └── b.prom │ │ ├── metrics_merge_same_help.out │ │ ├── metrics_merge_same_help │ │ │ ├── a.prom │ │ │ └── b.prom │ │ ├── no_metric_files.out │ │ ├── no_metric_files │ │ │ └── non_matching_file.txt │ │ ├── nonexistent_path.out │ │ ├── summary.out │ │ ├── summary │ │ │ └── metrics.prom │ │ ├── summary_extra_dimension.out │ │ ├── summary_extra_dimension │ │ │ └── metrics.prom │ │ ├── two_metric_files.out │ │ └── two_metric_files │ │ │ ├── metrics1.prom │ │ │ ├── metrics2.prom │ │ │ └── non_matching_file.txt │ ├── udev │ │ └── data │ │ │ ├── b11:0 │ │ │ ├── b179:0 │ │ │ ├── b179:1 │ │ │ ├── b179:2 │ │ │ ├── b252:0 │ │ │ ├── b252:1 │ │ │ ├── b252:2 │ │ │ ├── b252:3 │ │ │ ├── b252:4 │ │ │ ├── b252:5 │ │ │ ├── b254:0 │ │ │ ├── b259:0 │ │ │ ├── b8:0 │ │ │ ├── b8:16 │ │ │ └── b8:32 │ ├── usr │ │ └── lib │ │ │ └── os-release │ └── wifi │ │ ├── interfaces.json │ │ └── wlan0 │ │ ├── bss.json │ │ └── stationinfo.json ├── fixtures_bindmount │ └── proc │ │ └── mounts ├── fixtures_hidepid │ └── proc │ │ └── mounts ├── helper.go ├── helper_test.go ├── hwmon_linux.go ├── infiniband_linux.go ├── interrupts_common.go ├── interrupts_linux.go ├── interrupts_linux_test.go ├── interrupts_openbsd.go ├── interrupts_openbsd_amd64.go ├── ipvs_linux.go ├── ipvs_linux_test.go ├── ksmd_linux.go ├── kvm_bsd.c ├── kvm_bsd.go ├── kvm_bsd.h ├── lnstat_linux.go ├── loadavg.go ├── loadavg_bsd.go ├── loadavg_linux.go ├── loadavg_linux_test.go ├── loadavg_solaris.go ├── logind_linux.go ├── logind_linux_test.go ├── mdadm_linux.go ├── meminfo.go ├── meminfo_darwin.go ├── meminfo_linux.go ├── meminfo_linux_test.go ├── meminfo_numa_linux.go ├── meminfo_numa_linux_test.go ├── meminfo_openbsd.go ├── meminfo_openbsd_amd64.go ├── memory_bsd.go ├── mountstats_linux.go ├── netclass_linux.go ├── netdev_bsd.go ├── netdev_common.go ├── netdev_darwin.go ├── netdev_linux.go ├── netdev_linux_test.go ├── netdev_openbsd.go ├── netdev_openbsd_amd64.go ├── netstat_linux.go ├── netstat_linux_test.go ├── network_route_linux.go ├── nfs_linux.go ├── nfsd_linux.go ├── ntp.go ├── nvme_linux.go ├── os_release.go ├── os_release_test.go ├── paths.go ├── paths_test.go ├── perf_linux.go ├── perf_linux_test.go ├── powersupplyclass.go ├── powersupplyclass_darwin.go ├── powersupplyclass_linux.go ├── pressure_linux.go ├── processes_linux.go ├── processes_linux_test.go ├── qdisc_linux.go ├── rapl_linux.go ├── runit.go ├── schedstat_linux.go ├── selinux_linux.go ├── slabinfo_linux.go ├── sockstat_linux.go ├── softnet_linux.go ├── stat_linux.go ├── supervisord.go ├── sysctl_bsd.go ├── sysctl_linux.go ├── sysctl_openbsd_amd64.go ├── systemd_linux.go ├── systemd_linux_test.go ├── tapestats_linux.go ├── tcpstat_linux.go ├── tcpstat_linux_test.go ├── textfile.go ├── textfile_test.go ├── thermal_darwin.go ├── thermal_zone_linux.go ├── time.go ├── time_linux.go ├── time_other.go ├── timex.go ├── udp_queues_linux.go ├── uname.go ├── uname_bsd.go ├── uname_linux.go ├── vmstat_linux.go ├── wifi_linux.go ├── xfs_linux.go ├── zfs.go ├── zfs_freebsd.go ├── zfs_linux.go ├── zfs_linux_test.go ├── zfs_solaris.go └── zoneinfo_linux.go ├── docs ├── TIME.md ├── V0_16_UPGRADE_GUIDE.md ├── example-16-compatibility-rules-new-to-old.yml ├── example-16-compatibility-rules.yml ├── example-17-compatibility-rules-new-to-old.yml ├── example-17-compatibility-rules.yml └── node-mixin │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── alerts.jsonnet │ ├── alerts │ └── alerts.libsonnet │ ├── config.libsonnet │ ├── dashboards.jsonnet │ ├── dashboards │ ├── dashboards.libsonnet │ ├── node.libsonnet │ └── use.libsonnet │ ├── jsonnetfile.json │ ├── lib │ └── prom-mixin.libsonnet │ ├── mixin.libsonnet │ ├── rules.jsonnet │ └── rules │ └── rules.libsonnet ├── end-to-end-test.sh ├── example-rules.yml ├── example.prom ├── examples ├── init.d │ └── node_exporter ├── launchctl │ ├── README.md │ └── io.prometheus.node_exporter.plist ├── openbsd-rc.d │ └── node_exporter ├── openwrt-init.d │ └── node_exporter └── systemd │ ├── README.md │ ├── node_exporter.service │ └── sysconfig.node_exporter ├── go.mod ├── go.sum ├── node_exporter.go ├── node_exporter_test.go ├── percona ├── perconacollector │ ├── perconacollector.go │ ├── standard.go │ └── textfile.directory.go └── tests │ └── upstream_update │ ├── Makefile │ ├── assets │ ├── node_exporter_percona.tar.xz │ └── test.exporter-flags.txt │ ├── env_prepare_test.go │ ├── metrics_test.go │ ├── performance_test.go │ ├── readme.md │ └── utils_test.go ├── scripts └── codespell_ignore.txt ├── staticcheck.conf ├── test_image.sh ├── text_collector_examples └── README.md ├── tls_config_noAuth.bad.yml └── ttar /.dockerignore: -------------------------------------------------------------------------------- 1 | .build/ 2 | .tarballs/ 3 | 4 | !.build/linux-amd64 5 | !.build/linux-armv7 6 | !.build/linux-arm64 7 | !.build/linux-ppc64le 8 | !.build/linux-s390x 9 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @percona/pmm-review-exporters 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 18 | ### Host operating system: output of `uname -a` 19 | 20 | ### node_exporter version: output of `node_exporter --version` 21 | 22 | 23 | ### node_exporter command line flags 24 | 25 | 26 | ### Are you running node_exporter in Docker? 27 | 28 | 29 | ### What did you do that produced an error? 30 | 31 | ### What did you expect to see? 32 | 33 | ### What did you see instead? 34 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "gomod" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | - package-ecosystem: "docker" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | - package-ecosystem: "github-actions" 13 | directory: "/" 14 | schedule: 15 | interval: "weekly" 16 | - package-ecosystem: "gomod" 17 | directory: "/" 18 | target-branch: "v3" 19 | schedule: 20 | interval: "weekly" 21 | - package-ecosystem: "docker" 22 | directory: "/" 23 | target-branch: "v3" 24 | schedule: 25 | interval: "weekly" 26 | - package-ecosystem: "github-actions" 27 | directory: "/" 28 | target-branch: "v3" 29 | schedule: 30 | interval: "weekly" 31 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | name: golangci-lint 2 | on: 3 | push: 4 | paths: 5 | - "go.sum" 6 | - "go.mod" 7 | - "**.go" 8 | - ".github/workflows/golangci-lint.yml" 9 | - ".golangci.yml" 10 | pull_request: 11 | 12 | jobs: 13 | golangci: 14 | name: lint 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | 20 | - name: install Go 21 | uses: actions/setup-go@v5 22 | with: 23 | go-version-file: ${{ github.workspace }}/go.mod 24 | 25 | - name: Install snmp_exporter/generator dependencies 26 | run: sudo apt-get update && sudo apt-get -y install libsnmp-dev 27 | if: github.repository == 'prometheus/snmp_exporter' 28 | 29 | - name: Lint 30 | uses: golangci/golangci-lint-action@v6.5.2 31 | with: 32 | version: v1.62.0 33 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Node Exporter CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | tags: 8 | - 'v*' 9 | pull_request: 10 | 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-go@v5 17 | with: 18 | go-version-file: ${{ github.workspace }}/go.mod 19 | - run: go mod download 20 | - run: make test-e2e 21 | - name: Upload artifact 22 | uses: actions/upload-artifact@v4 23 | with: 24 | name: node_exporter 25 | path: node_exporter 26 | 27 | codespell: 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v4 31 | - run: sudo pip install codespell 32 | - run: codespell --skip=".git,ttar,go.mod,go.sum,*pem,./collector/fixtures" -I scripts/codespell_ignore.txt 33 | 34 | test_mixins: 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v4 38 | - uses: actions/setup-go@v5 39 | with: 40 | go-version-file: ${{ github.workspace }}/go.mod 41 | - run: go install github.com/google/go-jsonnet/cmd/jsonnet@latest 42 | - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest 43 | - run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest 44 | - run: make promtool 45 | - run: make -C docs/node-mixin clean 46 | - run: make -C docs/node-mixin jb_install 47 | - run: make -C docs/node-mixin 48 | - run: git diff --exit-code 49 | 50 | build: 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@v4 54 | - uses: actions/setup-go@v5 55 | with: 56 | go-version-file: ${{ github.workspace }}/go.mod 57 | - run: docker run --privileged linuxkit/binfmt:v0.8 58 | - run: make promtool 59 | - run: make promu 60 | - run: promu crossbuild -v --parallelism 3 --parallelism-thread 3 61 | - run: promu --config .promu-cgo.yml crossbuild -v --parallelism 3 --parallelism-thread 3 62 | - name: Upload artifact 63 | uses: actions/upload-artifact@v4 64 | with: 65 | name: build 66 | path: .build 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | dependencies-stamp 24 | /node_exporter 25 | /.build 26 | /.deps 27 | /.release 28 | /.tarballs 29 | 30 | # Intellij 31 | 32 | /.idea 33 | *.iml 34 | 35 | # Test files extracted from ttar 36 | collector/fixtures/sys/ 37 | 38 | /vendor 39 | 40 | # upstream updating dev test 41 | percona/tests/upstream_update/metrics.upstream.txt 42 | /percona/tests/upstream_update/assets/metrics.names.new.txt 43 | /percona/tests/upstream_update/assets/metrics.names.old.txt 44 | /percona/tests/upstream_update/assets/metrics.new.txt 45 | /percona/tests/upstream_update/assets/metrics.old.txt 46 | /percona/tests/upstream_update/assets/node_exporter 47 | /percona/tests/upstream_update/assets/node_exporter_percona 48 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | enable: 3 | - revive 4 | disable: 5 | # Disable soon to deprecated[1] linters that lead to false 6 | # positives when build tags disable certain files[2] 7 | # 1: https://github.com/golangci/golangci-lint/issues/1841 8 | # 2: https://github.com/prometheus/node_exporter/issues/1545 9 | - unused 10 | 11 | issues: 12 | exclude-rules: 13 | - path: _test.go 14 | linters: 15 | - errcheck 16 | 17 | linters-settings: 18 | errcheck: 19 | exclude-functions: 20 | - (net/http.ResponseWriter).Write 21 | - (github.com/go-kit/log.Logger).Log 22 | -------------------------------------------------------------------------------- /.promu-cgo.yml: -------------------------------------------------------------------------------- 1 | go: 2 | # Whenever the Go version is updated here, .circle/config.yml and 3 | # .promu.yml should also be updated. 4 | version: 1.19 5 | cgo: true 6 | repository: 7 | path: github.com/prometheus/node_exporter 8 | build: 9 | binaries: 10 | - name: node_exporter 11 | flags: -a -tags 'netgo osusergo static_build' 12 | ldflags: | 13 | -X github.com/prometheus/common/version.Version={{.Version}} 14 | -X github.com/prometheus/common/version.Revision={{.Revision}} 15 | -X github.com/prometheus/common/version.Branch={{.Branch}} 16 | -X github.com/prometheus/common/version.BuildUser={{user}}@{{host}} 17 | -X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} 18 | tarball: 19 | files: 20 | - LICENSE 21 | - NOTICE 22 | crossbuild: 23 | platforms: 24 | - darwin/amd64 25 | - darwin/arm64 26 | - netbsd/amd64 27 | - netbsd/386 28 | -------------------------------------------------------------------------------- /.promu.yml: -------------------------------------------------------------------------------- 1 | go: 2 | # Whenever the Go version is updated here, .circle/config.yml and 3 | # .promu-cgo.yml should also be updated. 4 | version: 1.19 5 | repository: 6 | path: github.com/prometheus/node_exporter 7 | build: 8 | binaries: 9 | - name: node_exporter 10 | flags: -a -tags 'netgo osusergo static_build' 11 | ldflags: | 12 | -X github.com/prometheus/common/version.Version={{.Version}} 13 | -X github.com/prometheus/common/version.Revision={{.Revision}} 14 | -X github.com/prometheus/common/version.Branch={{.Branch}} 15 | -X github.com/prometheus/common/version.BuildUser={{user}}@{{host}} 16 | -X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} 17 | tarball: 18 | files: 19 | - LICENSE 20 | - NOTICE 21 | crossbuild: 22 | platforms: 23 | - linux 24 | - openbsd/amd64 25 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | braces: 6 | max-spaces-inside: 1 7 | level: error 8 | brackets: 9 | max-spaces-inside: 1 10 | level: error 11 | commas: disable 12 | comments: disable 13 | comments-indentation: disable 14 | document-start: disable 15 | indentation: 16 | spaces: consistent 17 | indent-sequences: consistent 18 | key-duplicates: 19 | ignore: | 20 | config/testdata/section_key_dup.bad.yml 21 | line-length: disable 22 | truthy: 23 | ignore: | 24 | .github/workflows/codeql-analysis.yml 25 | .github/workflows/funcbench.yml 26 | .github/workflows/fuzzing.yml 27 | .github/workflows/prombench.yml 28 | .github/workflows/golangci-lint.yml 29 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Prometheus Community Code of Conduct 2 | 3 | Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md). 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Prometheus uses GitHub to manage reviews of pull requests. 4 | 5 | * If you have a trivial fix or improvement, go ahead and create a pull request, 6 | addressing (with `@...`) the maintainer of this repository (see 7 | [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request. 8 | 9 | * If you plan to do something more involved, first discuss your ideas 10 | on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers). 11 | This will avoid unnecessary work and surely give you and us a good deal 12 | of inspiration. 13 | 14 | * Relevant coding style guidelines are the [Go Code Review 15 | Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) 16 | and the _Formatting and style_ section of Peter Bourgon's [Go: Best 17 | Practices for Production 18 | Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style). 19 | 20 | * Sign your work to certify that your changes were created by yourself or you 21 | have the right to submit it under our license. Read 22 | https://developercertificate.org/ for all details and append your sign-off to 23 | every commit message like this: 24 | 25 | Signed-off-by: Random J Developer 26 | 27 | 28 | ## Collector Implementation Guidelines 29 | 30 | The Node Exporter is not a general monitoring agent. Its sole purpose is to 31 | expose machine metrics, as oppose to service metrics, with the only exception 32 | being the textfile collector. 33 | 34 | The metrics should not get transformed in a way that is hardware specific and 35 | would require maintaining any form of vendor based mappings or conditions. If 36 | for example a proc file contains the magic number 42 as some identifier, the 37 | Node Exporter should expose it as it is and not keep a mapping in code to make 38 | this human readable. Instead, the textfile collector can be used to add a static 39 | metric which can be joined with the metrics exposed by the exporter to get human 40 | readable identifier. 41 | 42 | A Collector may only read `/proc` or `/sys` files, use system calls or local 43 | sockets to retrieve metrics. It may not require root privileges. Running 44 | external commands is not allowed for performance and reliability reasons. Use a 45 | dedicated exporter instead or gather the metrics via the textfile collector. 46 | 47 | The Node Exporter tries to support the most common machine metrics. For more 48 | exotic metrics, use the textfile collector or a dedicated Exporter. 49 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ARCH="amd64" 2 | ARG OS="linux" 3 | FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest 4 | LABEL maintainer="The Prometheus Authors " 5 | 6 | ARG ARCH="amd64" 7 | ARG OS="linux" 8 | COPY .build/${OS}-${ARCH}/node_exporter /bin/node_exporter 9 | 10 | EXPOSE 9100 11 | USER nobody 12 | ENTRYPOINT [ "/bin/node_exporter" ] 13 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Ben Kochie @SuperQ 2 | * Johannes 'fish' Ziemke @discordianfish 3 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Configurable modular Prometheus exporter for various node metrics. 2 | Copyright 2013-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | 7 | The following components are included in this product: 8 | 9 | wifi 10 | https://github.com/mdlayher/wifi 11 | Copyright 2016-2017 Matt Layher 12 | Licensed under the MIT License 13 | 14 | netlink 15 | https://github.com/mdlayher/netlink 16 | Copyright 2016-2017 Matt Layher 17 | Licensed under the MIT License 18 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting a security issue 2 | 3 | The Prometheus security policy, including how to report vulnerabilities, can be 4 | found here: 5 | 6 | 7 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.4.0 2 | -------------------------------------------------------------------------------- /checkmetrics.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ ( -z "$1" ) || ( -z "$2" ) ]]; then 4 | echo "usage: ./checkmetrics.sh /usr/bin/promtool e2e-output.txt" 5 | exit 1 6 | fi 7 | 8 | # Ignore known issues in auto-generated and network specific collectors. 9 | lint=$($1 check metrics < "$2" 2>&1 | grep -v -E "^node_(entropy|memory|netstat|wifi_station)_") 10 | 11 | if [[ -n $lint ]]; then 12 | echo -e "Some Prometheus metrics do not follow best practices:\n" 13 | echo "$lint" 14 | 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /collector/bonding_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "testing" 18 | ) 19 | 20 | func TestBonding(t *testing.T) { 21 | bondingStats, err := readBondingStats("fixtures/sys/class/net") 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | if bondingStats["bond0"][0] != 0 || bondingStats["bond0"][1] != 0 { 26 | t.Fatal("bond0 in unexpected state") 27 | } 28 | 29 | if bondingStats["int"][0] != 2 || bondingStats["int"][1] != 1 { 30 | t.Fatal("int in unexpected state") 31 | } 32 | 33 | if bondingStats["dmz"][0] != 2 || bondingStats["dmz"][1] != 2 { 34 | t.Fatal("dmz in unexpected state") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /collector/boot_time_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (freebsd || dragonfly || openbsd || netbsd || darwin) && !noboottime 15 | // +build freebsd dragonfly openbsd netbsd darwin 16 | // +build !noboottime 17 | 18 | package collector 19 | 20 | import ( 21 | "github.com/go-kit/log" 22 | "github.com/prometheus/client_golang/prometheus" 23 | "golang.org/x/sys/unix" 24 | ) 25 | 26 | type bootTimeCollector struct { 27 | logger log.Logger 28 | } 29 | 30 | func init() { 31 | registerCollector("boottime", defaultEnabled, newBootTimeCollector) 32 | } 33 | 34 | // newBootTimeCollector returns a new Collector exposing system boot time on BSD systems. 35 | func newBootTimeCollector(logger log.Logger) (Collector, error) { 36 | return &bootTimeCollector{ 37 | logger: logger, 38 | }, nil 39 | } 40 | 41 | // Update pushes boot time onto ch 42 | func (c *bootTimeCollector) Update(ch chan<- prometheus.Metric) error { 43 | tv, err := unix.SysctlTimeval("kern.boottime") 44 | if err != nil { 45 | return err 46 | } 47 | 48 | // This conversion maintains the usec precision. Using the time 49 | // package did not. 50 | v := float64(tv.Sec) + (float64(tv.Usec) / float64(1000*1000)) 51 | 52 | ch <- prometheus.MustNewConstMetric( 53 | prometheus.NewDesc( 54 | prometheus.BuildFQName(namespace, "", "boot_time_seconds"), 55 | "Unix time of last boot, including microseconds.", 56 | nil, nil, 57 | ), prometheus.GaugeValue, v) 58 | 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /collector/boot_time_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build solaris && !noboottime 15 | // +build solaris,!noboottime 16 | 17 | package collector 18 | 19 | import ( 20 | "github.com/go-kit/log" 21 | "github.com/illumos/go-kstat" 22 | "github.com/prometheus/client_golang/prometheus" 23 | ) 24 | 25 | type bootTimeCollector struct { 26 | boottime typedDesc 27 | logger log.Logger 28 | } 29 | 30 | func init() { 31 | registerCollector("boottime", defaultEnabled, newBootTimeCollector) 32 | } 33 | 34 | func newBootTimeCollector(logger log.Logger) (Collector, error) { 35 | return &bootTimeCollector{ 36 | boottime: typedDesc{ 37 | prometheus.NewDesc( 38 | prometheus.BuildFQName(namespace, "", "boot_time_seconds"), 39 | "Unix time of last boot, including microseconds.", 40 | nil, nil, 41 | ), prometheus.GaugeValue}, 42 | logger: logger, 43 | }, nil 44 | } 45 | 46 | // newBootTimeCollector returns a new Collector exposing system boot time on Solaris systems. 47 | // Update pushes boot time onto ch 48 | func (c *bootTimeCollector) Update(ch chan<- prometheus.Metric) error { 49 | tok, err := kstat.Open() 50 | if err != nil { 51 | return err 52 | } 53 | 54 | defer tok.Close() 55 | 56 | ks, err := tok.Lookup("unix", 0, "system_misc") 57 | if err != nil { 58 | return err 59 | } 60 | 61 | v, err := ks.GetNamed("boot_time") 62 | if err != nil { 63 | return err 64 | } 65 | 66 | ch <- c.boottime.mustNewConstMetric(float64(v.UintVal)) 67 | 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /collector/buddyinfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nobuddyinfo && !netbsd 15 | // +build !nobuddyinfo,!netbsd 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | 23 | "github.com/go-kit/log" 24 | "github.com/go-kit/log/level" 25 | "github.com/prometheus/client_golang/prometheus" 26 | "github.com/prometheus/procfs" 27 | ) 28 | 29 | const ( 30 | buddyInfoSubsystem = "buddyinfo" 31 | ) 32 | 33 | type buddyinfoCollector struct { 34 | fs procfs.FS 35 | desc *prometheus.Desc 36 | logger log.Logger 37 | } 38 | 39 | func init() { 40 | registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector) 41 | } 42 | 43 | // NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats. 44 | func NewBuddyinfoCollector(logger log.Logger) (Collector, error) { 45 | desc := prometheus.NewDesc( 46 | prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"), 47 | "Count of free blocks according to size.", 48 | []string{"node", "zone", "size"}, nil, 49 | ) 50 | fs, err := procfs.NewFS(*procPath) 51 | if err != nil { 52 | return nil, fmt.Errorf("failed to open procfs: %w", err) 53 | } 54 | return &buddyinfoCollector{fs, desc, logger}, nil 55 | } 56 | 57 | // Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific 58 | // buddyinfo metrics. 59 | func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error { 60 | buddyInfo, err := c.fs.BuddyInfo() 61 | if err != nil { 62 | return fmt.Errorf("couldn't get buddyinfo: %w", err) 63 | } 64 | 65 | level.Debug(c.logger).Log("msg", "Set node_buddy", "buddyInfo", buddyInfo) 66 | for _, entry := range buddyInfo { 67 | for size, value := range entry.Sizes { 68 | ch <- prometheus.MustNewConstMetric( 69 | c.desc, 70 | prometheus.GaugeValue, value, 71 | entry.Node, entry.Zone, strconv.Itoa(size), 72 | ) 73 | } 74 | } 75 | return nil 76 | } 77 | -------------------------------------------------------------------------------- /collector/cgroups_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nostat 15 | // +build !nostat 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/go-kit/log" 23 | "github.com/prometheus/client_golang/prometheus" 24 | "github.com/prometheus/procfs" 25 | ) 26 | 27 | const cgroupsCollectorSubsystem = "cgroups" 28 | 29 | type cgroupSummaryCollector struct { 30 | fs procfs.FS 31 | cgroups *prometheus.Desc 32 | enabled *prometheus.Desc 33 | logger log.Logger 34 | } 35 | 36 | func init() { 37 | registerCollector(cgroupsCollectorSubsystem, defaultDisabled, NewCgroupSummaryCollector) 38 | } 39 | 40 | // NewCgroupSummaryCollector returns a new Collector exposing a summary of cgroups. 41 | func NewCgroupSummaryCollector(logger log.Logger) (Collector, error) { 42 | fs, err := procfs.NewFS(*procPath) 43 | if err != nil { 44 | return nil, fmt.Errorf("failed to open procfs: %w", err) 45 | } 46 | return &cgroupSummaryCollector{ 47 | fs: fs, 48 | cgroups: prometheus.NewDesc( 49 | prometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, "cgroups"), 50 | "Current cgroup number of the subsystem.", 51 | []string{"subsys_name"}, nil, 52 | ), 53 | enabled: prometheus.NewDesc( 54 | prometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, "enabled"), 55 | "Current cgroup number of the subsystem.", 56 | []string{"subsys_name"}, nil, 57 | ), 58 | logger: logger, 59 | }, nil 60 | } 61 | 62 | // Update implements Collector and exposes cgroup statistics. 63 | func (c *cgroupSummaryCollector) Update(ch chan<- prometheus.Metric) error { 64 | cgroupSummarys, err := c.fs.CgroupSummarys() 65 | if err != nil { 66 | return err 67 | } 68 | for _, cs := range cgroupSummarys { 69 | ch <- prometheus.MustNewConstMetric(c.cgroups, prometheus.GaugeValue, float64(cs.Cgroups), cs.SubsysName) 70 | ch <- prometheus.MustNewConstMetric(c.enabled, prometheus.GaugeValue, float64(cs.Enabled), cs.SubsysName) 71 | } 72 | return nil 73 | } 74 | -------------------------------------------------------------------------------- /collector/collectorPerconaExtensions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package collector includes all individual collectors to gather and export system metrics. 15 | package collector 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/go-kit/log" 21 | "gopkg.in/alecthomas/kingpin.v2" 22 | ) 23 | 24 | func RegisterCollectorPublic(collector string, isDefaultEnabled bool, factory func(logger log.Logger) (Collector, error)) { 25 | registerCollector(collector, isDefaultEnabled, factory) 26 | } 27 | 28 | func ReplaceCollector(collector string, isDefaultEnabled bool, factory func(logger log.Logger) (Collector, error)) { 29 | delete(factories, collector) 30 | /*var helpDefaultState string 31 | if isDefaultEnabled { 32 | helpDefaultState = "enabled" 33 | } else { 34 | helpDefaultState = "disabled" 35 | }*/ 36 | 37 | flagName := fmt.Sprintf("collector.%s", collector) 38 | //flagHelp := fmt.Sprintf("Enable the %s collector (default: %s).", collector, helpDefaultState) 39 | defaultValue := fmt.Sprintf("%v", isDefaultEnabled) 40 | flagModel := kingpin.CommandLine.GetFlag(flagName) 41 | 42 | flag := flagModel.Default(defaultValue).Action(collectorFlagAction(collector)).Bool() 43 | collectorState[collector] = flag 44 | 45 | factories[collector] = factory 46 | } 47 | -------------------------------------------------------------------------------- /collector/cpu_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nocpu 15 | // +build !nocpu 16 | 17 | package collector 18 | 19 | import ( 20 | "github.com/prometheus/client_golang/prometheus" 21 | ) 22 | 23 | const ( 24 | cpuCollectorSubsystem = "cpu" 25 | ) 26 | 27 | var ( 28 | nodeCPUSecondsDesc = prometheus.NewDesc( 29 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "seconds_total"), 30 | "Seconds the CPUs spent in each mode.", 31 | []string{"cpu", "mode"}, nil, 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /collector/cpu_dragonfly_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nocpu 15 | // +build !nocpu 16 | 17 | package collector 18 | 19 | import ( 20 | "runtime" 21 | "testing" 22 | ) 23 | 24 | func TestCPU(t *testing.T) { 25 | var ( 26 | fieldsCount = 5 27 | times, err = getDragonFlyCPUTimes() 28 | ) 29 | 30 | if err != nil { 31 | t.Fatalf("expected no error, got %v", err) 32 | } 33 | 34 | if len(times) == 0 { 35 | t.Fatalf("no cputimes found") 36 | } 37 | 38 | want := runtime.NumCPU() * fieldsCount 39 | if len(times) != want { 40 | t.Fatalf("should have %d cpuTimes: got %d", want, len(times)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /collector/cpu_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build solaris && !nocpu 15 | // +build solaris,!nocpu 16 | 17 | package collector 18 | 19 | import ( 20 | "strconv" 21 | 22 | "github.com/go-kit/log" 23 | "github.com/illumos/go-kstat" 24 | "github.com/prometheus/client_golang/prometheus" 25 | ) 26 | 27 | // #include 28 | import "C" 29 | 30 | type cpuCollector struct { 31 | cpu typedDesc 32 | logger log.Logger 33 | } 34 | 35 | func init() { 36 | registerCollector("cpu", defaultEnabled, NewCpuCollector) 37 | } 38 | 39 | func NewCpuCollector(logger log.Logger) (Collector, error) { 40 | return &cpuCollector{ 41 | cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue}, 42 | logger: logger, 43 | }, nil 44 | } 45 | 46 | func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error { 47 | ncpus := C.sysconf(C._SC_NPROCESSORS_ONLN) 48 | 49 | tok, err := kstat.Open() 50 | if err != nil { 51 | return err 52 | } 53 | 54 | defer tok.Close() 55 | 56 | for cpu := 0; cpu < int(ncpus); cpu++ { 57 | ksCPU, err := tok.Lookup("cpu", cpu, "sys") 58 | if err != nil { 59 | return err 60 | } 61 | 62 | for k, v := range map[string]string{ 63 | "idle": "cpu_ticks_idle", 64 | "kernel": "cpu_ticks_kernel", 65 | "user": "cpu_ticks_user", 66 | "wait": "cpu_ticks_wait", 67 | } { 68 | kstatValue, err := ksCPU.GetNamed(v) 69 | if err != nil { 70 | return err 71 | } 72 | 73 | ch <- c.cpu.mustNewConstMetric(float64(kstatValue.UintVal), strconv.Itoa(cpu), k) 74 | } 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /collector/device_filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "regexp" 18 | ) 19 | 20 | type deviceFilter struct { 21 | ignorePattern *regexp.Regexp 22 | acceptPattern *regexp.Regexp 23 | } 24 | 25 | func newDeviceFilter(ignoredPattern, acceptPattern string) (f deviceFilter) { 26 | if ignoredPattern != "" { 27 | f.ignorePattern = regexp.MustCompile(ignoredPattern) 28 | } 29 | 30 | if acceptPattern != "" { 31 | f.acceptPattern = regexp.MustCompile(acceptPattern) 32 | } 33 | 34 | return 35 | } 36 | 37 | // ignores returns whether the device should be ignored 38 | func (f *deviceFilter) ignored(name string) bool { 39 | return ((f.ignorePattern != nil && f.ignorePattern.MatchString(name)) || 40 | (f.acceptPattern != nil && !f.acceptPattern.MatchString(name))) 41 | } 42 | -------------------------------------------------------------------------------- /collector/device_filter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "testing" 18 | ) 19 | 20 | func TestDeviceFilter(t *testing.T) { 21 | tests := []struct { 22 | ignore string 23 | accept string 24 | name string 25 | expectedResult bool 26 | }{ 27 | {"", "", "eth0", false}, 28 | {"", "^💩0$", "💩0", false}, 29 | {"", "^💩0$", "💩1", true}, 30 | {"", "^💩0$", "veth0", true}, 31 | {"^💩", "", "💩3", true}, 32 | {"^💩", "", "veth0", false}, 33 | } 34 | 35 | for _, test := range tests { 36 | filter := newDeviceFilter(test.ignore, test.accept) 37 | result := filter.ignored(test.name) 38 | 39 | if result != test.expectedResult { 40 | t.Errorf("ignorePattern=%v acceptPattern=%v ifname=%v expected=%v result=%v", test.ignore, test.accept, test.name, test.expectedResult, result) 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /collector/devstat_freebsd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | typedef struct { 23 | uint64_t read; 24 | uint64_t write; 25 | uint64_t free; 26 | } Bytes; 27 | 28 | typedef struct { 29 | uint64_t other; 30 | uint64_t read; 31 | uint64_t write; 32 | uint64_t free; 33 | } Transfers; 34 | 35 | typedef struct { 36 | double other; 37 | double read; 38 | double write; 39 | double free; 40 | } Duration; 41 | 42 | typedef struct { 43 | char device[DEVSTAT_NAME_LEN]; 44 | int unit; 45 | Bytes bytes; 46 | Transfers transfers; 47 | Duration duration; 48 | long busyTime; 49 | uint64_t blocks; 50 | } Stats; 51 | 52 | 53 | int _get_ndevs(); 54 | int _get_stats(struct devinfo *info, Stats **stats); 55 | -------------------------------------------------------------------------------- /collector/entropy_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !noentropy 15 | // +build !noentropy 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/go-kit/log" 23 | "github.com/prometheus/client_golang/prometheus" 24 | "github.com/prometheus/procfs" 25 | ) 26 | 27 | type entropyCollector struct { 28 | fs procfs.FS 29 | entropyAvail *prometheus.Desc 30 | entropyPoolSize *prometheus.Desc 31 | logger log.Logger 32 | } 33 | 34 | func init() { 35 | registerCollector("entropy", defaultEnabled, NewEntropyCollector) 36 | } 37 | 38 | // NewEntropyCollector returns a new Collector exposing entropy stats. 39 | func NewEntropyCollector(logger log.Logger) (Collector, error) { 40 | fs, err := procfs.NewFS(*procPath) 41 | if err != nil { 42 | return nil, fmt.Errorf("failed to open procfs: %w", err) 43 | } 44 | 45 | return &entropyCollector{ 46 | fs: fs, 47 | entropyAvail: prometheus.NewDesc( 48 | prometheus.BuildFQName(namespace, "", "entropy_available_bits"), 49 | "Bits of available entropy.", 50 | nil, nil, 51 | ), 52 | entropyPoolSize: prometheus.NewDesc( 53 | prometheus.BuildFQName(namespace, "", "entropy_pool_size_bits"), 54 | "Bits of entropy pool.", 55 | nil, nil, 56 | ), 57 | logger: logger, 58 | }, nil 59 | } 60 | 61 | func (c *entropyCollector) Update(ch chan<- prometheus.Metric) error { 62 | stats, err := c.fs.KernelRandom() 63 | if err != nil { 64 | return fmt.Errorf("failed to get kernel random stats: %w", err) 65 | } 66 | 67 | if stats.EntropyAvaliable == nil { 68 | return fmt.Errorf("couldn't get entropy_avail") 69 | } 70 | ch <- prometheus.MustNewConstMetric( 71 | c.entropyAvail, prometheus.GaugeValue, float64(*stats.EntropyAvaliable)) 72 | 73 | if stats.PoolSize == nil { 74 | return fmt.Errorf("couldn't get entropy poolsize") 75 | } 76 | ch <- prometheus.MustNewConstMetric( 77 | c.entropyPoolSize, prometheus.GaugeValue, float64(*stats.PoolSize)) 78 | 79 | return nil 80 | } 81 | -------------------------------------------------------------------------------- /collector/filefd_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import "testing" 17 | 18 | func TestFileFDStats(t *testing.T) { 19 | fileFDStats, err := parseFileFDStats("fixtures/proc/sys/fs/file-nr") 20 | if err != nil { 21 | t.Fatal(err) 22 | } 23 | 24 | if want, got := "1024", fileFDStats["allocated"]; want != got { 25 | t.Errorf("want filefd allocated %q, got %q", want, got) 26 | } 27 | 28 | if want, got := "1631329", fileFDStats["maximum"]; want != got { 29 | t.Errorf("want filefd maximum %q, got %q", want, got) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /collector/filesystem_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build openbsd && !nofilesystem 15 | // +build openbsd,!nofilesystem 16 | 17 | package collector 18 | 19 | import ( 20 | "github.com/go-kit/log/level" 21 | "golang.org/x/sys/unix" 22 | ) 23 | 24 | const ( 25 | defMountPointsExcluded = "^/(dev)($|/)" 26 | defFSTypesExcluded = "^devfs$" 27 | ) 28 | 29 | // Expose filesystem fullness. 30 | func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) { 31 | var mnt []unix.Statfs_t 32 | size, err := unix.Getfsstat(mnt, unix.MNT_NOWAIT) 33 | if err != nil { 34 | return nil, err 35 | } 36 | mnt = make([]unix.Statfs_t, size) 37 | _, err = unix.Getfsstat(mnt, unix.MNT_NOWAIT) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | stats = []filesystemStats{} 43 | for _, v := range mnt { 44 | mountpoint := string(v.F_mntonname[:]) 45 | if c.excludedMountPointsPattern.MatchString(mountpoint) { 46 | level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint) 47 | continue 48 | } 49 | 50 | device := string(v.F_mntfromname[:]) 51 | fstype := string(v.F_fstypename[:]) 52 | if c.excludedFSTypesPattern.MatchString(fstype) { 53 | level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype) 54 | continue 55 | } 56 | 57 | var ro float64 58 | if (v.F_flags & unix.MNT_RDONLY) != 0 { 59 | ro = 1 60 | } 61 | 62 | stats = append(stats, filesystemStats{ 63 | labels: filesystemLabels{ 64 | device: device, 65 | mountPoint: mountpoint, 66 | fsType: fstype, 67 | }, 68 | size: float64(v.F_blocks) * float64(v.F_bsize), 69 | free: float64(v.F_bfree) * float64(v.F_bsize), 70 | avail: float64(v.F_bavail) * float64(v.F_bsize), 71 | files: float64(v.F_files), 72 | filesFree: float64(v.F_ffree), 73 | ro: ro, 74 | }) 75 | } 76 | return stats, nil 77 | } 78 | -------------------------------------------------------------------------------- /collector/fixtures/ethtool/bond0/statistics: -------------------------------------------------------------------------------- 1 | ERROR: 1 -------------------------------------------------------------------------------- /collector/fixtures/ethtool/eth0/driver: -------------------------------------------------------------------------------- 1 | # ethtool -i eth0 2 | driver: e1000e 3 | version: 5.11.0-22-generic 4 | firmware-version: 0.5-4 5 | expansion-rom-version: 6 | bus-info: 0000:00:1f.6 7 | supports-statistics: yes 8 | supports-test: yes 9 | supports-eeprom-access: yes 10 | supports-register-dump: yes 11 | supports-priv-flags: yes 12 | -------------------------------------------------------------------------------- /collector/fixtures/ethtool/eth0/settings: -------------------------------------------------------------------------------- 1 | # ethtool eth0 2 | Settings for eth0: 3 | Supported ports: [ TP MII ] 4 | Supported link modes: 10baseT/Half 10baseT/Full 5 | 100baseT/Half 100baseT/Full 6 | 1000baseT/Full 10000baseT/Full 7 | Supported pause frame use: Symmetric 8 | Supports auto-negotiation: Yes 9 | Supported FEC modes: Not reported 10 | Advertised link modes: 10baseT/Half 10baseT/Full 11 | 100baseT/Half 100baseT/Full 12 | 1000baseT/Full 13 | Advertised pause frame use: Symmetric 14 | Advertised auto-negotiation: Yes 15 | Advertised FEC modes: Not reported 16 | Speed: 1000Mb/s 17 | Duplex: Full 18 | Auto-negotiation: on 19 | Port: Twisted Pair 20 | PHYAD: 1 21 | Transceiver: internal 22 | MDI-X: off (auto) 23 | netlink error: Operation not permitted 24 | Current message level: 0x00000007 (7) 25 | drv probe link 26 | Link detected: yes 27 | 28 | -------------------------------------------------------------------------------- /collector/fixtures/ethtool/eth0/statistics: -------------------------------------------------------------------------------- 1 | # ethtool -S eth0 2 | NIC statistics: 3 | tx_packets: 961500 4 | rx_packets: 1260062 5 | tx_errors: 0 6 | rx_errors: 0 7 | rx_missed: 401 8 | align_errors: 0 9 | tx_single_collisions: 0 10 | tx_multi_collisions: 0 11 | rx_unicast: 1230297 12 | rx_broadcast: 5792 13 | rx_multicast: 23973 14 | tx_aborted: 0 15 | tx_underrun: 0 16 | duplicate metric: 1 17 | duplicate_metric: 2 18 | -------------------------------------------------------------------------------- /collector/fixtures/ip_vs_result_lbs_local_address_local_port.txt: -------------------------------------------------------------------------------- 1 | # HELP node_ipvs_backend_connections_active The current active connections by local and remote address. 2 | # TYPE node_ipvs_backend_connections_active gauge 3 | node_ipvs_backend_connections_active{local_address="",local_port="0"} 385 4 | node_ipvs_backend_connections_active{local_address="192.168.0.22",local_port="3306"} 744 5 | node_ipvs_backend_connections_active{local_address="192.168.0.55",local_port="3306"} 0 6 | node_ipvs_backend_connections_active{local_address="192.168.0.57",local_port="3306"} 2997 7 | # HELP node_ipvs_backend_connections_inactive The current inactive connections by local and remote address. 8 | # TYPE node_ipvs_backend_connections_inactive gauge 9 | node_ipvs_backend_connections_inactive{local_address="",local_port="0"} 6 10 | node_ipvs_backend_connections_inactive{local_address="192.168.0.22",local_port="3306"} 5 11 | node_ipvs_backend_connections_inactive{local_address="192.168.0.55",local_port="3306"} 0 12 | node_ipvs_backend_connections_inactive{local_address="192.168.0.57",local_port="3306"} 0 13 | # HELP node_ipvs_backend_weight The current backend weight by local and remote address. 14 | # TYPE node_ipvs_backend_weight gauge 15 | node_ipvs_backend_weight{local_address="",local_port="0"} 120 16 | node_ipvs_backend_weight{local_address="192.168.0.22",local_port="3306"} 300 17 | node_ipvs_backend_weight{local_address="192.168.0.55",local_port="3306"} 100 18 | node_ipvs_backend_weight{local_address="192.168.0.57",local_port="3306"} 200 19 | # HELP node_ipvs_connections_total The total number of connections made. 20 | # TYPE node_ipvs_connections_total counter 21 | node_ipvs_connections_total 2.3765872e+07 22 | # HELP node_ipvs_incoming_bytes_total The total amount of incoming data. 23 | # TYPE node_ipvs_incoming_bytes_total counter 24 | node_ipvs_incoming_bytes_total 8.9991519156915e+13 25 | # HELP node_ipvs_incoming_packets_total The total number of incoming packets. 26 | # TYPE node_ipvs_incoming_packets_total counter 27 | node_ipvs_incoming_packets_total 3.811989221e+09 28 | # HELP node_ipvs_outgoing_bytes_total The total amount of outgoing data. 29 | # TYPE node_ipvs_outgoing_bytes_total counter 30 | node_ipvs_outgoing_bytes_total 0 31 | # HELP node_ipvs_outgoing_packets_total The total number of outgoing packets. 32 | # TYPE node_ipvs_outgoing_packets_total counter 33 | node_ipvs_outgoing_packets_total 0 34 | -------------------------------------------------------------------------------- /collector/fixtures/ip_vs_result_lbs_local_port.txt: -------------------------------------------------------------------------------- 1 | # HELP node_ipvs_backend_connections_active The current active connections by local and remote address. 2 | # TYPE node_ipvs_backend_connections_active gauge 3 | node_ipvs_backend_connections_active{local_port="0"} 385 4 | node_ipvs_backend_connections_active{local_port="3306"} 3741 5 | # HELP node_ipvs_backend_connections_inactive The current inactive connections by local and remote address. 6 | # TYPE node_ipvs_backend_connections_inactive gauge 7 | node_ipvs_backend_connections_inactive{local_port="0"} 6 8 | node_ipvs_backend_connections_inactive{local_port="3306"} 5 9 | # HELP node_ipvs_backend_weight The current backend weight by local and remote address. 10 | # TYPE node_ipvs_backend_weight gauge 11 | node_ipvs_backend_weight{local_port="0"} 120 12 | node_ipvs_backend_weight{local_port="3306"} 600 13 | # HELP node_ipvs_connections_total The total number of connections made. 14 | # TYPE node_ipvs_connections_total counter 15 | node_ipvs_connections_total 2.3765872e+07 16 | # HELP node_ipvs_incoming_bytes_total The total amount of incoming data. 17 | # TYPE node_ipvs_incoming_bytes_total counter 18 | node_ipvs_incoming_bytes_total 8.9991519156915e+13 19 | # HELP node_ipvs_incoming_packets_total The total number of incoming packets. 20 | # TYPE node_ipvs_incoming_packets_total counter 21 | node_ipvs_incoming_packets_total 3.811989221e+09 22 | # HELP node_ipvs_outgoing_bytes_total The total amount of outgoing data. 23 | # TYPE node_ipvs_outgoing_bytes_total counter 24 | node_ipvs_outgoing_bytes_total 0 25 | # HELP node_ipvs_outgoing_packets_total The total number of outgoing packets. 26 | # TYPE node_ipvs_outgoing_packets_total counter 27 | node_ipvs_outgoing_packets_total 0 28 | -------------------------------------------------------------------------------- /collector/fixtures/ip_vs_result_lbs_none.txt: -------------------------------------------------------------------------------- 1 | # HELP node_ipvs_backend_connections_active The current active connections by local and remote address. 2 | # TYPE node_ipvs_backend_connections_active gauge 3 | node_ipvs_backend_connections_active 4126 4 | # HELP node_ipvs_backend_connections_inactive The current inactive connections by local and remote address. 5 | # TYPE node_ipvs_backend_connections_inactive gauge 6 | node_ipvs_backend_connections_inactive 11 7 | # HELP node_ipvs_backend_weight The current backend weight by local and remote address. 8 | # TYPE node_ipvs_backend_weight gauge 9 | node_ipvs_backend_weight 720 10 | # HELP node_ipvs_connections_total The total number of connections made. 11 | # TYPE node_ipvs_connections_total counter 12 | node_ipvs_connections_total 2.3765872e+07 13 | # HELP node_ipvs_incoming_bytes_total The total amount of incoming data. 14 | # TYPE node_ipvs_incoming_bytes_total counter 15 | node_ipvs_incoming_bytes_total 8.9991519156915e+13 16 | # HELP node_ipvs_incoming_packets_total The total number of incoming packets. 17 | # TYPE node_ipvs_incoming_packets_total counter 18 | node_ipvs_incoming_packets_total 3.811989221e+09 19 | # HELP node_ipvs_outgoing_bytes_total The total amount of outgoing data. 20 | # TYPE node_ipvs_outgoing_bytes_total counter 21 | node_ipvs_outgoing_bytes_total 0 22 | # HELP node_ipvs_outgoing_packets_total The total number of outgoing packets. 23 | # TYPE node_ipvs_outgoing_packets_total counter 24 | node_ipvs_outgoing_packets_total 0 25 | -------------------------------------------------------------------------------- /collector/fixtures/proc/1/stat: -------------------------------------------------------------------------------- 1 | 1 (systemd) S 0 1 1 0 -1 4194560 9061 9416027 94 2620 36 98 54406 13885 20 0 1 0 29 109604864 2507 18446744073709551615 1 1 0 0 0 0 671173123 4096 1260 0 0 0 17 0 0 0 19 0 0 0 0 0 0 0 0 0 0 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/10/mountinfo: -------------------------------------------------------------------------------- 1 | 1 1 0:5 / /root rw,nosuid shared:8 - rootfs rootfs rw 2 | 16 21 0:16 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw 3 | 17 21 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw 4 | 21 0 8:1 / / rw,relatime shared:1 - ext4 /dev/sda1 rw,errors=remount-ro,data=ordered 5 | 194 21 0:42 / /mnt/nfs/test rw shared:144 - nfs4 192.168.1.1:/srv/test rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,addr=192.168.1.1,local_lock=none 6 | 177 21 0:42 / /mnt/nfs/test rw shared:130 - nfs4 192.168.1.1:/srv/test rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,addr=192.168.1.1,local_lock=none 7 | 1398 798 0:44 / /mnt/nfs/test rw,relatime shared:1154 - nfs 192.168.1.1:/srv/test rw,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=udp,timeo=11,retrans=3,sec=sys,mountaddr=192.168.1.1,mountvers=3,mountport=49602,mountproto=udp,local_lock=none,addr=192.168.1.1 8 | -------------------------------------------------------------------------------- /collector/fixtures/proc/10/stat: -------------------------------------------------------------------------------- 1 | 17 (khungtaskd) S 2 0 0 0 -1 2129984 0 0 0 0 14 0 0 0 20 0 1 0 24 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /collector/fixtures/proc/11/.missing_stat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/percona/node_exporter/056f570aa6302c54620b74f38cb45ef40f9ba4eb/collector/fixtures/proc/11/.missing_stat -------------------------------------------------------------------------------- /collector/fixtures/proc/11/stat: -------------------------------------------------------------------------------- 1 | 11 (rcu_preempt) I 2 0 0 0 -1 2129984 0 0 0 0 0 346 0 0 -2 0 1 0 32 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 2 1 1 0 0 0 0 0 0 0 0 0 0 0 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/buddyinfo: -------------------------------------------------------------------------------- 1 | Node 0, zone DMA 1 0 1 0 2 1 1 0 1 1 3 2 | Node 0, zone DMA32 759 572 791 475 194 45 12 0 0 0 0 3 | Node 0, zone Normal 4381 1093 185 1530 567 102 4 0 0 0 0 4 | -------------------------------------------------------------------------------- /collector/fixtures/proc/cgroups: -------------------------------------------------------------------------------- 1 | #subsys_name hierarchy num_cgroups enabled 2 | cpuset 5 47 1 3 | cpu 3 172 1 4 | cpuacct 3 172 1 5 | blkio 6 170 1 6 | memory 7 234 1 7 | devices 11 170 1 8 | freezer 9 47 1 9 | net_cls 2 47 1 10 | perf_event 8 47 1 11 | hugetlb 12 47 1 12 | pids 10 170 1 13 | rdma 4 1 1 -------------------------------------------------------------------------------- /collector/fixtures/proc/drbd: -------------------------------------------------------------------------------- 1 | version: 8.4.3 (api:1/proto:86-101) 2 | srcversion: 1A9F77B1CA5FF92235C2213 3 | 4 | 1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r----- 5 | ns:17324442 nr:10961011 dw:28263521 dr:118696670 al:1100 bm:221 lo:12345 pe:12346 ua:12347 ap:12348 ep:1 wo:d oos:12349 6 | -------------------------------------------------------------------------------- /collector/fixtures/proc/interrupts: -------------------------------------------------------------------------------- 1 | CPU0 CPU1 CPU2 CPU3 2 | 0: 18 0 0 0 IR-IO-APIC-edge timer 3 | 1: 17960 105 28 28 IR-IO-APIC-edge i8042 4 | 8: 1 0 0 0 IR-IO-APIC-edge rtc0 5 | 9: 398553 2320 824 863 IR-IO-APIC-fasteoi acpi 6 | 12: 380847 1021 240 198 IR-IO-APIC-edge i8042 7 | 16: 328511 322879 293782 351412 IR-IO-APIC-fasteoi ehci_hcd:usb1, mmc0 8 | 23: 1451445 3333499 1092032 2644609 IR-IO-APIC-fasteoi ehci_hcd:usb2 9 | 40: 0 0 0 0 DMAR_MSI-edge dmar0 10 | 41: 0 0 0 0 DMAR_MSI-edge dmar1 11 | 42: 378324 1734637 440240 2434308 IR-PCI-MSI-edge xhci_hcd 12 | 43: 7434032 8092205 6478877 7492252 IR-PCI-MSI-edge ahci 13 | 44: 140636 226313 347 633 IR-PCI-MSI-edge i915 14 | 45: 4 22 0 0 IR-PCI-MSI-edge mei_me 15 | 46: 43078464 130 460171 290 IR-PCI-MSI-edge iwlwifi 16 | 47: 350 224 0 0 IR-PCI-MSI-edge snd_hda_intel 17 | NMI: 47 5031 6211 4968 Non-maskable interrupts 18 | LOC: 174326351 135776678 168393257 130980079 Local timer interrupts 19 | SPU: 0 0 0 0 Spurious interrupts 20 | PMI: 47 5031 6211 4968 Performance monitoring interrupts 21 | IWI: 1509379 2411776 1512975 2428828 IRQ work interrupts 22 | RTR: 0 0 0 0 APIC ICR read retries 23 | RES: 10847134 9111507 15999335 7457260 Rescheduling interrupts 24 | CAL: 148554 157441 142912 155528 Function call interrupts 25 | TLB: 10460334 9918429 10494258 10345022 TLB shootdowns 26 | TRM: 0 0 0 0 Thermal event interrupts 27 | THR: 0 0 0 0 Threshold APIC interrupts 28 | MCE: 0 0 0 0 Machine check exceptions 29 | MCP: 2406 2399 2399 2399 Machine check polls 30 | ERR: 0 31 | MIS: 0 32 | -------------------------------------------------------------------------------- /collector/fixtures/proc/loadavg: -------------------------------------------------------------------------------- 1 | 0.21 0.37 0.39 1/719 19737 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/mdstat: -------------------------------------------------------------------------------- 1 | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 2 | 3 | md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9] sdd1[10](S) sdd2[11](S) 4 | 5853468288 blocks super 1.2 level 6, 64k chunk, algorithm 2 [8/8] [UUUUUUUU] 5 | 6 | md127 : active raid1 sdi2[0] sdj2[1] 7 | 312319552 blocks [2/2] [UU] 8 | 9 | md0 : active raid1 sdi1[0] sdj1[1] 10 | 248896 blocks [2/2] [UU] 11 | 12 | md4 : inactive raid1 sda3[0](F) sdb3[1](S) 13 | 4883648 blocks [2/2] [UU] 14 | 15 | md6 : active raid1 sdb2[2](F) sdc[1](S) sda2[0] 16 | 195310144 blocks [2/1] [U_] 17 | [=>...................] recovery = 8.5% (16775552/195310144) finish=17.0min speed=259783K/sec 18 | 19 | md8 : active raid1 sdb1[1] sda1[0] sdc[2](S) sde[3](S) 20 | 195310144 blocks [2/2] [UU] 21 | [=>...................] resync = 8.5% (16775552/195310144) finish=17.0min speed=259783K/sec 22 | 23 | md201 : active raid1 sda3[0] sdb3[1] 24 | 1993728 blocks super 1.2 [2/2] [UU] 25 | [=>...................] check = 5.7% (114176/1993728) finish=0.2min speed=114176K/sec 26 | 27 | md7 : active raid6 sdb1[0] sde1[3] sdd1[2] sdc1[1](F) 28 | 7813735424 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU] 29 | bitmap: 0/30 pages [0KB], 65536KB chunk 30 | 31 | md9 : active raid1 sdc2[2] sdd2[3] sdb2[1] sda2[0] sde[4](F) sdf[5](F) sdg[6](S) 32 | 523968 blocks super 1.2 [4/4] [UUUU] 33 | resync=DELAYED 34 | 35 | md10 : active raid0 sda1[0] sdb1[1] 36 | 314159265 blocks 64k chunks 37 | 38 | md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1] sdc3[2](F) hda[4](S) ssdc2[3](S) 39 | 4190208 blocks super 1.2 [2/2] [UU] 40 | resync=PENDING 41 | 42 | md12 : active raid0 sdc2[0] sdd2[1] 43 | 3886394368 blocks super 1.2 512k chunks 44 | 45 | md126 : active raid0 sdb[1] sdc[0] 46 | 1855870976 blocks super external:/md127/0 128k chunks 47 | 48 | md219 : inactive sdb[2](S) sdc[1](S) sda[0](S) 49 | 7932 blocks super external:imsm 50 | 51 | md00 : active raid0 xvdb[0] 52 | 4186624 blocks super 1.2 256k chunks 53 | 54 | md120 : active linear sda1[1] sdb1[0] 55 | 2095104 blocks super 1.2 0k rounding 56 | 57 | md101 : active (read-only) raid0 sdb[2] sdd[1] sdc[0] 58 | 322560 blocks super 1.2 512k chunks 59 | 60 | unused devices: 61 | -------------------------------------------------------------------------------- /collector/fixtures/proc/meminfo: -------------------------------------------------------------------------------- 1 | MemTotal: 3742148 kB 2 | MemFree: 225472 kB 3 | Buffers: 22040 kB 4 | Cached: 930888 kB 5 | SwapCached: 192504 kB 6 | Active: 2233416 kB 7 | Inactive: 1028728 kB 8 | Active(anon): 2020004 kB 9 | Inactive(anon): 883052 kB 10 | Active(file): 213412 kB 11 | Inactive(file): 145676 kB 12 | Unevictable: 32 kB 13 | Mlocked: 32 kB 14 | SwapTotal: 4194300 kB 15 | SwapFree: 3155360 kB 16 | Dirty: 1052 kB 17 | Writeback: 0 kB 18 | AnonPages: 2244172 kB 19 | Mapped: 239220 kB 20 | Shmem: 593840 kB 21 | Slab: 98932 kB 22 | SReclaimable: 44772 kB 23 | SUnreclaim: 54160 kB 24 | KernelStack: 5800 kB 25 | PageTables: 75212 kB 26 | NFS_Unstable: 0 kB 27 | Bounce: 0 kB 28 | WritebackTmp: 0 kB 29 | CommitLimit: 6065372 kB 30 | Committed_AS: 7835436 kB 31 | VmallocTotal: 34359738367 kB 32 | VmallocUsed: 352840 kB 33 | VmallocChunk: 34359338876 kB 34 | HardwareCorrupted: 0 kB 35 | AnonHugePages: 0 kB 36 | HugePages_Total: 0 37 | HugePages_Free: 0 38 | HugePages_Rsvd: 0 39 | HugePages_Surp: 0 40 | Hugepagesize: 2048 kB 41 | DirectMap4k: 185660 kB 42 | DirectMap2M: 3698688 kB 43 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/arp: -------------------------------------------------------------------------------- 1 | IP address HW type Flags HW address Mask Device 2 | 192.168.1.1 0x1 0x2 cc:aa:dd:ee:aa:bb * eth0 3 | 192.168.1.2 0x1 0x2 bb:cc:dd:ee:ff:aa * eth0 4 | 192.168.1.3 0x1 0x2 aa:bb:cc:dd:ee:ff * eth0 5 | 192.168.1.4 0x1 0x2 dd:ee:ff:aa:bb:cc * eth1 6 | 192.168.1.5 0x1 0x2 ee:ff:aa:bb:cc:dd * eth1 7 | 192.168.1.6 0x1 0x2 ff:aa:bb:cc:dd:ee * eth1 8 | 10.0.0.1 0x1 0x2 de:ad:be:ef:00:00 * nope 9 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/ip_vs: -------------------------------------------------------------------------------- 1 | IP Virtual Server version 1.2.1 (size=4096) 2 | Prot LocalAddress:Port Scheduler Flags 3 | -> RemoteAddress:Port Forward Weight ActiveConn InActConn 4 | TCP C0A80016:0CEA wlc 5 | -> C0A85216:0CEA Tunnel 100 248 2 6 | -> C0A85318:0CEA Tunnel 100 248 2 7 | -> C0A85315:0CEA Tunnel 100 248 1 8 | TCP C0A80039:0CEA wlc 9 | -> C0A85416:0CEA Tunnel 0 0 0 10 | -> C0A85215:0CEA Tunnel 100 1499 0 11 | -> C0A83215:0CEA Tunnel 100 1498 0 12 | TCP C0A80037:0CEA wlc 13 | -> C0A8321A:0CEA Tunnel 0 0 0 14 | -> C0A83120:0CEA Tunnel 100 0 0 15 | FWM 10001000 wlc 16 | -> C0A8321A:0CEA Tunnel 20 64 1 17 | -> C0A83120:0CEA Tunnel 100 321 5 18 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/ip_vs_stats: -------------------------------------------------------------------------------- 1 | Total Incoming Outgoing Incoming Outgoing 2 | Conns Packets Packets Bytes Bytes 3 | 16AA370 E33656E5 0 51D8C8883AB3 0 4 | 5 | Conns/s Pkts/s Pkts/s Bytes/s Bytes/s 6 | 4 1FB3C 0 1282A8F 0 7 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/netstat: -------------------------------------------------------------------------------- 1 | TcpExt: SyncookiesSent SyncookiesRecv SyncookiesFailed EmbryonicRsts PruneCalled RcvPruned OfoPruned OutOfWindowIcmps LockDroppedIcmps ArpFilter TW TWRecycled TWKilled PAWSPassive PAWSActive PAWSEstab DelayedACKs DelayedACKLocked DelayedACKLost ListenOverflows ListenDrops TCPPrequeued TCPDirectCopyFromBacklog TCPDirectCopyFromPrequeue TCPPrequeueDropped TCPHPHits TCPHPHitsToUser TCPPureAcks TCPHPAcks TCPRenoRecovery TCPSackRecovery TCPSACKReneging TCPFACKReorder TCPSACKReorder TCPRenoReorder TCPTSReorder TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo TCPLoss TCPLostRetransmit TCPRenoFailures TCPSackFailures TCPLossFailures TCPFastRetrans TCPForwardRetrans TCPSlowStartRetrans TCPTimeouts TCPRenoRecoveryFail TCPSackRecoveryFail TCPSchedulerFailed TCPRcvCollapsed TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv TCPDSACKOfoRecv TCPAbortOnData TCPAbortOnClose TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger TCPAbortFailed TCPMemoryPressures TCPSACKDiscard TCPDSACKIgnoredOld TCPDSACKIgnoredNoUndo TCPSpuriousRTOs TCPMD5NotFound TCPMD5Unexpected TCPSackShifted TCPSackMerged TCPSackShiftFallback TCPBacklogDrop TCPMinTTLDrop TCPDeferAcceptDrop IPReversePathFilter TCPTimeWaitOverflow TCPReqQFullDoCookies TCPReqQFullDrop TCPChallengeACK TCPSYNChallenge 2 | TcpExt: 0 0 2 0 0 0 0 0 0 0 388812 0 0 0 0 6 102471 17 9 0 0 80568 0 168808 0 4471289 26 1433940 3744565 0 1 0 0 0 0 0 0 0 0 48 0 0 0 1 0 1 0 1 115 0 0 0 0 9 0 5 0 41 4 0 0 0 0 0 0 0 1 0 0 0 0 2 5 0 0 0 0 0 0 0 2 2 3 | IpExt: InNoRoutes InTruncatedPkts InMcastPkts OutMcastPkts InBcastPkts OutBcastPkts InOctets OutOctets InMcastOctets OutMcastOctets InBcastOctets OutBcastOctets 4 | IpExt: 0 0 0 0 0 0 6286396970 2786264347 0 0 0 0 5 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/rpc/nfs: -------------------------------------------------------------------------------- 1 | net 70 70 69 45 2 | rpc 1218785755 374636 1218815394 3 | proc2 18 16 57 74 52 71 73 45 86 0 52 83 61 17 53 50 23 70 82 4 | proc3 22 0 1061909262 48906 4077635 117661341 5 29391916 2570425 2993289 590 0 0 7815 15 1130 0 3983 92385 13332 2 1 23729 5 | proc4 48 98 51 54 83 85 23 24 1 28 73 68 83 12 84 39 68 59 58 88 29 74 69 96 21 84 15 53 86 54 66 56 97 36 49 32 85 81 11 58 32 67 13 28 35 90 1 26 0 6 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/rpc/nfsd: -------------------------------------------------------------------------------- 1 | rc 0 6 18622 2 | fh 0 0 0 0 0 3 | io 157286400 72864 4 | th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 5 | ra 32 0 0 0 0 0 0 0 0 0 0 0 6 | net 972 55 917 1 7 | rpc 18628 3 1 2 0 8 | proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2 9 | proc3 22 2 112 0 2719 111 0 0 0 0 0 0 0 0 0 0 0 27 216 0 2 1 0 10 | proc4 2 2 10853 11 | proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/snmp: -------------------------------------------------------------------------------- 1 | Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates 2 | Ip: 1 64 57740232 0 25 397750 0 0 57340175 55365537 0 54 0 0 0 0 0 0 0 3 | 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 4 | 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 5 | IcmpMsg: InType3 OutType3 6 | IcmpMsg: 104 120 7 | Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors 8 | Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0 9 | Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors 10 | Udp: 88542 120 0 53028 9 8 0 11 | UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors 12 | UdpLite: 0 0 0 0 0 0 0 13 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/sockstat: -------------------------------------------------------------------------------- 1 | sockets: used 229 2 | TCP: inuse 4 orphan 0 tw 4 alloc 17 mem 1 3 | UDP: inuse 0 mem 0 4 | UDPLITE: inuse 0 5 | RAW: inuse 0 6 | FRAG: inuse 0 memory 0 7 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/sockstat6: -------------------------------------------------------------------------------- 1 | TCP6: inuse 17 2 | UDP6: inuse 9 3 | UDPLITE6: inuse 0 4 | RAW6: inuse 1 5 | FRAG6: inuse 0 memory 0 6 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/softnet_stat: -------------------------------------------------------------------------------- 1 | 00049279 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 2 | 000dfb82 00000029 0000000a 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3 | 00551c3f 00000000 00000055 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 4 | 002f8339 00000000 00000032 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 -------------------------------------------------------------------------------- /collector/fixtures/proc/net/stat/arp_cache: -------------------------------------------------------------------------------- 1 | entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs unresolved_discards table_fulls 2 | 00000014 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 0000000a 0000000b 0000000c 3 | 00000014 0000000d 0000000e 0000000f 00000010 00000011 00000012 00000013 00000014 00000015 00000016 00000017 00000018 4 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/stat/ndisc_cache: -------------------------------------------------------------------------------- 1 | entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs unresolved_discards table_fulls 2 | 00000024 000000f0 000000f1 000000f2 000000f3 000000f4 000000f5 000000f6 000000f7 000000f8 000000f9 000000fa 000000fb 3 | 00000024 000000fc 000000fd 000000fe 000000ff 00000100 00000101 00000102 00000103 00000104 00000105 00000106 00000107 4 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/stat/nf_conntrack: -------------------------------------------------------------------------------- 1 | entries searched found new invalid ignore delete delete_list insert insert_failed drop early_drop icmp_error expect_new expect_create expect_delete search_restart 2 | 00000021 00000000 00000000 00000000 00000003 0000588a 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3 | 00000021 00000000 00000000 00000000 00000002 000056a4 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000002 4 | 00000021 00000000 00000000 00000000 00000001 000058d4 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001 5 | 00000021 00000000 00000000 00000000 0000002f 00005688 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000004 6 | -------------------------------------------------------------------------------- /collector/fixtures/proc/net/udp: -------------------------------------------------------------------------------- 1 | sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 2 | 0: 00000000:0016 00000000:0000 0A 00000015:00000000 00:00000000 00000000 0 0 2740 1 ffff88003d3af3c0 100 0 0 10 0 3 | -------------------------------------------------------------------------------- /collector/fixtures/proc/pressure/cpu: -------------------------------------------------------------------------------- 1 | some avg10=0.00 avg60=0.00 avg300=0.00 total=14036781 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/pressure/io: -------------------------------------------------------------------------------- 1 | some avg10=0.18 avg60=0.34 avg300=0.10 total=159886802 2 | full avg10=0.18 avg60=0.34 avg300=0.10 total=159229614 3 | -------------------------------------------------------------------------------- /collector/fixtures/proc/pressure/memory: -------------------------------------------------------------------------------- 1 | some avg10=0.00 avg60=0.00 avg300=0.00 total=0 2 | full avg10=0.00 avg60=0.00 avg300=0.00 total=0 3 | -------------------------------------------------------------------------------- /collector/fixtures/proc/schedstat: -------------------------------------------------------------------------------- 1 | version 15 2 | timestamp 15819019232 3 | cpu0 498494191 0 3533438552 2553969831 3853684107 2465731542 2045936778163039 343796328169361 4767485306 4 | domain0 00000000,00000003 212499247 210112015 1861015 1860405436 536440 369895 32599 210079416 25368550 24241256 384652 927363878 807233 6366 1647 24239609 2122447165 1886868564 121112060 2848625533 125678146 241025 1032026 1885836538 2545 12 2533 0 0 0 0 0 0 1387952561 21076581 0 5 | cpu1 518377256 0 4155211005 2778589869 10466382 2867629021 1904686152592476 364107263788241 5145567945 6 | domain0 00000000,00000003 217653037 215526982 1577949 1580427380 557469 393576 28538 215498444 28721913 27662819 371153 870843407 745912 5523 1639 27661180 2331056874 2107732788 111442342 652402556 123615235 196159 1045245 2106687543 2400 3 2397 0 0 0 0 0 0 1437804657 26220076 0 7 | -------------------------------------------------------------------------------- /collector/fixtures/proc/self: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /collector/fixtures/proc/slabinfo: -------------------------------------------------------------------------------- 1 | slabinfo - version: 2.1 2 | # name : tunables : slabdata 3 | tw_sock_TCP 704 864 256 32 2 : tunables 0 0 0 : slabdata 27 27 0 4 | dmaengine-unmap-128 1206 1320 1088 30 8 : tunables 0 0 0 : slabdata 44 44 0 5 | kmalloc-8192 132 148 8192 4 8 : tunables 0 0 0 : slabdata 37 37 0 6 | kmem_cache 320 320 256 32 2 : tunables 0 0 0 : slabdata 10 10 0 7 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/abdstats: -------------------------------------------------------------------------------- 1 | 7 1 0x01 21 5712 73163810083184 309946154984654 2 | name type data 3 | struct_size 4 2520 4 | linear_cnt 4 62 5 | linear_data_size 4 223232 6 | scatter_cnt 4 1 7 | scatter_data_size 4 16384 8 | scatter_chunk_waste 4 0 9 | scatter_order_0 4 0 10 | scatter_order_1 4 0 11 | scatter_order_2 4 1 12 | scatter_order_3 4 0 13 | scatter_order_4 4 0 14 | scatter_order_5 4 0 15 | scatter_order_6 4 0 16 | scatter_order_7 4 0 17 | scatter_order_8 4 0 18 | scatter_order_9 4 0 19 | scatter_order_10 4 0 20 | scatter_page_multi_chunk 4 0 21 | scatter_page_multi_zone 4 0 22 | scatter_page_alloc_retry 4 0 23 | scatter_sg_table_retry 4 0 24 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/dmu_tx: -------------------------------------------------------------------------------- 1 | 5 1 0x01 11 528 8010436841 354962070418194 2 | name type data 3 | dmu_tx_assigned 4 3532844 4 | dmu_tx_delay 4 0 5 | dmu_tx_error 4 0 6 | dmu_tx_suspended 4 0 7 | dmu_tx_group 4 0 8 | dmu_tx_memory_reserve 4 0 9 | dmu_tx_memory_reclaim 4 0 10 | dmu_tx_dirty_throttle 4 0 11 | dmu_tx_dirty_delay 4 0 12 | dmu_tx_dirty_over_max 4 0 13 | dmu_tx_quota 4 0 14 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/dnodestats: -------------------------------------------------------------------------------- 1 | 10 1 0x01 28 7616 73163810135894 309969103316276 2 | name type data 3 | dnode_hold_dbuf_hold 4 0 4 | dnode_hold_dbuf_read 4 0 5 | dnode_hold_alloc_hits 4 37617 6 | dnode_hold_alloc_misses 4 0 7 | dnode_hold_alloc_interior 4 0 8 | dnode_hold_alloc_lock_retry 4 0 9 | dnode_hold_alloc_lock_misses 4 0 10 | dnode_hold_alloc_type_none 4 0 11 | dnode_hold_free_hits 4 0 12 | dnode_hold_free_misses 4 0 13 | dnode_hold_free_lock_misses 4 0 14 | dnode_hold_free_lock_retry 4 0 15 | dnode_hold_free_overflow 4 0 16 | dnode_hold_free_refcount 4 0 17 | dnode_hold_free_txg 4 0 18 | dnode_allocate 4 0 19 | dnode_reallocate 4 0 20 | dnode_buf_evict 4 17 21 | dnode_alloc_next_chunk 4 0 22 | dnode_alloc_race 4 0 23 | dnode_alloc_next_block 4 0 24 | dnode_move_invalid 4 0 25 | dnode_move_recheck1 4 0 26 | dnode_move_recheck2 4 0 27 | dnode_move_special 4 0 28 | dnode_move_handle 4 0 29 | dnode_move_rwlock 4 0 30 | dnode_move_active 4 0 31 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/fm: -------------------------------------------------------------------------------- 1 | 0 1 0x01 4 192 8007255140 354329591145385 2 | name type data 3 | erpt-dropped 4 18 4 | erpt-set-failed 4 0 5 | fmri-set-failed 4 0 6 | payload-set-failed 4 0 7 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/pool1/io: -------------------------------------------------------------------------------- 1 | 12 3 0x00 1 80 79205351707403 395818011156865 2 | nread nwritten reads writes wtime wlentime wupdate rtime rlentime rupdate wcnt rcnt 3 | 1884160 3206144 22 132 7155162 104112268 79210489694949 24168078 104112268 79210489849220 0 0 4 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/pool1/objset-1: -------------------------------------------------------------------------------- 1 | 23 1 0x01 7 2160 221578688875 6665999035587 2 | name type data 3 | dataset_name 7 pool1 4 | writes 4 0 5 | nwritten 4 0 6 | reads 4 0 7 | nread 4 0 8 | nunlinks 4 0 9 | nunlinked 4 0 10 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/pool1/objset-2: -------------------------------------------------------------------------------- 1 | 24 1 0x01 7 2160 221611904716 7145015038451 2 | name type data 3 | dataset_name 7 pool1/dataset1 4 | writes 4 4 5 | nwritten 4 12302 6 | reads 4 2 7 | nread 4 28 8 | nunlinks 4 3 9 | nunlinked 4 3 10 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/pool1/state: -------------------------------------------------------------------------------- 1 | ONLINE 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/poolz1/io: -------------------------------------------------------------------------------- 1 | 16 3 0x00 1 80 79568650431241 395832279341621 2 | nread nwritten reads writes wtime wlentime wupdate rtime rlentime rupdate wcnt rcnt 3 | 2826240 2680501248 33 25294 9673715628 6472105124093 110734831833266 9829091640 6472105124093 110734831944501 0 0 4 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/poolz1/objset-1: -------------------------------------------------------------------------------- 1 | 30 1 0x01 7 2160 217993779684 2621674546179 2 | name type data 3 | dataset_name 7 poolz1 4 | writes 4 0 5 | nwritten 4 0 6 | reads 4 0 7 | nread 4 0 8 | nunlinks 4 0 9 | nunlinked 4 0 -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/poolz1/objset-2: -------------------------------------------------------------------------------- 1 | 31 1 0x01 7 2160 218133979890 3024169078920 2 | name type data 3 | dataset_name 7 poolz1/dataset1 4 | writes 4 10 5 | nwritten 4 32806 6 | reads 4 2 7 | nread 4 28 8 | nunlinks 4 14 9 | nunlinked 4 14 -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/poolz1/state: -------------------------------------------------------------------------------- 1 | DEGRADED 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/vdev_cache_stats: -------------------------------------------------------------------------------- 1 | 8 1 0x01 3 144 8012540758 352116106118781 2 | name type data 3 | delegations 4 40 4 | hits 4 0 5 | misses 4 0 6 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/vdev_mirror_stats: -------------------------------------------------------------------------------- 1 | 18 1 0x01 7 1904 73163813004224 309980651991187 2 | name type data 3 | rotating_linear 4 0 4 | rotating_offset 4 0 5 | rotating_seek 4 0 6 | non_rotating_linear 4 0 7 | non_rotating_seek 4 0 8 | preferred_found 4 0 9 | preferred_not_found 4 94 10 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/xuio_stats: -------------------------------------------------------------------------------- 1 | 2 1 0x01 6 288 8009100742 353415816865654 2 | name type data 3 | onloan_read_buf 4 32 4 | onloan_write_buf 4 0 5 | read_buf_copied 4 0 6 | read_buf_nocopy 4 0 7 | write_buf_copied 4 0 8 | write_buf_nocopy 4 0 9 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/zfetchstats: -------------------------------------------------------------------------------- 1 | 4 1 0x01 11 528 8010434610 345692669858836 2 | name type data 3 | hits 4 7067992 4 | misses 4 11 5 | colinear_hits 4 0 6 | colinear_misses 4 11 7 | stride_hits 4 7067990 8 | stride_misses 4 0 9 | reclaim_successes 4 0 10 | reclaim_failures 4 11 11 | streams_resets 4 0 12 | streams_noresets 4 2 13 | bogus_streams 4 0 14 | -------------------------------------------------------------------------------- /collector/fixtures/proc/spl/kstat/zfs/zil: -------------------------------------------------------------------------------- 1 | 7 1 0x01 13 624 8012538347 351689526932992 2 | name type data 3 | zil_commit_count 4 10 4 | zil_commit_writer_count 4 0 5 | zil_itx_count 4 0 6 | zil_itx_indirect_count 4 0 7 | zil_itx_indirect_bytes 4 0 8 | zil_itx_copied_count 4 0 9 | zil_itx_copied_bytes 4 0 10 | zil_itx_needcopy_count 4 0 11 | zil_itx_needcopy_bytes 4 18446744073709537686 12 | zil_itx_metaslab_normal_count 4 0 13 | zil_itx_metaslab_normal_bytes 4 0 14 | zil_itx_metaslab_slog_count 4 0 15 | zil_itx_metaslab_slog_bytes 4 0 16 | -------------------------------------------------------------------------------- /collector/fixtures/proc/stat: -------------------------------------------------------------------------------- 1 | cpu 301854 612 111922 8979004 3552 2 3944 0 44 36 2 | cpu0 44490 19 21045 1087069 220 1 3410 0 2 1 3 | cpu1 47869 23 16474 1110787 591 0 46 0 3 2 4 | cpu2 46504 36 15916 1112321 441 0 326 0 4 3 5 | cpu3 47054 102 15683 1113230 533 0 60 0 5 4 6 | cpu4 28413 25 10776 1140321 217 0 8 0 6 5 7 | cpu5 29271 101 11586 1136270 672 0 30 0 7 6 8 | cpu6 29152 36 10276 1139721 319 0 29 0 8 7 9 | cpu7 29098 268 10164 1139282 555 0 31 0 9 8 10 | 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 11 | ctxt 38014093 12 | btime 1418183276 13 | processes 26442 14 | procs_running 2 15 | procs_blocked 0 16 | softirq 5057579 250191 1481983 1647 211099 186066 0 1783454 622196 12499 508444 17 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/fs/file-nr: -------------------------------------------------------------------------------- 1 | 1024 0 1631329 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/kernel/pid_max: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/kernel/random/entropy_avail: -------------------------------------------------------------------------------- 1 | 1337 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/kernel/random/poolsize: -------------------------------------------------------------------------------- 1 | 4096 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/kernel/seccomp/actions_avail: -------------------------------------------------------------------------------- 1 | kill_process kill_thread trap errno user_notif trace log allow 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/kernel/threads-max: -------------------------------------------------------------------------------- 1 | 7801 -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/net/netfilter/nf_conntrack_count: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/net/netfilter/nf_conntrack_max: -------------------------------------------------------------------------------- 1 | 65536 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/pid_max: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /collector/fixtures/proc/sys/threads-max: -------------------------------------------------------------------------------- 1 | 7801 -------------------------------------------------------------------------------- /collector/fixtures/qdisc/results.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "IfaceName": "wlan0", 4 | "Bytes": 42, 5 | "Packets": 42, 6 | "Requeues": 1, 7 | "Kind": "fq", 8 | "Drops": 1 9 | }, 10 | { 11 | "IfaceName": "eth0", 12 | "Bytes": 83, 13 | "Packets": 83, 14 | "Requeues": 2, 15 | "Kind": "pfifo_fast" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /collector/fixtures/sys.ttar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/percona/node_exporter/056f570aa6302c54620b74f38cb45ef40f9ba4eb/collector/fixtures/sys.ttar -------------------------------------------------------------------------------- /collector/fixtures/textfile/client_side_timestamp.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 2 | # TYPE node_textfile_scrape_error gauge 3 | node_textfile_scrape_error 1 4 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/client_side_timestamp/metrics.prom: -------------------------------------------------------------------------------- 1 | metric_with_custom_timestamp 1 1441205977284 2 | normal_metric 2 3 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/different_metric_types.out: -------------------------------------------------------------------------------- 1 | # HELP event_duration_seconds_total Query timings 2 | # TYPE event_duration_seconds_total summary 3 | event_duration_seconds_total{baz="inner_eval",quantile="0.5"} 1.073e-06 4 | event_duration_seconds_total{baz="inner_eval",quantile="0.9"} 1.928e-06 5 | event_duration_seconds_total{baz="inner_eval",quantile="0.99"} 4.35e-06 6 | event_duration_seconds_total_sum{baz="inner_eval"} 1.8652166505091474e+06 7 | event_duration_seconds_total_count{baz="inner_eval"} 1.492355615e+09 8 | event_duration_seconds_total{baz="prepare_time",quantile="0.5"} 4.283e-06 9 | event_duration_seconds_total{baz="prepare_time",quantile="0.9"} 7.796e-06 10 | event_duration_seconds_total{baz="prepare_time",quantile="0.99"} 2.2083e-05 11 | event_duration_seconds_total_sum{baz="prepare_time"} 840923.7919437207 12 | event_duration_seconds_total_count{baz="prepare_time"} 1.492355814e+09 13 | event_duration_seconds_total{baz="result_append",quantile="0.5"} 1.566e-06 14 | event_duration_seconds_total{baz="result_append",quantile="0.9"} 3.223e-06 15 | event_duration_seconds_total{baz="result_append",quantile="0.99"} 6.53e-06 16 | event_duration_seconds_total_sum{baz="result_append"} 4.404109951000078 17 | event_duration_seconds_total_count{baz="result_append"} 1.427647e+06 18 | event_duration_seconds_total{baz="result_sort",quantile="0.5"} 1.847e-06 19 | event_duration_seconds_total{baz="result_sort",quantile="0.9"} 2.975e-06 20 | event_duration_seconds_total{baz="result_sort",quantile="0.99"} 4.08e-06 21 | event_duration_seconds_total_sum{baz="result_sort"} 3.4123187829998307 22 | event_duration_seconds_total_count{baz="result_sort"} 1.427647e+06 23 | # HELP events_total this is a test metric 24 | # TYPE events_total counter 25 | events_total{foo="bar"} 10 26 | events_total{foo="baz"} 20 27 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 28 | # TYPE node_textfile_mtime_seconds gauge 29 | node_textfile_mtime_seconds{file="fixtures/textfile/different_metric_types/metrics.prom"} 1 30 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 31 | # TYPE node_textfile_scrape_error gauge 32 | node_textfile_scrape_error 0 33 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/different_metric_types/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total this is a test metric 2 | # TYPE events_total counter 3 | events_total{foo="bar"} 10 4 | events_total{foo="baz"} 20 5 | 6 | # HELP event_duration_seconds_total Query timings 7 | # TYPE event_duration_seconds_total summary 8 | event_duration_seconds_total{baz="inner_eval",quantile="0.5"} 1.073e-06 9 | event_duration_seconds_total{baz="inner_eval",quantile="0.9"} 1.928e-06 10 | event_duration_seconds_total{baz="inner_eval",quantile="0.99"} 4.35e-06 11 | event_duration_seconds_total_sum{baz="inner_eval"} 1.8652166505091474e+06 12 | event_duration_seconds_total_count{baz="inner_eval"} 1.492355615e+09 13 | event_duration_seconds_total{baz="prepare_time",quantile="0.5"} 4.283e-06 14 | event_duration_seconds_total{baz="prepare_time",quantile="0.9"} 7.796e-06 15 | event_duration_seconds_total{baz="prepare_time",quantile="0.99"} 2.2083e-05 16 | event_duration_seconds_total_sum{baz="prepare_time"} 840923.7919437207 17 | event_duration_seconds_total_count{baz="prepare_time"} 1.492355814e+09 18 | event_duration_seconds_total{baz="result_append",quantile="0.5"} 1.566e-06 19 | event_duration_seconds_total{baz="result_append",quantile="0.9"} 3.223e-06 20 | event_duration_seconds_total{baz="result_append",quantile="0.99"} 6.53e-06 21 | event_duration_seconds_total_sum{baz="result_append"} 4.404109951000078 22 | event_duration_seconds_total_count{baz="result_append"} 1.427647e+06 23 | event_duration_seconds_total{baz="result_sort",quantile="0.5"} 1.847e-06 24 | event_duration_seconds_total{baz="result_sort",quantile="0.9"} 2.975e-06 25 | event_duration_seconds_total{baz="result_sort",quantile="0.99"} 4.08e-06 26 | event_duration_seconds_total_sum{baz="result_sort"} 3.4123187829998307 27 | event_duration_seconds_total_count{baz="result_sort"} 1.427647e+06 28 | 29 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/histogram.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 2 | # TYPE node_textfile_mtime_seconds gauge 3 | node_textfile_mtime_seconds{file="fixtures/textfile/histogram/metrics.prom"} 1 4 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 5 | # TYPE node_textfile_scrape_error gauge 6 | node_textfile_scrape_error 0 7 | # HELP prometheus_tsdb_compaction_chunk_range Final time range of chunks on their first compaction 8 | # TYPE prometheus_tsdb_compaction_chunk_range histogram 9 | prometheus_tsdb_compaction_chunk_range_bucket{le="100"} 0 10 | prometheus_tsdb_compaction_chunk_range_bucket{le="400"} 0 11 | prometheus_tsdb_compaction_chunk_range_bucket{le="1600"} 0 12 | prometheus_tsdb_compaction_chunk_range_bucket{le="6400"} 0 13 | prometheus_tsdb_compaction_chunk_range_bucket{le="25600"} 7 14 | prometheus_tsdb_compaction_chunk_range_bucket{le="102400"} 7 15 | prometheus_tsdb_compaction_chunk_range_bucket{le="409600"} 1.412839e+06 16 | prometheus_tsdb_compaction_chunk_range_bucket{le="1.6384e+06"} 1.69185e+06 17 | prometheus_tsdb_compaction_chunk_range_bucket{le="6.5536e+06"} 1.691853e+06 18 | prometheus_tsdb_compaction_chunk_range_bucket{le="2.62144e+07"} 1.691853e+06 19 | prometheus_tsdb_compaction_chunk_range_bucket{le="+Inf"} 1.691853e+06 20 | prometheus_tsdb_compaction_chunk_range_sum 6.71393432189e+11 21 | prometheus_tsdb_compaction_chunk_range_count 1.691853e+06 22 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/histogram/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP prometheus_tsdb_compaction_chunk_range Final time range of chunks on their first compaction 2 | # TYPE prometheus_tsdb_compaction_chunk_range histogram 3 | prometheus_tsdb_compaction_chunk_range_bucket{le="100"} 0 4 | prometheus_tsdb_compaction_chunk_range_bucket{le="400"} 0 5 | prometheus_tsdb_compaction_chunk_range_bucket{le="1600"} 0 6 | prometheus_tsdb_compaction_chunk_range_bucket{le="6400"} 0 7 | prometheus_tsdb_compaction_chunk_range_bucket{le="25600"} 7 8 | prometheus_tsdb_compaction_chunk_range_bucket{le="102400"} 7 9 | prometheus_tsdb_compaction_chunk_range_bucket{le="409600"} 1.412839e+06 10 | prometheus_tsdb_compaction_chunk_range_bucket{le="1.6384e+06"} 1.69185e+06 11 | prometheus_tsdb_compaction_chunk_range_bucket{le="6.5536e+06"} 1.691853e+06 12 | prometheus_tsdb_compaction_chunk_range_bucket{le="2.62144e+07"} 1.691853e+06 13 | prometheus_tsdb_compaction_chunk_range_bucket{le="+Inf"} 1.691853e+06 14 | prometheus_tsdb_compaction_chunk_range_sum 6.71393432189e+11 15 | prometheus_tsdb_compaction_chunk_range_count 1.691853e+06 16 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/histogram_extra_dimension/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP prometheus_tsdb_compaction_chunk_range Final time range of chunks on their first compaction 2 | # TYPE prometheus_tsdb_compaction_chunk_range histogram 3 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="100"} 0 4 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="400"} 0 5 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="1600"} 0 6 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="6400"} 0 7 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="25600"} 7 8 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="102400"} 7 9 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="409600"} 1.412839e+06 10 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="1.6384e+06"} 1.69185e+06 11 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="6.5536e+06"} 1.691853e+06 12 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="2.62144e+07"} 1.691853e+06 13 | prometheus_tsdb_compaction_chunk_range_bucket{foo="bar",le="+Inf"} 1.691853e+06 14 | prometheus_tsdb_compaction_chunk_range_sum{foo="bar"} 6.71393432189e+11 15 | prometheus_tsdb_compaction_chunk_range_count{foo="bar"} 1.691853e+06 16 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="100"} 0 17 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="400"} 0 18 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="1600"} 0 19 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="6400"} 0 20 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="25600"} 7 21 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="102400"} 7 22 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="409600"} 1.412839e+06 23 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="1.6384e+06"} 1.69185e+06 24 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="6.5536e+06"} 1.691853e+06 25 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="2.62144e+07"} 1.691853e+06 26 | prometheus_tsdb_compaction_chunk_range_bucket{foo="baz",le="+Inf"} 1.691853e+06 27 | prometheus_tsdb_compaction_chunk_range_sum{foo="baz"} 6.71393432189e+11 28 | prometheus_tsdb_compaction_chunk_range_count{foo="baz"} 1.691853e+06 29 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/inconsistent_metrics.out: -------------------------------------------------------------------------------- 1 | # HELP go_goroutines Number of goroutines that currently exist. 2 | # TYPE go_goroutines gauge 3 | go_goroutines{foo=""} 20 4 | go_goroutines{foo="bar"} 229 5 | # HELP http_requests_total Total number of HTTP requests made. 6 | # TYPE http_requests_total counter 7 | http_requests_total{baz="",code="200",foo="",handler="",method="get"} 11 8 | http_requests_total{baz="",code="200",foo="",handler="alerts",method="get"} 35 9 | http_requests_total{baz="",code="200",foo="",handler="config",method="get"} 8 10 | http_requests_total{baz="",code="200",foo="",handler="flags",method="get"} 18 11 | http_requests_total{baz="",code="200",foo="",handler="graph",method="get"} 89 12 | http_requests_total{baz="",code="200",foo="",handler="prometheus",method="get"} 17051 13 | http_requests_total{baz="",code="200",foo="",handler="query",method="get"} 401 14 | http_requests_total{baz="",code="200",foo="",handler="query_range",method="get"} 15663 15 | http_requests_total{baz="",code="200",foo="",handler="rules",method="get"} 7 16 | http_requests_total{baz="",code="200",foo="",handler="series",method="get"} 221 17 | http_requests_total{baz="",code="200",foo="",handler="static",method="get"} 1647 18 | http_requests_total{baz="",code="200",foo="",handler="status",method="get"} 12 19 | http_requests_total{baz="",code="200",foo="bar",handler="",method="get"} 325 20 | http_requests_total{baz="",code="206",foo="",handler="static",method="get"} 2 21 | http_requests_total{baz="",code="400",foo="",handler="query_range",method="get"} 40 22 | http_requests_total{baz="",code="503",foo="",handler="query_range",method="get"} 3 23 | http_requests_total{baz="bar",code="200",foo="",handler="",method="get"} 93 24 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 25 | # TYPE node_textfile_mtime_seconds gauge 26 | node_textfile_mtime_seconds{file="fixtures/textfile/inconsistent_metrics/metrics.prom"} 1 27 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 28 | # TYPE node_textfile_scrape_error gauge 29 | node_textfile_scrape_error 0 30 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/inconsistent_metrics/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP http_requests_total Total number of HTTP requests made. 2 | # TYPE http_requests_total counter 3 | http_requests_total{code="200",handler="alerts",method="get"} 35 4 | http_requests_total{code="200",handler="config",method="get"} 8 5 | http_requests_total{code="200",method="get", foo="bar"} 325 6 | http_requests_total{code="200",handler="flags",method="get"} 18 7 | http_requests_total{code="200",handler="graph",method="get"} 89 8 | http_requests_total{code="200",method="get", baz="bar"} 93 9 | http_requests_total{code="200",handler="prometheus",method="get"} 17051 10 | http_requests_total{code="200",handler="query",method="get"} 401 11 | http_requests_total{code="200",handler="query_range",method="get"} 15663 12 | http_requests_total{code="200",handler="rules",method="get"} 7 13 | http_requests_total{code="200",handler="series",method="get"} 221 14 | http_requests_total{code="200",handler="static",method="get"} 1647 15 | http_requests_total{code="200",handler="status",method="get"} 12 16 | http_requests_total{code="200",method="get"} 11 17 | http_requests_total{code="206",handler="static",method="get"} 2 18 | http_requests_total{code="400",handler="query_range",method="get"} 40 19 | http_requests_total{code="503",handler="query_range",method="get"} 3 20 | 21 | # HELP go_goroutines Number of goroutines that currently exist. 22 | # TYPE go_goroutines gauge 23 | go_goroutines{foo="bar"} 229 24 | go_goroutines 20 25 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_different_help.out: -------------------------------------------------------------------------------- 1 | # HELP events_total A nice help message. 2 | # TYPE events_total counter 3 | events_total{file="a",foo="bar"} 10 4 | events_total{file="a",foo="baz"} 20 5 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 6 | # TYPE node_textfile_mtime_seconds gauge 7 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_different_help/a.prom"} 1 8 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_different_help/b.prom"} 1 9 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 10 | # TYPE node_textfile_scrape_error gauge 11 | node_textfile_scrape_error 0 12 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_different_help/a.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total A nice help message. 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="a"} 10 4 | events_total{foo="baz",file="a"} 20 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_different_help/b.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total A different help message. 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="b"} 30 4 | events_total{foo="baz",file="b"} 40 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_empty_help.out: -------------------------------------------------------------------------------- 1 | # HELP events_total Metric read from fixtures/textfile/metrics_merge_empty_help/a.prom, fixtures/textfile/metrics_merge_empty_help/b.prom 2 | # TYPE events_total counter 3 | events_total{file="a",foo="bar"} 10 4 | events_total{file="a",foo="baz"} 20 5 | events_total{file="b",foo="bar"} 30 6 | events_total{file="b",foo="baz"} 40 7 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 8 | # TYPE node_textfile_mtime_seconds gauge 9 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_empty_help/a.prom"} 1 10 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_empty_help/b.prom"} 1 11 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 12 | # TYPE node_textfile_scrape_error gauge 13 | node_textfile_scrape_error 0 14 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_empty_help/a.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="a"} 10 4 | events_total{foo="baz",file="a"} 20 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_empty_help/b.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="b"} 30 4 | events_total{foo="baz",file="b"} 40 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_no_help.out: -------------------------------------------------------------------------------- 1 | # HELP events_total Metric read from fixtures/textfile/metrics_merge_no_help/a.prom, fixtures/textfile/metrics_merge_no_help/b.prom 2 | # TYPE events_total counter 3 | events_total{file="a",foo="bar"} 10 4 | events_total{file="a",foo="baz"} 20 5 | events_total{file="b",foo="bar"} 30 6 | events_total{file="b",foo="baz"} 40 7 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 8 | # TYPE node_textfile_mtime_seconds gauge 9 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_no_help/a.prom"} 1 10 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_no_help/b.prom"} 1 11 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 12 | # TYPE node_textfile_scrape_error gauge 13 | node_textfile_scrape_error 0 14 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_no_help/a.prom: -------------------------------------------------------------------------------- 1 | # TYPE events_total counter 2 | events_total{foo="bar",file="a"} 10 3 | events_total{foo="baz",file="a"} 20 4 | 5 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_no_help/b.prom: -------------------------------------------------------------------------------- 1 | # TYPE events_total counter 2 | events_total{foo="bar",file="b"} 30 3 | events_total{foo="baz",file="b"} 40 4 | 5 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_same_help.out: -------------------------------------------------------------------------------- 1 | # HELP events_total The same help. 2 | # TYPE events_total counter 3 | events_total{file="a",foo="bar"} 10 4 | events_total{file="a",foo="baz"} 20 5 | events_total{file="b",foo="bar"} 30 6 | events_total{file="b",foo="baz"} 40 7 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 8 | # TYPE node_textfile_mtime_seconds gauge 9 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_same_help/a.prom"} 1 10 | node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_same_help/b.prom"} 1 11 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 12 | # TYPE node_textfile_scrape_error gauge 13 | node_textfile_scrape_error 0 14 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_same_help/a.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total The same help. 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="a"} 10 4 | events_total{foo="baz",file="a"} 20 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/metrics_merge_same_help/b.prom: -------------------------------------------------------------------------------- 1 | # HELP events_total The same help. 2 | # TYPE events_total counter 3 | events_total{foo="bar",file="b"} 30 4 | events_total{foo="baz",file="b"} 40 5 | 6 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/no_metric_files.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 2 | # TYPE node_textfile_scrape_error gauge 3 | node_textfile_scrape_error 0 4 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/no_metric_files/non_matching_file.txt: -------------------------------------------------------------------------------- 1 | This file should be ignored. 2 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/nonexistent_path.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 2 | # TYPE node_textfile_scrape_error gauge 3 | node_textfile_scrape_error 1 4 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/summary.out: -------------------------------------------------------------------------------- 1 | # HELP event_duration_seconds_total Query timings 2 | # TYPE event_duration_seconds_total summary 3 | event_duration_seconds_total{baz="inner_eval",quantile="0.5"} 1.073e-06 4 | event_duration_seconds_total{baz="inner_eval",quantile="0.9"} 1.928e-06 5 | event_duration_seconds_total{baz="inner_eval",quantile="0.99"} 4.35e-06 6 | event_duration_seconds_total_sum{baz="inner_eval"} 1.8652166505091474e+06 7 | event_duration_seconds_total_count{baz="inner_eval"} 1.492355615e+09 8 | event_duration_seconds_total{baz="prepare_time",quantile="0.5"} 4.283e-06 9 | event_duration_seconds_total{baz="prepare_time",quantile="0.9"} 7.796e-06 10 | event_duration_seconds_total{baz="prepare_time",quantile="0.99"} 2.2083e-05 11 | event_duration_seconds_total_sum{baz="prepare_time"} 840923.7919437207 12 | event_duration_seconds_total_count{baz="prepare_time"} 1.492355814e+09 13 | event_duration_seconds_total{baz="result_append",quantile="0.5"} 1.566e-06 14 | event_duration_seconds_total{baz="result_append",quantile="0.9"} 3.223e-06 15 | event_duration_seconds_total{baz="result_append",quantile="0.99"} 6.53e-06 16 | event_duration_seconds_total_sum{baz="result_append"} 4.404109951000078 17 | event_duration_seconds_total_count{baz="result_append"} 1.427647e+06 18 | event_duration_seconds_total{baz="result_sort",quantile="0.5"} 1.847e-06 19 | event_duration_seconds_total{baz="result_sort",quantile="0.9"} 2.975e-06 20 | event_duration_seconds_total{baz="result_sort",quantile="0.99"} 4.08e-06 21 | event_duration_seconds_total_sum{baz="result_sort"} 3.4123187829998307 22 | event_duration_seconds_total_count{baz="result_sort"} 1.427647e+06 23 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 24 | # TYPE node_textfile_mtime_seconds gauge 25 | node_textfile_mtime_seconds{file="fixtures/textfile/summary/metrics.prom"} 1 26 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 27 | # TYPE node_textfile_scrape_error gauge 28 | node_textfile_scrape_error 0 29 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/summary/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP event_duration_seconds_total Query timings 2 | # TYPE event_duration_seconds_total summary 3 | event_duration_seconds_total{baz="inner_eval",quantile="0.5"} 1.073e-06 4 | event_duration_seconds_total{baz="inner_eval",quantile="0.9"} 1.928e-06 5 | event_duration_seconds_total{baz="inner_eval",quantile="0.99"} 4.35e-06 6 | event_duration_seconds_total_sum{baz="inner_eval"} 1.8652166505091474e+06 7 | event_duration_seconds_total_count{baz="inner_eval"} 1.492355615e+09 8 | event_duration_seconds_total{baz="prepare_time",quantile="0.5"} 4.283e-06 9 | event_duration_seconds_total{baz="prepare_time",quantile="0.9"} 7.796e-06 10 | event_duration_seconds_total{baz="prepare_time",quantile="0.99"} 2.2083e-05 11 | event_duration_seconds_total_sum{baz="prepare_time"} 840923.7919437207 12 | event_duration_seconds_total_count{baz="prepare_time"} 1.492355814e+09 13 | event_duration_seconds_total{baz="result_append",quantile="0.5"} 1.566e-06 14 | event_duration_seconds_total{baz="result_append",quantile="0.9"} 3.223e-06 15 | event_duration_seconds_total{baz="result_append",quantile="0.99"} 6.53e-06 16 | event_duration_seconds_total_sum{baz="result_append"} 4.404109951000078 17 | event_duration_seconds_total_count{baz="result_append"} 1.427647e+06 18 | event_duration_seconds_total{baz="result_sort",quantile="0.5"} 1.847e-06 19 | event_duration_seconds_total{baz="result_sort",quantile="0.9"} 2.975e-06 20 | event_duration_seconds_total{baz="result_sort",quantile="0.99"} 4.08e-06 21 | event_duration_seconds_total_sum{baz="result_sort"} 3.4123187829998307 22 | event_duration_seconds_total_count{baz="result_sort"} 1.427647e+06 23 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/summary_extra_dimension.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 2 | # TYPE node_textfile_mtime_seconds gauge 3 | node_textfile_mtime_seconds{file="fixtures/textfile/summary_extra_dimension/metrics.prom"} 1 4 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 5 | # TYPE node_textfile_scrape_error gauge 6 | node_textfile_scrape_error 0 7 | # HELP prometheus_rule_evaluation_duration_seconds The duration for a rule to execute. 8 | # TYPE prometheus_rule_evaluation_duration_seconds summary 9 | prometheus_rule_evaluation_duration_seconds{handler="",rule_type="alerting",quantile="0.9"} 0.001765451 10 | prometheus_rule_evaluation_duration_seconds{handler="",rule_type="alerting",quantile="0.99"} 0.018672076 11 | prometheus_rule_evaluation_duration_seconds_sum{handler="",rule_type="alerting"} 214.85081044700146 12 | prometheus_rule_evaluation_duration_seconds_count{handler="",rule_type="alerting"} 185209 13 | prometheus_rule_evaluation_duration_seconds{handler="",rule_type="recording",quantile="0.5"} 4.3132e-05 14 | prometheus_rule_evaluation_duration_seconds{handler="",rule_type="recording",quantile="0.9"} 8.9295e-05 15 | prometheus_rule_evaluation_duration_seconds{handler="",rule_type="recording",quantile="0.99"} 0.000193657 16 | prometheus_rule_evaluation_duration_seconds_sum{handler="",rule_type="recording"} 185091.01317759082 17 | prometheus_rule_evaluation_duration_seconds_count{handler="",rule_type="recording"} 1.0020195e+08 18 | prometheus_rule_evaluation_duration_seconds{handler="foo",rule_type="alerting",quantile="0.5"} 0.000571464 19 | prometheus_rule_evaluation_duration_seconds_sum{handler="foo",rule_type="alerting"} 0 20 | prometheus_rule_evaluation_duration_seconds_count{handler="foo",rule_type="alerting"} 0 21 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/summary_extra_dimension/metrics.prom: -------------------------------------------------------------------------------- 1 | # HELP prometheus_rule_evaluation_duration_seconds The duration for a rule to execute. 2 | # TYPE prometheus_rule_evaluation_duration_seconds summary 3 | prometheus_rule_evaluation_duration_seconds{rule_type="alerting",quantile="0.5", handler="foo"} 0.000571464 4 | prometheus_rule_evaluation_duration_seconds{rule_type="alerting",quantile="0.9"} 0.001765451 5 | prometheus_rule_evaluation_duration_seconds{rule_type="alerting",quantile="0.99"} 0.018672076 6 | prometheus_rule_evaluation_duration_seconds_sum{rule_type="alerting"} 214.85081044700146 7 | prometheus_rule_evaluation_duration_seconds_count{rule_type="alerting"} 185209 8 | prometheus_rule_evaluation_duration_seconds{rule_type="recording",quantile="0.5"} 4.3132e-05 9 | prometheus_rule_evaluation_duration_seconds{rule_type="recording",quantile="0.9"} 8.9295e-05 10 | prometheus_rule_evaluation_duration_seconds{rule_type="recording",quantile="0.99"} 0.000193657 11 | prometheus_rule_evaluation_duration_seconds_sum{rule_type="recording"} 185091.01317759082 12 | prometheus_rule_evaluation_duration_seconds_count{rule_type="recording"} 1.0020195e+08 13 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/two_metric_files.out: -------------------------------------------------------------------------------- 1 | # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. 2 | # TYPE node_textfile_mtime_seconds gauge 3 | node_textfile_mtime_seconds{file="fixtures/textfile/two_metric_files/metrics1.prom"} 1 4 | node_textfile_mtime_seconds{file="fixtures/textfile/two_metric_files/metrics2.prom"} 1 5 | # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise 6 | # TYPE node_textfile_scrape_error gauge 7 | node_textfile_scrape_error 0 8 | # HELP testmetric1_1 Metric read from fixtures/textfile/two_metric_files/metrics1.prom 9 | # TYPE testmetric1_1 untyped 10 | testmetric1_1{foo="bar"} 10 11 | # HELP testmetric1_2 Metric read from fixtures/textfile/two_metric_files/metrics1.prom 12 | # TYPE testmetric1_2 untyped 13 | testmetric1_2{foo="baz"} 20 14 | # HELP testmetric2_1 Metric read from fixtures/textfile/two_metric_files/metrics2.prom 15 | # TYPE testmetric2_1 untyped 16 | testmetric2_1{foo="bar"} 30 17 | # HELP testmetric2_2 Metric read from fixtures/textfile/two_metric_files/metrics2.prom 18 | # TYPE testmetric2_2 untyped 19 | testmetric2_2{foo="baz"} 40 20 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/two_metric_files/metrics1.prom: -------------------------------------------------------------------------------- 1 | testmetric1_1{foo="bar"} 10 2 | testmetric1_2{foo="baz"} 20 3 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/two_metric_files/metrics2.prom: -------------------------------------------------------------------------------- 1 | testmetric2_1{foo="bar"} 30 2 | testmetric2_2{foo="baz"} 40 3 | -------------------------------------------------------------------------------- /collector/fixtures/textfile/two_metric_files/non_matching_file.txt: -------------------------------------------------------------------------------- 1 | This file should be ignored. 2 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b11:0: -------------------------------------------------------------------------------- 1 | S:disk/by-id/usb-AMI_Virtual_CDROM0_AAAABBBBCCCC1-0:0 2 | S:disk/by-path/pci-0000:00:14.0-usb-0:1.1:1.0-scsi-0:0:0:0 3 | S:cdrom 4 | L:-100 5 | I:83543243 6 | E:ID_CDROM=1 7 | E:SYSTEMD_MOUNT_DEVICE_BOUND=1 8 | E:ID_VENDOR=AMI 9 | E:ID_VENDOR_ENC=AMI\x20\x20\x20\x20\x20 10 | E:ID_VENDOR_ID=c096 11 | E:ID_MODEL=Virtual_CDROM0 12 | E:ID_MODEL_ENC=Virtual\x20CDROM0\x20\x20 13 | E:ID_MODEL_ID=ee31 14 | E:ID_REVISION=1.00 15 | E:ID_SERIAL=AMI_Virtual_CDROM0_AAAABBBBCCCC1-0:0 16 | E:ID_SERIAL_SHORT=AAAABBBBCCCC1 17 | E:ID_TYPE=cd/dvd 18 | E:ID_INSTANCE=0:0 19 | E:ID_BUS=usb 20 | E:ID_USB_INTERFACES=:905639: 21 | E:ID_USB_INTERFACE_NUM=00 22 | E:ID_USB_DRIVER=usb-storage 23 | E:ID_PATH=pci-0000:00:14.0-usb-0:1.1:1.0-scsi-0:0:0:0 24 | E:ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_1_0-scsi-0_0_0_0 25 | E:SCSI_TPGS=0 26 | E:SCSI_TYPE=cd/dvd 27 | E:SCSI_VENDOR=AMI 28 | E:SCSI_VENDOR_ENC=AMI\x20\x20\x20\x20\x20 29 | E:SCSI_MODEL=Virtual_CDROM0 30 | E:SCSI_MODEL_ENC=Virtual\x20CDROM0\x20\x20 31 | E:SCSI_REVISION=1.00 32 | E:ID_SCSI=1 33 | E:ID_SCSI_INQUIRY=1 34 | E:ID_FS_TYPE= 35 | E:ID_FOR_SEAT=block-pci-0000_00_14_0-usb-0_1_1_1_0-scsi-0_0_0_0 36 | G:uaccess 37 | G:systemd 38 | G:seat 39 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b179:0: -------------------------------------------------------------------------------- 1 | S:disk/by-path/platform-df2969f3.mmc 2 | S:disk/by-id/mmc-SC64G_0x83e36d93 3 | W:1 4 | I:7679747 5 | E:ID_NAME=SC64G 6 | E:ID_SERIAL=0x83e36d93 7 | E:ID_PATH=platform-df2969f3.mmc 8 | E:ID_PATH_TAG=platform-df2969f3_mmc 9 | E:ID_PART_TABLE_UUID=1954c9df 10 | E:ID_PART_TABLE_TYPE=dos 11 | E:ID_DRIVE_FLASH_SD=1 12 | E:ID_DRIVE_MEDIA_FLASH_SD=1 13 | G:systemd 14 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b179:1: -------------------------------------------------------------------------------- 1 | S:disk/by-id/mmc-SC64G_0x83e36d93-part1 2 | S:disk/by-path/platform-df2969f3.mmc-part1 3 | S:disk/by-label/boot 4 | S:disk/by-uuid/6284-658D 5 | S:disk/by-partuuid/1954c9df-01 6 | W:12 7 | I:8463403 8 | E:ID_NAME=SC64G 9 | E:ID_SERIAL=0x83e36d93 10 | E:ID_PATH=platform-df2969f3.mmc 11 | E:ID_PATH_TAG=platform-df2969f3_mmc 12 | E:ID_PART_TABLE_UUID=1954c9df 13 | E:ID_PART_TABLE_TYPE=dos 14 | E:ID_DRIVE_FLASH_SD=1 15 | E:ID_DRIVE_MEDIA_FLASH_SD=1 16 | E:ID_FS_LABEL=boot 17 | E:ID_FS_LABEL_ENC=boot 18 | E:ID_FS_UUID=6284-658D 19 | E:ID_FS_UUID_ENC=6284-658D 20 | E:ID_FS_VERSION=FAT32 21 | E:ID_FS_TYPE=vfat 22 | E:ID_FS_USAGE=filesystem 23 | E:ID_PART_ENTRY_SCHEME=dos 24 | E:ID_PART_ENTRY_UUID=1954c9df-01 25 | E:ID_PART_ENTRY_TYPE=0xc 26 | E:ID_PART_ENTRY_NUMBER=1 27 | E:ID_PART_ENTRY_OFFSET=8192 28 | E:ID_PART_ENTRY_SIZE=524288 29 | E:ID_PART_ENTRY_DISK=179:0 30 | G:systemd 31 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b179:2: -------------------------------------------------------------------------------- 1 | S:disk/by-id/mmc-SC64G_0x83e36d93-part2 2 | S:disk/by-path/platform-df2969f3.mmc-part2 3 | S:disk/by-label/rootfs 4 | S:disk/by-uuid/83324ce8-a6f3-4e35-ad64-dbb3d6b87a32 5 | S:disk/by-partuuid/1954c9df-02 6 | W:2 7 | I:7676649 8 | E:ID_NAME=SC64G 9 | E:ID_SERIAL=0x83e36d93 10 | E:ID_PATH=platform-df2969f3.mmc 11 | E:ID_PATH_TAG=platform-df2969f3_mmc 12 | E:ID_PART_TABLE_UUID=1954c9df 13 | E:ID_PART_TABLE_TYPE=dos 14 | E:ID_DRIVE_FLASH_SD=1 15 | E:ID_DRIVE_MEDIA_FLASH_SD=1 16 | E:ID_FS_LABEL=rootfs 17 | E:ID_FS_LABEL_ENC=rootfs 18 | E:ID_FS_UUID=83324ce8-a6f3-4e35-ad64-dbb3d6b87a32 19 | E:ID_FS_UUID_ENC=83324ce8-a6f3-4e35-ad64-dbb3d6b87a32 20 | E:ID_FS_VERSION=1.0 21 | E:ID_FS_TYPE=ext4 22 | E:ID_FS_USAGE=filesystem 23 | E:ID_PART_ENTRY_SCHEME=dos 24 | E:ID_PART_ENTRY_UUID=1954c9df-02 25 | E:ID_PART_ENTRY_TYPE=0x83 26 | E:ID_PART_ENTRY_NUMBER=2 27 | E:ID_PART_ENTRY_OFFSET=532480 28 | E:ID_PART_ENTRY_SIZE=124203008 29 | E:ID_PART_ENTRY_DISK=179:0 30 | G:systemd 31 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:0: -------------------------------------------------------------------------------- 1 | S:disk/by-id/dm-name-nvme0n1_crypt 2 | S:mapper/nvme0n1_crypt 3 | S:disk/by-id/lvm-pv-uuid-c3C3uW-gD96-Yw69-c1CJ-5MwT-6ysM-mST0vB 4 | S:disk/by-id/dm-uuid-CRYPT-LUKS2-jolaulot80fy9zsiobkxyxo7y2dqeho2-nvme0n1_crypt 5 | I:72859885 6 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 7 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 8 | E:DM_UDEV_RULES=1 9 | E:DM_UDEV_RULES_VSN=2 10 | E:DM_NAME=nvme0n1_crypt 11 | E:DM_UUID=CRYPT-LUKS2-jolaulot80fy9zsiobkxyxo7y2dqeho2-nvme0n1_crypt 12 | E:DM_SUSPENDED=0 13 | E:ID_FS_UUID=c3C3uW-gD96-Yw69-c1CJ-5MwT-6ysM-mST0vB 14 | E:ID_FS_UUID_ENC=c3C3uW-gD96-Yw69-c1CJ-5MwT-6ysM-mST0vB 15 | E:ID_FS_VERSION=LVM2 001 16 | E:ID_FS_TYPE=LVM2_member 17 | E:ID_FS_USAGE=raid 18 | G:systemd 19 | Q:systemd 20 | V:1 21 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:1: -------------------------------------------------------------------------------- 1 | S:disk/by-id/dm-uuid-LVM-wbGqQEBL9SxrW2DLntJwgg8fAv946hw3Tvjqh0v31fWgxEtD4BoHO0lROWFUY65T 2 | S:mapper/system-swap_1 3 | S:disk/by-id/dm-name-system-swap_1 4 | S:disk/by-uuid/5272bb60-04b5-49cd-b730-be57c7604450 5 | S:system/swap_1 6 | I:78705530 7 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 8 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 9 | E:DM_UDEV_RULES=1 10 | E:DM_UDEV_RULES_VSN=2 11 | E:DM_NAME=system-swap_1 12 | E:DM_UUID=LVM-wbGqQEBL9SxrW2DLntJwgg8fAv946hw3Tvjqh0v31fWgxEtD4BoHO0lROWFUY65T 13 | E:DM_SUSPENDED=0 14 | E:DM_VG_NAME=system 15 | E:DM_LV_NAME=swap_1 16 | E:DM_LV_LAYER= 17 | E:ID_FS_UUID=5272bb60-04b5-49cd-b730-be57c7604450 18 | E:ID_FS_UUID_ENC=5272bb60-04b5-49cd-b730-be57c7604450 19 | E:ID_FS_VERSION=1 20 | E:ID_FS_TYPE=swap 21 | E:ID_FS_USAGE=other 22 | G:systemd 23 | Q:systemd 24 | V:1 25 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:2: -------------------------------------------------------------------------------- 1 | S:disk/by-id/dm-name-system-root 2 | S:disk/by-id/dm-uuid-LVM-NWEDo8q5ABDyJuC3F8veKNyWfYmeIBfFMS4MF3HakzUhkk7ekDm6fJTHkl2fYHe7 3 | S:mapper/system-root 4 | S:disk/by-uuid/3deafd0d-faff-4695-8d15-51061ae1f51b 5 | S:system/root 6 | I:77655410 7 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 8 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 9 | E:DM_UDEV_RULES=1 10 | E:DM_UDEV_RULES_VSN=2 11 | E:DM_NAME=system-root 12 | E:DM_UUID=LVM-NWEDo8q5ABDyJuC3F8veKNyWfYmeIBfFMS4MF3HakzUhkk7ekDm6fJTHkl2fYHe7 13 | E:DM_SUSPENDED=0 14 | E:DM_VG_NAME=system 15 | E:DM_LV_NAME=root 16 | E:DM_LV_LAYER= 17 | E:ID_FS_UUID=3deafd0d-faff-4695-8d15-51061ae1f51b 18 | E:ID_FS_UUID_ENC=3deafd0d-faff-4695-8d15-51061ae1f51b 19 | E:ID_FS_VERSION=1.0 20 | E:ID_FS_TYPE=ext4 21 | E:ID_FS_USAGE=filesystem 22 | G:systemd 23 | Q:systemd 24 | V:1 25 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:3: -------------------------------------------------------------------------------- 1 | S:disk/by-id/dm-name-system-var 2 | S:disk/by-id/dm-uuid-LVM-hrxHo0rlZ6U95ku5841Lpd17bS1Z7V7lrtEE60DVgE6YEOCdS9gcDGyonWim4hGP 3 | S:mapper/system-var 4 | S:disk/by-uuid/5c772222-f7d4-4c8e-87e8-e97df6b7a45e 5 | S:system/var 6 | I:79395348 7 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 8 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 9 | E:DM_UDEV_RULES=1 10 | E:DM_UDEV_RULES_VSN=2 11 | E:DM_NAME=system-var 12 | E:DM_UUID=LVM-hrxHo0rlZ6U95ku5841Lpd17bS1Z7V7lrtEE60DVgE6YEOCdS9gcDGyonWim4hGP 13 | E:DM_SUSPENDED=0 14 | E:DM_VG_NAME=system 15 | E:DM_LV_NAME=var 16 | E:DM_LV_LAYER= 17 | E:ID_FS_UUID=5c772222-f7d4-4c8e-87e8-e97df6b7a45e 18 | E:ID_FS_UUID_ENC=5c772222-f7d4-4c8e-87e8-e97df6b7a45e 19 | E:ID_FS_VERSION=1.0 20 | E:ID_FS_TYPE=ext4 21 | E:ID_FS_USAGE=filesystem 22 | G:systemd 23 | Q:systemd 24 | V:1 25 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:4: -------------------------------------------------------------------------------- 1 | S:system/tmp 2 | S:disk/by-uuid/a9479d44-60e1-4015-a1e5-bb065e6dd11b 3 | S:disk/by-id/dm-uuid-LVM-XTNGOHjPWLHcxmJmVu5cWTXEtuzqDeBkdEHAZW5q9LxWQ2d4mb5CchUQzUPJpl8H 4 | S:mapper/system-tmp 5 | S:disk/by-id/dm-name-system-tmp 6 | I:75852450 7 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 8 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 9 | E:DM_UDEV_RULES=1 10 | E:DM_UDEV_RULES_VSN=2 11 | E:DM_NAME=system-tmp 12 | E:DM_UUID=LVM-XTNGOHjPWLHcxmJmVu5cWTXEtuzqDeBkdEHAZW5q9LxWQ2d4mb5CchUQzUPJpl8H 13 | E:DM_SUSPENDED=0 14 | E:DM_VG_NAME=system 15 | E:DM_LV_NAME=tmp 16 | E:DM_LV_LAYER= 17 | E:ID_FS_UUID=a9479d44-60e1-4015-a1e5-bb065e6dd11b 18 | E:ID_FS_UUID_ENC=a9479d44-60e1-4015-a1e5-bb065e6dd11b 19 | E:ID_FS_VERSION=1.0 20 | E:ID_FS_TYPE=ext4 21 | E:ID_FS_USAGE=filesystem 22 | G:systemd 23 | Q:systemd 24 | V:1 25 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b252:5: -------------------------------------------------------------------------------- 1 | S:disk/by-uuid/b05b726a-c718-4c4d-8641-7c73a7696d83 2 | S:mapper/system-home 3 | S:system/home 4 | S:disk/by-id/dm-name-system-home 5 | S:disk/by-id/dm-uuid-LVM-MtoJaWTpjWRXlUnNFlpxZauTEuYlMvGFutigEzCCrfj8CNh6jCRi5LQJXZCpLjPf 6 | I:72604009 7 | E:DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1 8 | E:DM_UDEV_PRIMARY_SOURCE_FLAG=1 9 | E:DM_UDEV_RULES=1 10 | E:DM_UDEV_RULES_VSN=2 11 | E:DM_NAME=system-home 12 | E:DM_UUID=LVM-MtoJaWTpjWRXlUnNFlpxZauTEuYlMvGFutigEzCCrfj8CNh6jCRi5LQJXZCpLjPf 13 | E:DM_SUSPENDED=0 14 | E:DM_VG_NAME=system 15 | E:DM_LV_NAME=home 16 | E:DM_LV_LAYER= 17 | E:ID_FS_UUID=b05b726a-c718-4c4d-8641-7c73a7696d83 18 | E:ID_FS_UUID_ENC=b05b726a-c718-4c4d-8641-7c73a7696d83 19 | E:ID_FS_VERSION=1.0 20 | E:ID_FS_TYPE=ext4 21 | E:ID_FS_USAGE=filesystem 22 | G:systemd 23 | Q:systemd 24 | V:1 25 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b254:0: -------------------------------------------------------------------------------- 1 | S:disk/by-path/pci-0000:00:06.0 2 | S:disk/by-path/virtio-pci-0000:00:06.0 3 | W:1 4 | I:8524171 5 | E:ID_PATH=pci-0000:00:06.0 6 | E:ID_PATH_TAG=pci-0000_00_06_0 7 | E:ID_PART_TABLE_UUID=653b59fd 8 | E:ID_PART_TABLE_TYPE=dos 9 | E:ID_FS_TYPE= 10 | G:systemd 11 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b259:0: -------------------------------------------------------------------------------- 1 | S:disk/by-path/pci-0000:02:00.0-nvme-1 2 | S:disk/by-id/nvme-eui.p3vbbiejx5aae2r3 3 | S:disk/by-id/nvme-SAMSUNG_EHFTF55LURSY-000Y9_S252B6CU1HG3M1 4 | I:79621327 5 | E:ID_SERIAL_SHORT=S252B6CU1HG3M1 6 | E:ID_WWN=eui.p3vbbiejx5aae2r3 7 | E:ID_MODEL=SAMSUNG EHFTF55LURSY-000Y9 8 | E:ID_REVISION=4NBTUY95 9 | E:ID_SERIAL=SAMSUNG_EHFTF55LURSY-000Y9_S252B6CU1HG3M1 10 | E:ID_PATH=pci-0000:02:00.0-nvme-1 11 | E:ID_PATH_TAG=pci-0000_02_00_0-nvme-1 12 | E:ID_PART_TABLE_UUID=f301fdbd-fd1f-46d4-9fb8-c9aeb757f050 13 | E:ID_PART_TABLE_TYPE=gpt 14 | E:ID_FS_TYPE= 15 | G:systemd 16 | Q:systemd 17 | V:1 18 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b8:0: -------------------------------------------------------------------------------- 1 | S:disk/by-id/lvm-pv-uuid-cVVv6j-HSA2-IY33-1Jmj-dO2H-YL7w-b4Oxqw 2 | S:disk/by-id/scsi-SATA_TOSHIBA_KSDB4U86_2160A0D5FVGG 3 | S:disk/by-id/ata-TOSHIBA_KSDB4U866TE_2160A0D5FVGG 4 | S:disk/by-path/pci-0000:3b:00.0-sas-phy7-lun-0 5 | S:disk/by-id/scsi-37c72382b8de36a64 6 | S:disk/by-id/wwn-0x7c72382b8de36a64 7 | W:702 8 | I:73815117 9 | E:ID_ATA=1 10 | E:ID_TYPE=disk 11 | E:ID_BUS=ata 12 | E:ID_MODEL=TOSHIBA_KSDB4U86 13 | E:ID_MODEL_ENC=TOSHIBA\x20KSDB4U86 14 | E:ID_REVISION=0102 15 | E:ID_SERIAL=TOSHIBA_KSDB4U866TE_DTB0QRJR2EIG 16 | E:ID_SERIAL_SHORT=2160A0D5FVGG 17 | E:ID_ATA_WRITE_CACHE=1 18 | E:ID_ATA_WRITE_CACHE_ENABLED=0 19 | E:ID_ATA_FEATURE_SET_PM=1 20 | E:ID_ATA_FEATURE_SET_PM_ENABLED=1 21 | E:ID_ATA_FEATURE_SET_SECURITY=1 22 | E:ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 23 | E:ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=66892 24 | E:ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=66892 25 | E:ID_ATA_FEATURE_SET_SMART=1 26 | E:ID_ATA_FEATURE_SET_SMART_ENABLED=1 27 | E:ID_ATA_FEATURE_SET_APM=1 28 | E:ID_ATA_FEATURE_SET_APM_ENABLED=1 29 | E:ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=128 30 | E:ID_ATA_DOWNLOAD_MICROCODE=1 31 | E:ID_ATA_SATA=1 32 | E:ID_ATA_SATA_SIGNAL_RATE_GEN2=1 33 | E:ID_ATA_SATA_SIGNAL_RATE_GEN1=1 34 | E:ID_ATA_ROTATION_RATE_RPM=7200 35 | E:ID_WWN=0x7c72382b8de36a64 36 | E:ID_WWN_WITH_EXTENSION=0x7c72382b8de36a64 37 | E:ID_PATH=pci-0000:3b:00.0-sas-phy7-lun-0 38 | E:ID_PATH_TAG=pci-0000_3b_00_0-sas-phy7-lun-0 39 | E:ID_FS_UUID=cVVv6j-HSA2-IY33-1Jmj-dO2H-YL7w-b4Oxqw 40 | E:ID_FS_UUID_ENC=cVVv6j-HSA2-IY33-1Jmj-dO2H-YL7w-b4Oxqw 41 | E:ID_FS_VERSION=LVM2 001 42 | E:ID_FS_TYPE=LVM2_member 43 | E:ID_FS_USAGE=raid 44 | E:SCSI_TPGS=0 45 | E:SCSI_TYPE=disk 46 | E:SCSI_VENDOR=ATA 47 | E:SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 48 | E:SCSI_MODEL=TOSHIBA_KSDB4U86 49 | E:SCSI_MODEL_ENC=TOSHIBA\x20KSDB4U86 50 | E:SCSI_REVISION=0102 51 | E:ID_SCSI=1 52 | E:ID_SCSI_INQUIRY=1 53 | E:ID_VENDOR=ATA 54 | E:ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 55 | E:SCSI_IDENT_SERIAL=2160A0D5FVGG 56 | E:SCSI_IDENT_LUN_NAA_REG=7c72382b8de36a64 57 | E:SYSTEMD_READY=1 58 | E:SYSTEMD_ALIAS=/dev/block/8:0 59 | E:SYSTEMD_WANTS=lvm2-pvscan@8:0.service 60 | G:systemd 61 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b8:16: -------------------------------------------------------------------------------- 1 | S:disk/by-id/scsi-3e1b87abbb16bd84e 2 | S:disk/by-id/wwn-0xe1b87abbb16bd84e 3 | S:disk/by-path/pci-0000:00:1f.2-ata-1 4 | S:disk/by-id/scsi-0ATA_SuperMicro_SSD_SMC0E1B87ABBB16BD84E 5 | S:disk/by-id/scsi-SATA_SuperMicro_SSD_SMC0E1B87ABBB16BD84E 6 | S:disk/by-id/scsi-1ATA_SuperMicro_SSD_SMC0E1B87ABBB16BD84E 7 | S:disk/by-id/ata-SuperMicro_SSD_SMC0E1B87ABBB16BD84E 8 | W:58 9 | I:147686920 10 | E:ID_ATA=1 11 | E:ID_TYPE=disk 12 | E:ID_BUS=ata 13 | E:ID_MODEL=SuperMicro_SSD 14 | E:ID_MODEL_ENC=SuperMicro\x20SSD\x20\x20 15 | E:ID_REVISION=0R 16 | E:ID_SERIAL=SuperMicro_SSD_SMC0E1B87ABBB16BD84E 17 | E:ID_SERIAL_SHORT=SMC0E1B87ABBB16BD84E 18 | E:ID_ATA_WRITE_CACHE=1 19 | E:ID_ATA_WRITE_CACHE_ENABLED=1 20 | E:ID_ATA_FEATURE_SET_HPA=1 21 | E:ID_ATA_FEATURE_SET_HPA_ENABLED=1 22 | E:ID_ATA_FEATURE_SET_PM=1 23 | E:ID_ATA_FEATURE_SET_PM_ENABLED=1 24 | E:ID_ATA_FEATURE_SET_SECURITY=1 25 | E:ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 26 | E:ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=4 27 | E:ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=4 28 | E:ID_ATA_FEATURE_SET_SMART=1 29 | E:ID_ATA_FEATURE_SET_SMART_ENABLED=1 30 | E:ID_ATA_FEATURE_SET_AAM=1 31 | E:ID_ATA_FEATURE_SET_AAM_ENABLED=0 32 | E:ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=0 33 | E:ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=0 34 | E:ID_ATA_DOWNLOAD_MICROCODE=1 35 | E:ID_ATA_SATA=1 36 | E:ID_ATA_SATA_SIGNAL_RATE_GEN2=1 37 | E:ID_ATA_SATA_SIGNAL_RATE_GEN1=1 38 | E:ID_ATA_ROTATION_RATE_RPM=0 39 | E:ID_WWN=0xe1b87abbb16bd84e 40 | E:ID_WWN_WITH_EXTENSION=0xe1b87abbb16bd84e 41 | E:ID_PATH=pci-0000:00:1f.2-ata-1 42 | E:ID_PATH_TAG=pci-0000_00_1f_2-ata-1 43 | E:ID_PART_TABLE_UUID=45980145-24e2-4302-a7f0-364c68cfaf59 44 | E:ID_PART_TABLE_TYPE=gpt 45 | E:SCSI_TPGS=0 46 | E:SCSI_TYPE=disk 47 | E:SCSI_VENDOR=ATA 48 | E:SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 49 | E:SCSI_MODEL=SuperMicro_SSD 50 | E:SCSI_MODEL_ENC=SuperMicro\x20SSD\x20\x20 51 | E:SCSI_REVISION=0R 52 | E:ID_SCSI=1 53 | E:ID_SCSI_INQUIRY=1 54 | E:ID_VENDOR=ATA 55 | E:ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 56 | E:SCSI_IDENT_SERIAL=SMC0E1B87ABBB16BD84E 57 | E:SCSI_IDENT_LUN_VENDOR=SMC0E1B87ABBB16BD84E 58 | E:SCSI_IDENT_LUN_T10=ATA_SuperMicro_SSD_SMC0E1B87ABBB16BD84E 59 | E:SCSI_IDENT_LUN_ATA=SuperMicro_SSD_SMC0E1B87ABBB16BD84E 60 | E:SCSI_IDENT_LUN_NAA_REG=e1b87abbb16bd84e 61 | E:ID_FS_TYPE= 62 | G:systemd 63 | -------------------------------------------------------------------------------- /collector/fixtures/udev/data/b8:32: -------------------------------------------------------------------------------- 1 | S:disk/by-path/pci-0000:00:1f.2-ata-4 2 | S:disk/by-id/scsi-SATA_INTEL_SSDS9X9SI0_3EWB5Y25CWQWA7EH1U 3 | S:disk/by-id/scsi-0ATA_INTEL_SSDS9X9SI0_3EWB5Y25CWQWA7EH1U 4 | S:disk/by-id/scsi-1ATA_INTEL_SSDS9X9SI00G8_3EWB5Y25CWQWA7EH1U 5 | S:disk/by-id/lvm-pv-uuid-QFy9W7-Brj3-hQ6v-AF8i-3Zqg-n3Vs-kGY4vb 6 | S:disk/by-id/ata-INTEL_SSDS9X9SI00G8_3EWB5Y25CWQWA7EH1U 7 | S:disk/by-id/scsi-358907ddc573a5de 8 | S:disk/by-id/wwn-0x58907ddc573a5de 9 | W:10 10 | I:145572852 11 | E:ID_ATA=1 12 | E:ID_TYPE=disk 13 | E:ID_BUS=ata 14 | E:ID_MODEL=INTEL_SSDS9X9SI0 15 | E:ID_MODEL_ENC=INTEL\x20SSDS9X9SI0 16 | E:ID_REVISION=0100 17 | E:ID_SERIAL=INTEL_SSDS9X9SI00G8_3EWB5Y25CWQWA7EH1U 18 | E:ID_SERIAL_SHORT=3EWB5Y25CWQWA7EH1U 19 | E:ID_ATA_WRITE_CACHE=1 20 | E:ID_ATA_WRITE_CACHE_ENABLED=0 21 | E:ID_ATA_FEATURE_SET_PM=1 22 | E:ID_ATA_FEATURE_SET_PM_ENABLED=1 23 | E:ID_ATA_FEATURE_SET_SECURITY=1 24 | E:ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 25 | E:ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=4 26 | E:ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=4 27 | E:ID_ATA_FEATURE_SET_SMART=1 28 | E:ID_ATA_FEATURE_SET_SMART_ENABLED=1 29 | E:ID_ATA_DOWNLOAD_MICROCODE=1 30 | E:ID_ATA_SATA=1 31 | E:ID_ATA_SATA_SIGNAL_RATE_GEN2=1 32 | E:ID_ATA_SATA_SIGNAL_RATE_GEN1=1 33 | E:ID_ATA_ROTATION_RATE_RPM=0 34 | E:ID_WWN=0x58907ddc573a5de 35 | E:ID_WWN_WITH_EXTENSION=0x58907ddc573a5de 36 | E:ID_PATH=pci-0000:00:1f.2-ata-4 37 | E:ID_PATH_TAG=pci-0000_00_1f_2-ata-4 38 | E:ID_FS_UUID=QFy9W7-Brj3-hQ6v-AF8i-3Zqg-n3Vs-kGY4vb 39 | E:ID_FS_UUID_ENC=QFy9W7-Brj3-hQ6v-AF8i-3Zqg-n3Vs-kGY4vb 40 | E:ID_FS_VERSION=LVM2 001 41 | E:ID_FS_TYPE=LVM2_member 42 | E:ID_FS_USAGE=raid 43 | E:SCSI_TPGS=0 44 | E:SCSI_TYPE=disk 45 | E:SCSI_VENDOR=ATA 46 | E:SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 47 | E:SCSI_MODEL=INTEL_SSDS9X9SI0 48 | E:SCSI_MODEL_ENC=INTEL\x20SSDS9X9SI0 49 | E:SCSI_REVISION=0100 50 | E:ID_SCSI=1 51 | E:ID_SCSI_INQUIRY=1 52 | E:ID_VENDOR=ATA 53 | E:ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 54 | E:SCSI_IDENT_SERIAL=3EWB5Y25CWQWA7EH1U 55 | E:SCSI_IDENT_LUN_VENDOR=3EWB5Y25CWQWA7EH1U 56 | E:SCSI_IDENT_LUN_T10=ATA_INTEL_SSDS9X9SI00G8_3EWB5Y25CWQWA7EH1U 57 | E:SCSI_IDENT_LUN_ATA=INTEL_SSDS9X9SI00G8_3EWB5Y25CWQWA7EH1U 58 | E:SCSI_IDENT_LUN_NAA_REG=58907ddc573a5de 59 | E:SYSTEMD_READY=1 60 | E:SYSTEMD_ALIAS=/dev/block/8:32 61 | E:SYSTEMD_WANTS=lvm2-pvscan@8:32.service 62 | G:systemd 63 | -------------------------------------------------------------------------------- /collector/fixtures/usr/lib/os-release: -------------------------------------------------------------------------------- 1 | NAME="Ubuntu" 2 | VERSION="20.04.2 LTS (Focal Fossa)" 3 | ID=ubuntu 4 | ID_LIKE=debian 5 | PRETTY_NAME="Ubuntu 20.04.2 LTS" 6 | VERSION_ID="20.04" 7 | HOME_URL="https://www.ubuntu.com/" 8 | SUPPORT_URL="https://help.ubuntu.com/" 9 | BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" 10 | PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" 11 | VERSION_CODENAME=focal 12 | UBUNTU_CODENAME=focal 13 | -------------------------------------------------------------------------------- /collector/fixtures/wifi/interfaces.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "wlan0", 4 | "type": 2, 5 | "frequency": 2412 6 | }, 7 | { 8 | "name": "wlan1", 9 | "type": 3, 10 | "frequency": 2412 11 | }, 12 | { 13 | "type": 10 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /collector/fixtures/wifi/wlan0/bss.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssid": "Example", 3 | "bssid": "ABEiM0RV", 4 | "status": 1 5 | } 6 | -------------------------------------------------------------------------------- /collector/fixtures/wifi/wlan0/stationinfo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "hardwareaddr": "qrvM3e7/", 4 | "connected": 30000000000, 5 | "inactive": 400000000, 6 | "receivebitrate": 128000000, 7 | "transmitbitrate": 164000000, 8 | "signal": -52, 9 | "transmitretries": 10, 10 | "transmitfailed": 2, 11 | "beaconloss": 1 12 | }, 13 | { 14 | "hardwareaddr": "AQIDBAUG", 15 | "connected": 60000000000, 16 | "inactive": 800000000, 17 | "receivebitrate": 256000000, 18 | "transmitbitrate": 328000000, 19 | "signal": -26, 20 | "transmitretries": 20, 21 | "transmitfailed": 4, 22 | "beaconloss": 2 23 | } 24 | ] 25 | 26 | -------------------------------------------------------------------------------- /collector/fixtures_bindmount/proc/mounts: -------------------------------------------------------------------------------- 1 | /dev/nvme1n0 /host ext4 rw,seclabel,relatime,data=ordered 0 0 2 | /dev/nvme1n1 /host/media/volume1 ext4 rw,seclabel,relatime,data=ordered 0 0 3 | /dev/nvme1n2 /host/media/volume2 ext4 rw,seclabel,relatime,data=ordered 0 0 4 | tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 5 | tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0 6 | tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 7 | -------------------------------------------------------------------------------- /collector/fixtures_hidepid/proc/mounts: -------------------------------------------------------------------------------- 1 | rootfs / rootfs rw 0 0 2 | -------------------------------------------------------------------------------- /collector/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "os" 18 | "regexp" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | func readUintFromFile(path string) (uint64, error) { 24 | data, err := os.ReadFile(path) 25 | if err != nil { 26 | return 0, err 27 | } 28 | value, err := strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) 29 | if err != nil { 30 | return 0, err 31 | } 32 | return value, nil 33 | } 34 | 35 | var metricNameRegex = regexp.MustCompile(`_*[^0-9A-Za-z_]+_*`) 36 | 37 | // SanitizeMetricName sanitize the given metric name by replacing invalid characters by underscores. 38 | // 39 | // OpenMetrics and the Prometheus exposition format require the metric name 40 | // to consist only of alphanumericals and "_", ":" and they must not start 41 | // with digits. Since colons in MetricFamily are reserved to signal that the 42 | // MetricFamily is the result of a calculation or aggregation of a general 43 | // purpose monitoring system, colons will be replaced as well. 44 | // 45 | // Note: If not subsequently prepending a namespace and/or subsystem (e.g., 46 | // with prometheus.BuildFQName), the caller must ensure that the supplied 47 | // metricName does not begin with a digit. 48 | func SanitizeMetricName(metricName string) string { 49 | return metricNameRegex.ReplaceAllString(metricName, "_") 50 | } 51 | -------------------------------------------------------------------------------- /collector/helper_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "testing" 18 | ) 19 | 20 | func TestSanitizeMetricName(t *testing.T) { 21 | testcases := map[string]string{ 22 | "": "", 23 | "rx_errors": "rx_errors", 24 | "Queue[0] AllocFails": "Queue_0_AllocFails", 25 | "Tx LPI entry count": "Tx_LPI_entry_count", 26 | "port.VF_admin_queue_requests": "port_VF_admin_queue_requests", 27 | "[3]: tx_bytes": "_3_tx_bytes", 28 | " err": "_err", 29 | } 30 | 31 | for metricName, expected := range testcases { 32 | got := SanitizeMetricName(metricName) 33 | if expected != got { 34 | t.Errorf("Expected '%s' but got '%s'", expected, got) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /collector/interrupts_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (linux || openbsd) && !nointerrupts 15 | // +build linux openbsd 16 | // +build !nointerrupts 17 | 18 | package collector 19 | 20 | import ( 21 | "github.com/go-kit/log" 22 | "github.com/prometheus/client_golang/prometheus" 23 | ) 24 | 25 | type interruptsCollector struct { 26 | desc typedDesc 27 | logger log.Logger 28 | } 29 | 30 | func init() { 31 | registerCollector("interrupts", defaultDisabled, NewInterruptsCollector) 32 | } 33 | 34 | // NewInterruptsCollector returns a new Collector exposing interrupts stats. 35 | func NewInterruptsCollector(logger log.Logger) (Collector, error) { 36 | return &interruptsCollector{ 37 | desc: typedDesc{prometheus.NewDesc( 38 | namespace+"_interrupts_total", 39 | "Interrupt details.", 40 | interruptLabelNames, nil, 41 | ), prometheus.CounterValue}, 42 | logger: logger, 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /collector/interrupts_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "os" 18 | "testing" 19 | ) 20 | 21 | func TestInterrupts(t *testing.T) { 22 | file, err := os.Open("fixtures/proc/interrupts") 23 | if err != nil { 24 | t.Fatal(err) 25 | } 26 | defer file.Close() 27 | 28 | interrupts, err := parseInterrupts(file) 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | 33 | if want, got := "5031", interrupts["NMI"].values[1]; want != got { 34 | t.Errorf("want interrupts %s, got %s", want, got) 35 | } 36 | 37 | if want, got := "4968", interrupts["NMI"].values[3]; want != got { 38 | t.Errorf("want interrupts %s, got %s", want, got) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /collector/kvm_bsd.c: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build !nomeminfo 15 | // +build freebsd dragonfly 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | int _kvm_swap_used_pages(uint64_t *out) { 24 | const int total_only = 1; // from kvm_getswapinfo(3) 25 | 26 | kvm_t *kd; 27 | struct kvm_swap current; 28 | 29 | kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL); 30 | if (kd == NULL) { 31 | return -1; 32 | } 33 | 34 | if (kvm_getswapinfo(kd, ¤t, total_only, 0) == -1) { 35 | goto error1; 36 | } 37 | 38 | if (kvm_close(kd) != 0) { 39 | return -1; 40 | } 41 | kd = NULL; 42 | 43 | *out = current.ksw_used; 44 | return 0; 45 | 46 | error1: 47 | if (kd != NULL) { 48 | kvm_close(kd); 49 | } 50 | 51 | return -1; 52 | } 53 | -------------------------------------------------------------------------------- /collector/kvm_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nokvm && (freebsd || dragonfly) 15 | // +build !nokvm 16 | // +build freebsd dragonfly 17 | 18 | package collector 19 | 20 | import ( 21 | "fmt" 22 | "sync" 23 | ) 24 | 25 | // #cgo LDFLAGS: -lkvm 26 | // #include "kvm_bsd.h" 27 | import "C" 28 | 29 | type kvm struct { 30 | mu sync.Mutex 31 | hasErr bool 32 | } 33 | 34 | func (k *kvm) SwapUsedPages() (value uint64, err error) { 35 | k.mu.Lock() 36 | defer k.mu.Unlock() 37 | if C._kvm_swap_used_pages((*C.uint64_t)(&value)) == -1 { 38 | k.hasErr = true 39 | return 0, fmt.Errorf("couldn't get kvm stats") 40 | } 41 | 42 | return value, nil 43 | } 44 | -------------------------------------------------------------------------------- /collector/kvm_bsd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // +build !nomeminfo 15 | // +build freebsd dragonfly 16 | 17 | #include 18 | 19 | int _kvm_swap_used_pages(uint64_t *out); 20 | -------------------------------------------------------------------------------- /collector/lnstat_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nolnstat 15 | // +build !nolnstat 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | 23 | "github.com/go-kit/log" 24 | "github.com/prometheus/client_golang/prometheus" 25 | "github.com/prometheus/procfs" 26 | ) 27 | 28 | type lnstatCollector struct { 29 | logger log.Logger 30 | } 31 | 32 | func init() { 33 | registerCollector("lnstat", defaultDisabled, NewLnstatCollector) 34 | } 35 | 36 | func NewLnstatCollector(logger log.Logger) (Collector, error) { 37 | return &lnstatCollector{logger}, nil 38 | } 39 | 40 | func (c *lnstatCollector) Update(ch chan<- prometheus.Metric) error { 41 | const ( 42 | subsystem = "lnstat" 43 | ) 44 | 45 | fs, err := procfs.NewFS(*procPath) 46 | if err != nil { 47 | return fmt.Errorf("failed to open procfs: %w", err) 48 | } 49 | 50 | netStats, err := fs.NetStat() 51 | if err != nil { 52 | return fmt.Errorf("lnstat error: %s", err) 53 | } 54 | 55 | for _, netStatFile := range netStats { 56 | labelNames := []string{"subsystem", "cpu"} 57 | for header, stats := range netStatFile.Stats { 58 | for cpu, value := range stats { 59 | labelValues := []string{netStatFile.Filename, strconv.Itoa(cpu)} 60 | ch <- prometheus.MustNewConstMetric( 61 | prometheus.NewDesc( 62 | prometheus.BuildFQName(namespace, subsystem, header+"_total"), 63 | "linux network cache stats", 64 | labelNames, nil, 65 | ), 66 | prometheus.CounterValue, float64(value), labelValues..., 67 | ) 68 | } 69 | } 70 | } 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /collector/loadavg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && !noloadavg 15 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 16 | // +build !noloadavg 17 | 18 | package collector 19 | 20 | import ( 21 | "fmt" 22 | 23 | "github.com/go-kit/log" 24 | "github.com/go-kit/log/level" 25 | "github.com/prometheus/client_golang/prometheus" 26 | ) 27 | 28 | type loadavgCollector struct { 29 | metric []typedDesc 30 | logger log.Logger 31 | } 32 | 33 | func init() { 34 | registerCollector("loadavg", defaultEnabled, NewLoadavgCollector) 35 | } 36 | 37 | // NewLoadavgCollector returns a new Collector exposing load average stats. 38 | func NewLoadavgCollector(logger log.Logger) (Collector, error) { 39 | return &loadavgCollector{ 40 | metric: []typedDesc{ 41 | {prometheus.NewDesc(namespace+"_load1", "1m load average.", nil, nil), prometheus.GaugeValue}, 42 | {prometheus.NewDesc(namespace+"_load5", "5m load average.", nil, nil), prometheus.GaugeValue}, 43 | {prometheus.NewDesc(namespace+"_load15", "15m load average.", nil, nil), prometheus.GaugeValue}, 44 | }, 45 | logger: logger, 46 | }, nil 47 | } 48 | 49 | func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) error { 50 | loads, err := getLoad() 51 | if err != nil { 52 | return fmt.Errorf("couldn't get load: %w", err) 53 | } 54 | for i, load := range loads { 55 | level.Debug(c.logger).Log("msg", "return load", "index", i, "load", load) 56 | ch <- c.metric[i].mustNewConstMetric(load) 57 | } 58 | return err 59 | } 60 | -------------------------------------------------------------------------------- /collector/loadavg_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && !noloadavg 15 | // +build darwin dragonfly freebsd netbsd openbsd 16 | // +build !noloadavg 17 | 18 | package collector 19 | 20 | import ( 21 | "unsafe" 22 | 23 | "golang.org/x/sys/unix" 24 | ) 25 | 26 | func getLoad() ([]float64, error) { 27 | type loadavg struct { 28 | load [3]uint32 29 | scale int 30 | } 31 | b, err := unix.SysctlRaw("vm.loadavg") 32 | if err != nil { 33 | return nil, err 34 | } 35 | load := *(*loadavg)(unsafe.Pointer((&b[0]))) 36 | scale := float64(load.scale) 37 | return []float64{ 38 | float64(load.load[0]) / scale, 39 | float64(load.load[1]) / scale, 40 | float64(load.load[2]) / scale, 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /collector/loadavg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !noloadavg 15 | // +build !noloadavg 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "strconv" 23 | "strings" 24 | ) 25 | 26 | // Read loadavg from /proc. 27 | func getLoad() (loads []float64, err error) { 28 | data, err := os.ReadFile(procFilePath("loadavg")) 29 | if err != nil { 30 | return nil, err 31 | } 32 | loads, err = parseLoad(string(data)) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return loads, nil 37 | } 38 | 39 | // Parse /proc loadavg and return 1m, 5m and 15m. 40 | func parseLoad(data string) (loads []float64, err error) { 41 | loads = make([]float64, 3) 42 | parts := strings.Fields(data) 43 | if len(parts) < 3 { 44 | return nil, fmt.Errorf("unexpected content in %s", procFilePath("loadavg")) 45 | } 46 | for i, load := range parts[0:3] { 47 | loads[i], err = strconv.ParseFloat(load, 64) 48 | if err != nil { 49 | return nil, fmt.Errorf("could not parse load '%s': %w", load, err) 50 | } 51 | } 52 | return loads, nil 53 | } 54 | -------------------------------------------------------------------------------- /collector/loadavg_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import "testing" 17 | 18 | func TestLoad(t *testing.T) { 19 | want := []float64{0.21, 0.37, 0.39} 20 | loads, err := parseLoad("0.21 0.37 0.39 1/719 19737") 21 | if err != nil { 22 | t.Fatal(err) 23 | } 24 | 25 | for i, load := range loads { 26 | if want[i] != load { 27 | t.Fatalf("want load %f, got %f", want[i], load) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /collector/loadavg_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !noloadavg 15 | // +build !noloadavg 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | 23 | "github.com/illumos/go-kstat" 24 | ) 25 | 26 | // #include 27 | import "C" 28 | 29 | func kstatToFloat(ks *kstat.KStat, kstatKey string) float64 { 30 | kstatValue, err := ks.GetNamed(kstatKey) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | kstatLoadavg, err := strconv.ParseFloat( 37 | fmt.Sprintf("%.2f", float64(kstatValue.UintVal)/C.FSCALE), 64) 38 | 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | return kstatLoadavg 44 | } 45 | 46 | func getLoad() ([]float64, error) { 47 | tok, err := kstat.Open() 48 | if err != nil { 49 | panic(err) 50 | } 51 | 52 | defer tok.Close() 53 | 54 | ks, err := tok.Lookup("unix", 0, "system_misc") 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | loadavg1Min := kstatToFloat(ks, "avenrun_1min") 61 | loadavg5Min := kstatToFloat(ks, "avenrun_5min") 62 | loadavg15Min := kstatToFloat(ks, "avenrun_15min") 63 | 64 | return []float64{loadavg1Min, loadavg5Min, loadavg15Min}, nil 65 | } 66 | -------------------------------------------------------------------------------- /collector/meminfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (darwin || linux || openbsd) && !nomeminfo 15 | // +build darwin linux openbsd 16 | // +build !nomeminfo 17 | 18 | package collector 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | 24 | "github.com/go-kit/log" 25 | "github.com/go-kit/log/level" 26 | "github.com/prometheus/client_golang/prometheus" 27 | ) 28 | 29 | const ( 30 | memInfoSubsystem = "memory" 31 | ) 32 | 33 | type meminfoCollector struct { 34 | logger log.Logger 35 | } 36 | 37 | func init() { 38 | registerCollector("meminfo", defaultEnabled, NewMeminfoCollector) 39 | } 40 | 41 | // NewMeminfoCollector returns a new Collector exposing memory stats. 42 | func NewMeminfoCollector(logger log.Logger) (Collector, error) { 43 | return &meminfoCollector{logger}, nil 44 | } 45 | 46 | // Update calls (*meminfoCollector).getMemInfo to get the platform specific 47 | // memory metrics. 48 | func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) error { 49 | var metricType prometheus.ValueType 50 | memInfo, err := c.getMemInfo() 51 | if err != nil { 52 | return fmt.Errorf("couldn't get meminfo: %w", err) 53 | } 54 | level.Debug(c.logger).Log("msg", "Set node_mem", "memInfo", memInfo) 55 | for k, v := range memInfo { 56 | if strings.HasSuffix(k, "_total") { 57 | metricType = prometheus.CounterValue 58 | } else { 59 | metricType = prometheus.GaugeValue 60 | } 61 | ch <- prometheus.MustNewConstMetric( 62 | prometheus.NewDesc( 63 | prometheus.BuildFQName(namespace, memInfoSubsystem, k), 64 | fmt.Sprintf("Memory information field %s.", k), 65 | nil, nil, 66 | ), 67 | metricType, v, 68 | ) 69 | } 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /collector/meminfo_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nomeminfo 15 | // +build !nomeminfo 16 | 17 | package collector 18 | 19 | import ( 20 | "bufio" 21 | "fmt" 22 | "io" 23 | "os" 24 | "regexp" 25 | "strconv" 26 | "strings" 27 | ) 28 | 29 | var ( 30 | reParens = regexp.MustCompile(`\((.*)\)`) 31 | ) 32 | 33 | func (c *meminfoCollector) getMemInfo() (map[string]float64, error) { 34 | file, err := os.Open(procFilePath("meminfo")) 35 | if err != nil { 36 | return nil, err 37 | } 38 | defer file.Close() 39 | 40 | return parseMemInfo(file) 41 | } 42 | 43 | func parseMemInfo(r io.Reader) (map[string]float64, error) { 44 | var ( 45 | memInfo = map[string]float64{} 46 | scanner = bufio.NewScanner(r) 47 | ) 48 | 49 | for scanner.Scan() { 50 | line := scanner.Text() 51 | parts := strings.Fields(line) 52 | // Workaround for empty lines occasionally occur in CentOS 6.2 kernel 3.10.90. 53 | if len(parts) == 0 { 54 | continue 55 | } 56 | fv, err := strconv.ParseFloat(parts[1], 64) 57 | if err != nil { 58 | return nil, fmt.Errorf("invalid value in meminfo: %w", err) 59 | } 60 | key := parts[0][:len(parts[0])-1] // remove trailing : from key 61 | // Active(anon) -> Active_anon 62 | key = reParens.ReplaceAllString(key, "_${1}") 63 | switch len(parts) { 64 | case 2: // no unit 65 | case 3: // has unit, we presume kB 66 | fv *= 1024 67 | key = key + "_bytes" 68 | default: 69 | return nil, fmt.Errorf("invalid line in meminfo: %s", line) 70 | } 71 | memInfo[key] = fv 72 | } 73 | 74 | return memInfo, scanner.Err() 75 | } 76 | -------------------------------------------------------------------------------- /collector/meminfo_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "os" 18 | "testing" 19 | ) 20 | 21 | func TestMemInfo(t *testing.T) { 22 | file, err := os.Open("fixtures/proc/meminfo") 23 | if err != nil { 24 | t.Fatal(err) 25 | } 26 | defer file.Close() 27 | 28 | memInfo, err := parseMemInfo(file) 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | 33 | if want, got := 3831959552.0, memInfo["MemTotal_bytes"]; want != got { 34 | t.Errorf("want memory total %f, got %f", want, got) 35 | } 36 | 37 | if want, got := 3787456512.0, memInfo["DirectMap2M_bytes"]; want != got { 38 | t.Errorf("want memory directMap2M %f, got %f", want, got) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /collector/netdev_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nonetdev && (freebsd || dragonfly) 15 | // +build !nonetdev 16 | // +build freebsd dragonfly 17 | 18 | package collector 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/go-kit/log" 24 | "github.com/go-kit/log/level" 25 | ) 26 | 27 | /* 28 | #cgo CFLAGS: -D_IFI_OQDROPS 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | */ 35 | import "C" 36 | 37 | func getNetDevStats(filter *deviceFilter, logger log.Logger) (netDevStats, error) { 38 | netDev := netDevStats{} 39 | 40 | var ifap, ifa *C.struct_ifaddrs 41 | if C.getifaddrs(&ifap) == -1 { 42 | return nil, errors.New("getifaddrs() failed") 43 | } 44 | defer C.freeifaddrs(ifap) 45 | 46 | for ifa = ifap; ifa != nil; ifa = ifa.ifa_next { 47 | if ifa.ifa_addr.sa_family != C.AF_LINK { 48 | continue 49 | } 50 | 51 | dev := C.GoString(ifa.ifa_name) 52 | if filter.ignored(dev) { 53 | level.Debug(logger).Log("msg", "Ignoring device", "device", dev) 54 | continue 55 | } 56 | 57 | data := (*C.struct_if_data)(ifa.ifa_data) 58 | 59 | netDev[dev] = map[string]uint64{ 60 | "receive_packets": uint64(data.ifi_ipackets), 61 | "transmit_packets": uint64(data.ifi_opackets), 62 | "receive_bytes": uint64(data.ifi_ibytes), 63 | "transmit_bytes": uint64(data.ifi_obytes), 64 | "receive_errors": uint64(data.ifi_ierrors), 65 | "transmit_errors": uint64(data.ifi_oerrors), 66 | "receive_dropped": uint64(data.ifi_iqdrops), 67 | "transmit_dropped": uint64(data.ifi_oqdrops), 68 | "receive_multicast": uint64(data.ifi_imcasts), 69 | "transmit_multicast": uint64(data.ifi_omcasts), 70 | } 71 | } 72 | 73 | return netDev, nil 74 | } 75 | -------------------------------------------------------------------------------- /collector/netdev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build openbsd && !amd64 && !nonetdev 15 | // +build openbsd,!amd64,!nonetdev 16 | 17 | package collector 18 | 19 | import ( 20 | "errors" 21 | 22 | "github.com/go-kit/log" 23 | "github.com/go-kit/log/level" 24 | ) 25 | 26 | /* 27 | #include 28 | #include 29 | #include 30 | #include 31 | */ 32 | import "C" 33 | 34 | func getNetDevStats(filter *deviceFilter, logger log.Logger) (netDevStats, error) { 35 | netDev := netDevStats{} 36 | 37 | var ifap, ifa *C.struct_ifaddrs 38 | if C.getifaddrs(&ifap) == -1 { 39 | return nil, errors.New("getifaddrs() failed") 40 | } 41 | defer C.freeifaddrs(ifap) 42 | 43 | for ifa = ifap; ifa != nil; ifa = ifa.ifa_next { 44 | if ifa.ifa_addr.sa_family != C.AF_LINK { 45 | continue 46 | } 47 | 48 | dev := C.GoString(ifa.ifa_name) 49 | if filter.ignored(dev) { 50 | level.Debug(logger).Log("msg", "Ignoring device", "device", dev) 51 | continue 52 | } 53 | 54 | data := (*C.struct_if_data)(ifa.ifa_data) 55 | 56 | // https://github.com/openbsd/src/blob/master/sys/net/if.h#L101-L126 57 | netDev[dev] = map[string]uint64{ 58 | "receive_packets": uint64(data.ifi_ipackets), 59 | "transmit_packets": uint64(data.ifi_opackets), 60 | "receive_bytes": uint64(data.ifi_ibytes), 61 | "transmit_bytes": uint64(data.ifi_obytes), 62 | "receive_errors": uint64(data.ifi_ierrors), 63 | "transmit_errors": uint64(data.ifi_oerrors), 64 | "receive_dropped": uint64(data.ifi_iqdrops), 65 | "transmit_dropped": uint64(data.ifi_oqdrops), 66 | "receive_multicast": uint64(data.ifi_imcasts), 67 | "transmit_multicast": uint64(data.ifi_omcasts), 68 | "collisions": uint64(data.ifi_collisions), 69 | "noproto": uint64(data.ifi_noproto), 70 | } 71 | } 72 | 73 | return netDev, nil 74 | } 75 | -------------------------------------------------------------------------------- /collector/nvme_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build linux && !nonvme 15 | // +build linux,!nonvme 16 | 17 | package collector 18 | 19 | import ( 20 | "errors" 21 | "fmt" 22 | "os" 23 | 24 | "github.com/go-kit/log" 25 | "github.com/go-kit/log/level" 26 | "github.com/prometheus/client_golang/prometheus" 27 | "github.com/prometheus/procfs/sysfs" 28 | ) 29 | 30 | type nvmeCollector struct { 31 | fs sysfs.FS 32 | logger log.Logger 33 | } 34 | 35 | func init() { 36 | registerCollector("nvme", defaultEnabled, NewNVMeCollector) 37 | } 38 | 39 | // NewNVMeCollector returns a new Collector exposing NVMe stats. 40 | func NewNVMeCollector(logger log.Logger) (Collector, error) { 41 | fs, err := sysfs.NewFS(*sysPath) 42 | if err != nil { 43 | return nil, fmt.Errorf("failed to open sysfs: %w", err) 44 | } 45 | 46 | return &nvmeCollector{ 47 | fs: fs, 48 | logger: logger, 49 | }, nil 50 | } 51 | 52 | func (c *nvmeCollector) Update(ch chan<- prometheus.Metric) error { 53 | devices, err := c.fs.NVMeClass() 54 | if err != nil { 55 | if errors.Is(err, os.ErrNotExist) { 56 | level.Debug(c.logger).Log("msg", "nvme statistics not found, skipping") 57 | return ErrNoData 58 | } 59 | return fmt.Errorf("error obtaining NVMe class info: %w", err) 60 | } 61 | 62 | for _, device := range devices { 63 | infoDesc := prometheus.NewDesc( 64 | prometheus.BuildFQName(namespace, "nvme", "info"), 65 | "Non-numeric data from /sys/class/nvme/, value is always 1.", 66 | []string{"device", "firmware_revision", "model", "serial", "state"}, 67 | nil, 68 | ) 69 | infoValue := 1.0 70 | ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, device.Name, device.FirmwareRevision, device.Model, device.Serial, device.State) 71 | } 72 | 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /collector/paths.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "path/filepath" 18 | "strings" 19 | 20 | "github.com/prometheus/procfs" 21 | kingpin "gopkg.in/alecthomas/kingpin.v2" 22 | ) 23 | 24 | var ( 25 | // The path of the proc filesystem. 26 | procPath = kingpin.Flag("path.procfs", "procfs mountpoint.").Default(procfs.DefaultMountPoint).String() 27 | sysPath = kingpin.Flag("path.sysfs", "sysfs mountpoint.").Default("/sys").String() 28 | rootfsPath = kingpin.Flag("path.rootfs", "rootfs mountpoint.").Default("/").String() 29 | udevDataPath = kingpin.Flag("path.udev.data", "udev data path.").Default("/run/udev/data").String() 30 | ) 31 | 32 | func procFilePath(name string) string { 33 | return filepath.Join(*procPath, name) 34 | } 35 | 36 | func sysFilePath(name string) string { 37 | return filepath.Join(*sysPath, name) 38 | } 39 | 40 | func rootfsFilePath(name string) string { 41 | return filepath.Join(*rootfsPath, name) 42 | } 43 | 44 | func udevDataFilePath(name string) string { 45 | return filepath.Join(*udevDataPath, name) 46 | } 47 | 48 | func rootfsStripPrefix(path string) string { 49 | if *rootfsPath == "/" { 50 | return path 51 | } 52 | stripped := strings.TrimPrefix(path, *rootfsPath) 53 | if stripped == "" { 54 | return "/" 55 | } 56 | return stripped 57 | } 58 | -------------------------------------------------------------------------------- /collector/powersupplyclass.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nopowersupplyclass && (linux || darwin) 15 | // +build !nopowersupplyclass 16 | // +build linux darwin 17 | 18 | package collector 19 | 20 | import ( 21 | "regexp" 22 | 23 | "github.com/go-kit/log" 24 | "github.com/prometheus/client_golang/prometheus" 25 | "gopkg.in/alecthomas/kingpin.v2" 26 | ) 27 | 28 | var ( 29 | powerSupplyClassIgnoredPowerSupplies = kingpin.Flag("collector.powersupply.ignored-supplies", "Regexp of power supplies to ignore for powersupplyclass collector.").Default("^$").String() 30 | ) 31 | 32 | type powerSupplyClassCollector struct { 33 | subsystem string 34 | ignoredPattern *regexp.Regexp 35 | metricDescs map[string]*prometheus.Desc 36 | logger log.Logger 37 | } 38 | 39 | func init() { 40 | registerCollector("powersupplyclass", defaultEnabled, NewPowerSupplyClassCollector) 41 | } 42 | 43 | func NewPowerSupplyClassCollector(logger log.Logger) (Collector, error) { 44 | pattern := regexp.MustCompile(*powerSupplyClassIgnoredPowerSupplies) 45 | return &powerSupplyClassCollector{ 46 | subsystem: "power_supply", 47 | ignoredPattern: pattern, 48 | metricDescs: map[string]*prometheus.Desc{}, 49 | logger: logger, 50 | }, nil 51 | } 52 | -------------------------------------------------------------------------------- /collector/processes_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !noprocesses 15 | // +build !noprocesses 16 | 17 | package collector 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/go-kit/log" 23 | "github.com/prometheus/procfs" 24 | kingpin "gopkg.in/alecthomas/kingpin.v2" 25 | ) 26 | 27 | func TestReadProcessStatus(t *testing.T) { 28 | if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "fixtures/proc"}); err != nil { 29 | t.Fatal(err) 30 | } 31 | want := 1 32 | fs, err := procfs.NewFS(*procPath) 33 | if err != nil { 34 | t.Errorf("failed to open procfs: %v", err) 35 | } 36 | c := processCollector{fs: fs, logger: log.NewNopLogger()} 37 | pids, states, threads, _, err := c.getAllocatedThreads() 38 | if err != nil { 39 | t.Fatalf("Cannot retrieve data from procfs getAllocatedThreads function: %v ", err) 40 | } 41 | if threads < want { 42 | t.Fatalf("Current threads: %d Shouldn't be less than wanted %d", threads, want) 43 | } 44 | if states == nil { 45 | 46 | t.Fatalf("Process states cannot be nil %v:", states) 47 | } 48 | maxPid, err := readUintFromFile(procFilePath("sys/kernel/pid_max")) 49 | if err != nil { 50 | t.Fatalf("Unable to retrieve limit number of maximum pids alloved %v\n", err) 51 | } 52 | if uint64(pids) > maxPid || pids == 0 { 53 | t.Fatalf("Total running pids cannot be greater than %d or equals to 0", maxPid) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /collector/selinux_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build linux && !noselinux 15 | // +build linux,!noselinux 16 | 17 | package collector 18 | 19 | import ( 20 | "github.com/go-kit/log" 21 | "github.com/opencontainers/selinux/go-selinux" 22 | "github.com/prometheus/client_golang/prometheus" 23 | ) 24 | 25 | type selinuxCollector struct { 26 | configMode *prometheus.Desc 27 | currentMode *prometheus.Desc 28 | enabled *prometheus.Desc 29 | logger log.Logger 30 | } 31 | 32 | func init() { 33 | registerCollector("selinux", defaultEnabled, NewSelinuxCollector) 34 | } 35 | 36 | // NewSelinuxCollector returns a new Collector exposing SELinux statistics. 37 | func NewSelinuxCollector(logger log.Logger) (Collector, error) { 38 | const subsystem = "selinux" 39 | 40 | return &selinuxCollector{ 41 | configMode: prometheus.NewDesc( 42 | prometheus.BuildFQName(namespace, subsystem, "config_mode"), 43 | "Configured SELinux enforcement mode", 44 | nil, nil, 45 | ), 46 | currentMode: prometheus.NewDesc( 47 | prometheus.BuildFQName(namespace, subsystem, "current_mode"), 48 | "Current SELinux enforcement mode", 49 | nil, nil, 50 | ), 51 | enabled: prometheus.NewDesc( 52 | prometheus.BuildFQName(namespace, subsystem, "enabled"), 53 | "SELinux is enabled, 1 is true, 0 is false", 54 | nil, nil, 55 | ), 56 | logger: logger, 57 | }, nil 58 | } 59 | 60 | func (c *selinuxCollector) Update(ch chan<- prometheus.Metric) error { 61 | if !selinux.GetEnabled() { 62 | ch <- prometheus.MustNewConstMetric( 63 | c.enabled, prometheus.GaugeValue, 0) 64 | 65 | return nil 66 | } 67 | 68 | ch <- prometheus.MustNewConstMetric( 69 | c.enabled, prometheus.GaugeValue, 1) 70 | 71 | ch <- prometheus.MustNewConstMetric( 72 | c.configMode, prometheus.GaugeValue, float64(selinux.DefaultEnforceMode())) 73 | 74 | ch <- prometheus.MustNewConstMetric( 75 | c.currentMode, prometheus.GaugeValue, float64(selinux.EnforceMode())) 76 | 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /collector/sysctl_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "golang.org/x/sys/unix" 18 | "syscall" 19 | "unsafe" 20 | ) 21 | 22 | func int8ToString(a []int8) string { 23 | buf := make([]byte, len(a)) 24 | for i, v := range a { 25 | if byte(v) == 0 { 26 | buf = buf[:i] 27 | break 28 | } 29 | buf[i] = byte(v) 30 | } 31 | return string(buf) 32 | } 33 | 34 | // unix._C_int 35 | type _C_int int32 36 | 37 | var _zero uintptr 38 | 39 | func errnoErr(e syscall.Errno) error { 40 | switch e { 41 | case 0: 42 | return nil 43 | case unix.EAGAIN: 44 | return syscall.EAGAIN 45 | case unix.EINVAL: 46 | return syscall.EINVAL 47 | case unix.ENOENT: 48 | return syscall.ENOENT 49 | } 50 | return e 51 | } 52 | 53 | func _sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { 54 | var _p0 unsafe.Pointer 55 | if len(mib) > 0 { 56 | _p0 = unsafe.Pointer(&mib[0]) 57 | } else { 58 | _p0 = unsafe.Pointer(&_zero) 59 | } 60 | for { 61 | _, _, e1 := unix.Syscall6(unix.SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) 62 | if e1 != 0 { 63 | err = errnoErr(e1) 64 | } 65 | if err != unix.EINTR { 66 | return 67 | } 68 | } 69 | return 70 | } 71 | 72 | func sysctl(mib []_C_int) ([]byte, error) { 73 | n := uintptr(0) 74 | if err := _sysctl(mib, nil, &n, nil, 0); err != nil { 75 | return nil, err 76 | } 77 | if n == 0 { 78 | return nil, nil 79 | } 80 | 81 | buf := make([]byte, n) 82 | if err := _sysctl(mib, &buf[0], &n, nil, 0); err != nil { 83 | return nil, err 84 | } 85 | return buf[:n], nil 86 | } 87 | -------------------------------------------------------------------------------- /collector/tcpstat_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package collector 15 | 16 | import ( 17 | "bytes" 18 | "encoding/binary" 19 | "syscall" 20 | "testing" 21 | 22 | "github.com/mdlayher/netlink" 23 | ) 24 | 25 | func Test_parseTCPStats(t *testing.T) { 26 | encode := func(m InetDiagMsg) []byte { 27 | var buf bytes.Buffer 28 | err := binary.Write(&buf, binary.LittleEndian, m) 29 | if err != nil { 30 | panic(err) 31 | } 32 | return buf.Bytes() 33 | } 34 | 35 | msg := []netlink.Message{ 36 | { 37 | Data: encode(InetDiagMsg{ 38 | Family: syscall.AF_INET, 39 | State: uint8(tcpEstablished), 40 | Timer: 0, 41 | Retrans: 0, 42 | ID: InetDiagSockID{}, 43 | Expires: 0, 44 | RQueue: 11, 45 | WQueue: 21, 46 | UID: 0, 47 | Inode: 0, 48 | }), 49 | }, 50 | { 51 | Data: encode(InetDiagMsg{ 52 | Family: syscall.AF_INET, 53 | State: uint8(tcpListen), 54 | Timer: 0, 55 | Retrans: 0, 56 | ID: InetDiagSockID{}, 57 | Expires: 0, 58 | RQueue: 11, 59 | WQueue: 21, 60 | UID: 0, 61 | Inode: 0, 62 | }), 63 | }, 64 | } 65 | 66 | tcpStats, err := parseTCPStats(msg) 67 | if err != nil { 68 | t.Fatal(err) 69 | } 70 | 71 | if want, got := 1, int(tcpStats[tcpEstablished]); want != got { 72 | t.Errorf("want tcpstat number of established state %d, got %d", want, got) 73 | } 74 | 75 | if want, got := 1, int(tcpStats[tcpListen]); want != got { 76 | t.Errorf("want tcpstat number of listen state %d, got %d", want, got) 77 | } 78 | 79 | if want, got := 42, int(tcpStats[tcpTxQueuedBytes]); want != got { 80 | t.Errorf("want tcpstat number of bytes in tx queue %d, got %d", want, got) 81 | } 82 | if want, got := 22, int(tcpStats[tcpRxQueuedBytes]); want != got { 83 | t.Errorf("want tcpstat number of bytes in rx queue %d, got %d", want, got) 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /collector/time_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build linux && !notime 15 | // +build linux,!notime 16 | 17 | package collector 18 | 19 | import ( 20 | "fmt" 21 | "strconv" 22 | 23 | "github.com/go-kit/log/level" 24 | "github.com/prometheus/client_golang/prometheus" 25 | "github.com/prometheus/procfs/sysfs" 26 | ) 27 | 28 | func (c *timeCollector) update(ch chan<- prometheus.Metric) error { 29 | fs, err := sysfs.NewFS(*sysPath) 30 | if err != nil { 31 | return fmt.Errorf("failed to open procfs: %w", err) 32 | } 33 | 34 | clocksources, err := fs.ClockSources() 35 | if err != nil { 36 | return fmt.Errorf("couldn't get clocksources: %w", err) 37 | } 38 | level.Debug(c.logger).Log("msg", "in Update", "clocksources", fmt.Sprintf("%v", clocksources)) 39 | 40 | for i, clocksource := range clocksources { 41 | is := strconv.Itoa(i) 42 | for _, cs := range clocksource.Available { 43 | ch <- c.clocksourcesAvailable.mustNewConstMetric(1.0, is, cs) 44 | } 45 | ch <- c.clocksourceCurrent.mustNewConstMetric(1.0, is, clocksource.Current) 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /collector/time_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !linux && !notime 15 | // +build !linux,!notime 16 | 17 | package collector 18 | 19 | import ( 20 | "github.com/prometheus/client_golang/prometheus" 21 | ) 22 | 23 | func (c *timeCollector) update(ch chan<- prometheus.Metric) error { 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /collector/uname.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (darwin || freebsd || openbsd || linux) && !nouname 15 | // +build darwin freebsd openbsd linux 16 | // +build !nouname 17 | 18 | package collector 19 | 20 | import ( 21 | "github.com/go-kit/log" 22 | "github.com/prometheus/client_golang/prometheus" 23 | ) 24 | 25 | var unameDesc = prometheus.NewDesc( 26 | prometheus.BuildFQName(namespace, "uname", "info"), 27 | "Labeled system information as provided by the uname system call.", 28 | []string{ 29 | "sysname", 30 | "release", 31 | "version", 32 | "machine", 33 | "nodename", 34 | "domainname", 35 | }, 36 | nil, 37 | ) 38 | 39 | type unameCollector struct { 40 | logger log.Logger 41 | } 42 | type uname struct { 43 | SysName string 44 | Release string 45 | Version string 46 | Machine string 47 | NodeName string 48 | DomainName string 49 | } 50 | 51 | func init() { 52 | registerCollector("uname", defaultEnabled, newUnameCollector) 53 | } 54 | 55 | // NewUnameCollector returns new unameCollector. 56 | func newUnameCollector(logger log.Logger) (Collector, error) { 57 | return &unameCollector{logger}, nil 58 | } 59 | 60 | func (c *unameCollector) Update(ch chan<- prometheus.Metric) error { 61 | uname, err := getUname() 62 | if err != nil { 63 | return err 64 | } 65 | 66 | ch <- prometheus.MustNewConstMetric(unameDesc, prometheus.GaugeValue, 1, 67 | uname.SysName, 68 | uname.Release, 69 | uname.Version, 70 | uname.Machine, 71 | uname.NodeName, 72 | uname.DomainName, 73 | ) 74 | 75 | return nil 76 | } 77 | -------------------------------------------------------------------------------- /collector/uname_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build (darwin || freebsd || openbsd) && !nouname 15 | // +build darwin freebsd openbsd 16 | // +build !nouname 17 | 18 | package collector 19 | 20 | import ( 21 | "strings" 22 | 23 | "golang.org/x/sys/unix" 24 | ) 25 | 26 | func getUname() (uname, error) { 27 | var utsname unix.Utsname 28 | if err := unix.Uname(&utsname); err != nil { 29 | return uname{}, err 30 | } 31 | 32 | nodeName, domainName := parseHostNameAndDomainName(utsname) 33 | 34 | output := uname{ 35 | SysName: unix.ByteSliceToString(utsname.Sysname[:]), 36 | Release: unix.ByteSliceToString(utsname.Release[:]), 37 | Version: unix.ByteSliceToString(utsname.Version[:]), 38 | Machine: unix.ByteSliceToString(utsname.Machine[:]), 39 | NodeName: nodeName, 40 | DomainName: domainName, 41 | } 42 | 43 | return output, nil 44 | } 45 | 46 | // parseHostNameAndDomainName for FreeBSD,OpenBSD,Darwin. 47 | // Attempts to emulate what happens in the Linux uname calls since these OS doesn't have a Domainname. 48 | func parseHostNameAndDomainName(utsname unix.Utsname) (hostname string, domainname string) { 49 | nodename := unix.ByteSliceToString(utsname.Nodename[:]) 50 | split := strings.SplitN(nodename, ".", 2) 51 | 52 | // We'll always have at least a single element in the array. We assume this 53 | // is the hostname. 54 | hostname = split[0] 55 | 56 | // If we have more than one element, we assume this is the domainname. 57 | // Otherwise leave it to "(none)" like Linux. 58 | domainname = "(none)" 59 | if len(split) > 1 { 60 | domainname = split[1] 61 | } 62 | return hostname, domainname 63 | } 64 | -------------------------------------------------------------------------------- /collector/uname_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !nouname 15 | // +build !nouname 16 | 17 | package collector 18 | 19 | import "golang.org/x/sys/unix" 20 | 21 | func getUname() (uname, error) { 22 | var utsname unix.Utsname 23 | if err := unix.Uname(&utsname); err != nil { 24 | return uname{}, err 25 | } 26 | 27 | output := uname{ 28 | SysName: unix.ByteSliceToString(utsname.Sysname[:]), 29 | Release: unix.ByteSliceToString(utsname.Release[:]), 30 | Version: unix.ByteSliceToString(utsname.Version[:]), 31 | Machine: unix.ByteSliceToString(utsname.Machine[:]), 32 | NodeName: unix.ByteSliceToString(utsname.Nodename[:]), 33 | DomainName: unix.ByteSliceToString(utsname.Domainname[:]), 34 | } 35 | 36 | return output, nil 37 | } 38 | -------------------------------------------------------------------------------- /collector/vmstat_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !novmstat 15 | // +build !novmstat 16 | 17 | package collector 18 | 19 | import ( 20 | "bufio" 21 | "fmt" 22 | "os" 23 | "regexp" 24 | "strconv" 25 | "strings" 26 | 27 | "github.com/go-kit/log" 28 | "github.com/prometheus/client_golang/prometheus" 29 | "gopkg.in/alecthomas/kingpin.v2" 30 | ) 31 | 32 | const ( 33 | vmStatSubsystem = "vmstat" 34 | ) 35 | 36 | var ( 37 | vmStatFields = kingpin.Flag("collector.vmstat.fields", "Regexp of fields to return for vmstat collector.").Default("^(oom_kill|pgpg|pswp|pg.*fault).*").String() 38 | ) 39 | 40 | type vmStatCollector struct { 41 | fieldPattern *regexp.Regexp 42 | logger log.Logger 43 | } 44 | 45 | func init() { 46 | registerCollector("vmstat", defaultEnabled, NewvmStatCollector) 47 | } 48 | 49 | // NewvmStatCollector returns a new Collector exposing vmstat stats. 50 | func NewvmStatCollector(logger log.Logger) (Collector, error) { 51 | pattern := regexp.MustCompile(*vmStatFields) 52 | return &vmStatCollector{ 53 | fieldPattern: pattern, 54 | logger: logger, 55 | }, nil 56 | } 57 | 58 | func (c *vmStatCollector) Update(ch chan<- prometheus.Metric) error { 59 | file, err := os.Open(procFilePath("vmstat")) 60 | if err != nil { 61 | return err 62 | } 63 | defer file.Close() 64 | 65 | scanner := bufio.NewScanner(file) 66 | for scanner.Scan() { 67 | parts := strings.Fields(scanner.Text()) 68 | value, err := strconv.ParseFloat(parts[1], 64) 69 | if err != nil { 70 | return err 71 | } 72 | if !c.fieldPattern.MatchString(parts[0]) { 73 | continue 74 | } 75 | 76 | ch <- prometheus.MustNewConstMetric( 77 | prometheus.NewDesc( 78 | prometheus.BuildFQName(namespace, vmStatSubsystem, parts[0]), 79 | fmt.Sprintf("/proc/vmstat information field %s.", parts[0]), 80 | nil, nil), 81 | prometheus.UntypedValue, 82 | value, 83 | ) 84 | } 85 | return scanner.Err() 86 | } 87 | -------------------------------------------------------------------------------- /docs/V0_16_UPGRADE_GUIDE.md: -------------------------------------------------------------------------------- 1 | # Version 0.16.0 Upgrade Guide 2 | 3 | The `node_exporter` 0.16.0 and newer renamed many metrics in order to conform with Prometheus [naming best practices]. 4 | 5 | In order to allow easy upgrades, there are several options. 6 | 7 | ## Update dashboards 8 | 9 | Grafana users can add multiple queries in order to display both the old and new data simultaneously. 10 | 11 | ## Use recording rules 12 | 13 | We have provided a [sample recording rule set that translates old metrics to new ones] and the [one that translates new metrics format to old one] to create duplicate metrics (it translates "old" metrics format to new one). This has a minor disadvantage that it creates a lot of extra data, and re-aligns the timestamps of the data. 14 | 15 | ## Run both old and new versions simultaneously. 16 | 17 | It's possible to run both the old and new exporter on different ports, and include an additional scrape job in Prometheus. It's recommended to enable only the collectors that have name changes that you care about. 18 | 19 | [naming best practices]: https://prometheus.io/docs/practices/naming/ 20 | [sample recording rule set that translates old metrics to new ones]: example-16-compatibility-rules.yml 21 | [one that translates new metrics format to old one]: example-16-compatibility-rules-new-to-old.yml 22 | -------------------------------------------------------------------------------- /docs/example-17-compatibility-rules-new-to-old.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: node_exporter-17-supervisord 3 | rules: 4 | - record: node_supervisord_start_time_seconds 5 | expr: node_supervisord_uptime + time() 6 | -------------------------------------------------------------------------------- /docs/example-17-compatibility-rules.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: node_exporter-17-supervisord 3 | rules: 4 | - record: node_supervisord_uptime 5 | expr: time() - node_supervisord_start_time_seconds 6 | -------------------------------------------------------------------------------- /docs/node-mixin/.gitignore: -------------------------------------------------------------------------------- 1 | jsonnetfile.lock.json 2 | vendor 3 | *.yaml 4 | dashboards_out 5 | -------------------------------------------------------------------------------- /docs/node-mixin/Makefile: -------------------------------------------------------------------------------- 1 | JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s 2 | 3 | all: fmt node_alerts.yaml node_rules.yaml dashboards_out lint 4 | 5 | fmt: 6 | find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ 7 | xargs -n 1 -- $(JSONNET_FMT) -i 8 | 9 | node_alerts.yaml: mixin.libsonnet config.libsonnet $(wildcard alerts/*) 10 | jsonnet -S alerts.jsonnet > $@ 11 | 12 | node_rules.yaml: mixin.libsonnet config.libsonnet $(wildcard rules/*) 13 | jsonnet -S rules.jsonnet > $@ 14 | 15 | dashboards_out: mixin.libsonnet config.libsonnet $(wildcard dashboards/*) 16 | @mkdir -p dashboards_out 17 | jsonnet -J vendor -m dashboards_out dashboards.jsonnet 18 | 19 | lint: node_alerts.yaml node_rules.yaml 20 | find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ 21 | while read f; do \ 22 | $(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ 23 | done 24 | 25 | promtool check rules node_alerts.yaml node_rules.yaml 26 | 27 | .PHONY: jb_install 28 | jb_install: 29 | jb install 30 | 31 | clean: 32 | rm -rf dashboards_out node_alerts.yaml node_rules.yaml 33 | -------------------------------------------------------------------------------- /docs/node-mixin/README.md: -------------------------------------------------------------------------------- 1 | # Node Mixin 2 | 3 | _This is a work in progress. We aim for it to become a good role model for alerts 4 | and dashboards eventually, but it is not quite there yet._ 5 | 6 | The Node Mixin is a set of configurable, reusable, and extensible alerts and 7 | dashboards based on the metrics exported by the Node Exporter. The mixin creates 8 | recording and alerting rules for Prometheus and suitable dashboard descriptions 9 | for Grafana. 10 | 11 | To use them, you need to have `jsonnet` (v0.16+) and `jb` installed. If you 12 | have a working Go development environment, it's easiest to run the following: 13 | 14 | ```bash 15 | go install github.com/google/go-jsonnet/cmd/jsonnet@latest 16 | go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest 17 | go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest 18 | ``` 19 | 20 | Next, install the dependencies by running the following command in this 21 | directory: 22 | 23 | ```bash 24 | jb install 25 | ``` 26 | 27 | You can then build the Prometheus rules files `node_alerts.yaml` and 28 | `node_rules.yaml`: 29 | 30 | ```bash 31 | make node_alerts.yaml node_rules.yaml 32 | ``` 33 | 34 | You can also build a directory `dashboard_out` with the JSON dashboard files 35 | for Grafana: 36 | 37 | ```bash 38 | make dashboards_out 39 | ``` 40 | 41 | Note that some of the generated dashboards require recording rules specified in 42 | the previously generated `node_rules.yaml`. 43 | 44 | For more advanced uses of mixins, see 45 | . 46 | -------------------------------------------------------------------------------- /docs/node-mixin/alerts.jsonnet: -------------------------------------------------------------------------------- 1 | std.manifestYamlDoc((import 'mixin.libsonnet').prometheusAlerts) 2 | -------------------------------------------------------------------------------- /docs/node-mixin/dashboards.jsonnet: -------------------------------------------------------------------------------- 1 | local dashboards = (import 'mixin.libsonnet').grafanaDashboards; 2 | 3 | { 4 | [name]: dashboards[name] 5 | for name in std.objectFields(dashboards) 6 | } 7 | -------------------------------------------------------------------------------- /docs/node-mixin/dashboards/dashboards.libsonnet: -------------------------------------------------------------------------------- 1 | (import 'node.libsonnet') + 2 | (import 'use.libsonnet') 3 | -------------------------------------------------------------------------------- /docs/node-mixin/dashboards/node.libsonnet: -------------------------------------------------------------------------------- 1 | { 2 | local nodemixin = import '../lib/prom-mixin.libsonnet', 3 | grafanaDashboards+:: { 4 | 'nodes.json': nodemixin.new(config=$._config, platform='Linux').dashboard, 5 | 'nodes-darwin.json': nodemixin.new(config=$._config, platform='Darwin').dashboard, 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /docs/node-mixin/jsonnetfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": [ 4 | { 5 | "source": { 6 | "git": { 7 | "remote": "https://github.com/grafana/grafonnet-lib.git", 8 | "subdir": "grafonnet" 9 | } 10 | }, 11 | "version": "master" 12 | }, 13 | { 14 | "source": { 15 | "git": { 16 | "remote": "https://github.com/grafana/grafonnet-lib.git", 17 | "subdir": "grafonnet-7.0" 18 | } 19 | }, 20 | "version": "master" 21 | } 22 | ], 23 | "legacyImports": false 24 | } 25 | -------------------------------------------------------------------------------- /docs/node-mixin/mixin.libsonnet: -------------------------------------------------------------------------------- 1 | (import 'config.libsonnet') + 2 | (import 'alerts/alerts.libsonnet') + 3 | (import 'dashboards/dashboards.libsonnet') + 4 | (import 'rules/rules.libsonnet') 5 | -------------------------------------------------------------------------------- /docs/node-mixin/rules.jsonnet: -------------------------------------------------------------------------------- 1 | std.manifestYamlDoc((import 'mixin.libsonnet').prometheusRules) 2 | -------------------------------------------------------------------------------- /example-rules.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: example-node-exporter-rules 3 | rules: 4 | # The count of CPUs per node, useful for getting CPU time as a percent of total. 5 | - record: instance:node_cpus:count 6 | expr: count(node_cpu_seconds_total{mode="idle"}) without (cpu,mode) 7 | 8 | # CPU in use by CPU. 9 | - record: instance_cpu:node_cpu_seconds_not_idle:rate5m 10 | expr: sum(rate(node_cpu_seconds_total{mode!="idle"}[5m])) without (mode) 11 | 12 | # CPU in use by mode. 13 | - record: instance_mode:node_cpu_seconds:rate5m 14 | expr: sum(rate(node_cpu_seconds_total[5m])) without (cpu) 15 | 16 | # CPU in use ratio. 17 | - record: instance:node_cpu_utilization:ratio 18 | expr: sum(instance_mode:node_cpu_seconds:rate5m{mode!="idle"}) without (mode) / instance:node_cpus:count 19 | -------------------------------------------------------------------------------- /example.prom: -------------------------------------------------------------------------------- 1 | ## # Below is an example of a full-fledged Prometheus metric exposition, 2 | ## # including comments, HELP and TYPE expressions, a histogram, a summary, 3 | ## # character escaping examples, and more. It is taken from: 4 | ## # https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-example 5 | ## # More details about textfile collector you can find at: 6 | ## # https://github.com/prometheus/node_exporter#textfile-collector 7 | ## # 8 | ## # HELP http_requests_total The total number of HTTP requests. 9 | ## # TYPE http_requests_total counter 10 | ## http_requests_total{method="post",code="200"} 1027 1395066363000 11 | ## http_requests_total{method="post",code="400"} 3 1395066363000 12 | ## 13 | ## # Escaping in label values: 14 | ## msdos_file_access_time_seconds{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.458255915e9 15 | ## 16 | ## # Minimalistic line: 17 | ## metric_without_timestamp_and_labels 12.47 18 | ## 19 | ## # A weird metric from before the epoch: 20 | ## something_weird{problem="division by zero"} +Inf -3982045 21 | ## 22 | ## # A histogram, which has a pretty complex representation in the text format: 23 | ## # HELP http_request_duration_seconds A histogram of the request duration. 24 | ## # TYPE http_request_duration_seconds histogram 25 | ## http_request_duration_seconds_bucket{le="0.05"} 24054 26 | ## http_request_duration_seconds_bucket{le="0.1"} 33444 27 | ## http_request_duration_seconds_bucket{le="0.2"} 100392 28 | ## http_request_duration_seconds_bucket{le="0.5"} 129389 29 | ## http_request_duration_seconds_bucket{le="1"} 133988 30 | ## http_request_duration_seconds_bucket{le="+Inf"} 144320 31 | ## http_request_duration_seconds_sum 53423 32 | ## http_request_duration_seconds_count 144320 33 | ## 34 | ## # Finally a summary, which has a complex representation, too: 35 | ## # HELP rpc_duration_seconds A summary of the RPC duration in seconds. 36 | ## # TYPE rpc_duration_seconds summary 37 | ## rpc_duration_seconds{quantile="0.01"} 3102 38 | ## rpc_duration_seconds{quantile="0.05"} 3272 39 | ## rpc_duration_seconds{quantile="0.5"} 4773 40 | ## rpc_duration_seconds{quantile="0.9"} 9001 41 | ## rpc_duration_seconds{quantile="0.99"} 76656 42 | ## rpc_duration_seconds_sum 1.7560473e+07 43 | ## rpc_duration_seconds_count 2693 44 | -------------------------------------------------------------------------------- /examples/init.d/node_exporter: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RETVAL=0 4 | PROG="node_exporter" 5 | EXEC="/etc/node_exporter/node_exporter" 6 | LOCKFILE="/var/lock/subsys/$PROG" 7 | OPTIONS="--web.listen-address=:9100" 8 | 9 | # Source function library. 10 | if [ -f /etc/rc.d/init.d/functions ]; then 11 | . /etc/rc.d/init.d/functions 12 | else 13 | echo "/etc/rc.d/init.d/functions does not exist" 14 | exit 0 15 | fi 16 | 17 | start() { 18 | if [ -f $LOCKFILE ] 19 | then 20 | echo "$PROG is already running!" 21 | else 22 | echo -n "Starting $PROG: " 23 | nohup $EXEC $OPTIONS >/dev/null 2>&1 & 24 | RETVAL=$? 25 | [ $RETVAL -eq 0 ] && touch $LOCKFILE && success || failure 26 | echo 27 | return $RETVAL 28 | fi 29 | } 30 | 31 | stop() { 32 | echo -n "Stopping $PROG: " 33 | killproc $EXEC 34 | RETVAL=$? 35 | [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure 36 | echo 37 | } 38 | 39 | restart () 40 | { 41 | stop 42 | sleep 1 43 | start 44 | } 45 | 46 | case "$1" in 47 | start) 48 | start 49 | ;; 50 | stop) 51 | stop 52 | ;; 53 | status) 54 | status $PROG 55 | ;; 56 | restart) 57 | restart 58 | ;; 59 | *) 60 | echo "Usage: $0 {start|stop|restart|status}" 61 | exit 1 62 | esac 63 | exit $RETVAL 64 | -------------------------------------------------------------------------------- /examples/launchctl/README.md: -------------------------------------------------------------------------------- 1 | # MacOS LaunchDaemon 2 | 3 | If you're installing through a package manager, you probably don't need to deal 4 | with this file. 5 | 6 | The `plist` file should be put in `/Library/LaunchDaemons/` (user defined daemons), and the binary installed at 7 | `/usr/local/bin/node_exporter`. 8 | 9 | Ex. install globally by 10 | 11 | sudo cp -n node_exporter /usr/local/bin/ 12 | sudo cp -n examples/launchctl/io.prometheus.node_exporter.plist /Library/LaunchDaemons/ 13 | sudo launchctl bootstrap system/ /Library/LaunchDaemons/io.prometheus.node_exporter.plist 14 | 15 | # Optionally configure by dropping CLI arguments in a file 16 | echo -- '--web.listen-address=:9101' | sudo tee /usr/local/etc/node_exporter.args 17 | 18 | # Check it's running 19 | sudo launchctl list | grep node_exporter 20 | 21 | # See full process state 22 | sudo launchctl print system/io.prometheus.node_exporter 23 | 24 | # View logs 25 | sudo tail /tmp/node_exporter.log 26 | -------------------------------------------------------------------------------- /examples/launchctl/io.prometheus.node_exporter.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | io.prometheus.node_exporter 7 | ProgramArguments 8 | 9 | sh 10 | -c 11 | /usr/local/bin/node_exporter $(< /usr/local/etc/node_exporter.args) 12 | 13 | UserName 14 | nobody 15 | GroupName 16 | nobody 17 | RunAtLoad 18 | 19 | KeepAlive 20 | 21 | WorkingDirectory 22 | /usr/local 23 | StandardErrorPath 24 | /tmp/node_exporter.log 25 | StandardOutPath 26 | /tmp/node_exporter.log 27 | HardResourceLimits 28 | 29 | NumberOfFiles 30 | 4096 31 | 32 | SoftResourceLimits 33 | 34 | NumberOfFiles 35 | 4096 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/openbsd-rc.d/node_exporter: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | # Shawn Craver, 2019-04-02 3 | 4 | 5 | daemon="/usr/local/bin/node_exporter" 6 | 7 | . /etc/rc.d/rc.subr 8 | 9 | rc_bg=YES 10 | 11 | rc_cmd $1 12 | 13 | -------------------------------------------------------------------------------- /examples/openwrt-init.d/node_exporter: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=99 4 | 5 | USE_PROCD=1 6 | PROG="/usr/bin/node_exporter" 7 | OPTIONS="--web.listen-address=:9100" 8 | 9 | start_service() { 10 | procd_open_instance 11 | procd_set_param command "$PROG" "${OPTIONS}" 12 | procd_close_instance 13 | } 14 | -------------------------------------------------------------------------------- /examples/systemd/README.md: -------------------------------------------------------------------------------- 1 | # Systemd Unit 2 | 3 | If you are using distribution packages or the copr repository, you don't need to deal with these files! 4 | 5 | The unit file in this directory is to be put into `/etc/systemd/system`. 6 | It needs a user named `node_exporter`, whose shell should be `/sbin/nologin` and should not have any special privileges. 7 | It needs a sysconfig file in `/etc/sysconfig/node_exporter`. 8 | It needs a directory named `/var/lib/node_exporter/textfile_collector`, whose owner should be `node_exporter`:`node_exporter`. 9 | A sample file can be found in `sysconfig.node_exporter`. 10 | -------------------------------------------------------------------------------- /examples/systemd/node_exporter.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Node Exporter 3 | 4 | [Service] 5 | User=node_exporter 6 | EnvironmentFile=/etc/sysconfig/node_exporter 7 | ExecStart=/usr/sbin/node_exporter $OPTIONS 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /examples/systemd/sysconfig.node_exporter: -------------------------------------------------------------------------------- 1 | OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector" 2 | -------------------------------------------------------------------------------- /percona/perconacollector/perconacollector.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package perconacollector includes additional/replacement collectors which are missing in the main package 15 | package perconacollector 16 | -------------------------------------------------------------------------------- /percona/perconacollector/standard.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Prometheus Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package perconacollector 15 | 16 | import ( 17 | "fmt" 18 | 19 | "github.com/go-kit/log" 20 | "github.com/prometheus/client_golang/prometheus" 21 | "github.com/prometheus/client_golang/prometheus/collectors" 22 | cl "github.com/prometheus/node_exporter/collector" 23 | ) 24 | 25 | func init() { 26 | fmt.Println("init standard") 27 | cl.RegisterCollectorPublic("standard.go", false, NewStandardGoCollector) 28 | cl.RegisterCollectorPublic("standard.process", false, NewStandardProcessCollector) 29 | } 30 | 31 | type standardGoCollector struct { 32 | origin prometheus.Collector 33 | logger log.Logger 34 | } 35 | 36 | // NewStandardGoCollector creates standard go collector. 37 | func NewStandardGoCollector(_ log.Logger) (cl.Collector, error) { 38 | c := collectors.NewGoCollector() 39 | return &standardGoCollector{origin: c}, nil 40 | } 41 | 42 | func (c *standardGoCollector) Update(ch chan<- prometheus.Metric) error { 43 | c.origin.Collect(ch) 44 | return nil 45 | } 46 | 47 | type standardProcessCollector struct { 48 | origin prometheus.Collector 49 | } 50 | 51 | // NewStandardProcessCollector creates standard process collector. 52 | func NewStandardProcessCollector(_ log.Logger) (cl.Collector, error) { 53 | c := collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}) 54 | return &standardProcessCollector{origin: c}, nil 55 | } 56 | 57 | func (c *standardProcessCollector) Update(ch chan<- prometheus.Metric) error { 58 | c.origin.Collect(ch) 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /percona/tests/upstream_update/Makefile: -------------------------------------------------------------------------------- 1 | ######################### 2 | ### tests 3 | 4 | # measures avg scrape time and compares old vs new exporters 5 | test-performance: 6 | go test -v -run '^TestPerformance$$' -args -doRun=true 7 | 8 | extraMetrics = false 9 | multipleLabels = false 10 | dumpMetrics = false 11 | 12 | test-metrics: 13 | go test -v -run '^TestMissingMetrics$$' -args -doRun=true 14 | 15 | test-labels: 16 | go test -v -run '^TestMissingLabels$$' -args -doRun=true 17 | 18 | test-resolutions-duplicates: 19 | go test -v -run '^TestResolutionsMetricDuplicates$$' -args -doRun=true 20 | 21 | test-resolutions: 22 | go test -v -run '^TestResolutions$$' -args -doRun=true 23 | 24 | dump-metrics: 25 | go test -v -run '^TestDumpMetrics$$' -args -doRun=true -extraMetrics=$(extraMetrics) -multipleLabels=$(multipleLabels) -dumpMetrics=$(dumpMetrics) 26 | 27 | test-consistency: test-metrics test-resolutions test-resolutions-duplicates 28 | 29 | ######################### 30 | ### env preparation 31 | 32 | # download exporter from provided feature build's client binary url 33 | prepare-exporter: 34 | go test -v -run '^TestPrepareUpdatedExporter$\' -args -doRun=true -url=$(url) 35 | 36 | prepare-exporter-from-repo: 37 | make -C ../../../ build && cp ../../../node_exporter assets/node_exporter 38 | 39 | prepare-base-exporter: 40 | tar -xf assets/node_exporter_percona.tar.xz -C assets/ 41 | 42 | prepare-env-from-repo: prepare-exporter-from-repo prepare-base-exporter 43 | -------------------------------------------------------------------------------- /percona/tests/upstream_update/assets/node_exporter_percona.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/percona/node_exporter/056f570aa6302c54620b74f38cb45ef40f9ba4eb/percona/tests/upstream_update/assets/node_exporter_percona.tar.xz -------------------------------------------------------------------------------- /percona/tests/upstream_update/readme.md: -------------------------------------------------------------------------------- 1 | ### integration tests for exporter update 2 | 3 | basic usage: 4 | 5 | 1. unpack original exporter 6 | 7 | 8 | make prepare-base-exporter 9 | 10 | 2.a. download updated exporter from specific feature build 11 | 12 | make prepare-exporter url="" 13 | 14 | 2.b. or use current repo as updated exporter 15 | 16 | make prepare-exporter-from-repo 17 | 18 | 3. start test postgres_server 19 | 20 | 21 | make start-postgres-db 22 | 23 | 4. run basic performance comparison test 24 | 25 | 26 | make test-performance 27 | 28 | 5. run metrics list compatibility test 29 | 30 | 31 | make test-metrics 32 | 33 | -------------------------------------------------------------------------------- /scripts/codespell_ignore.txt: -------------------------------------------------------------------------------- 1 | inflight 2 | packages\' 3 | ro 4 | siz 5 | uint 6 | uptodate 7 | datas 8 | mis 9 | bootup -------------------------------------------------------------------------------- /staticcheck.conf: -------------------------------------------------------------------------------- 1 | checks = ["all", "ST1003"] 2 | -------------------------------------------------------------------------------- /test_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -exo pipefail 3 | 4 | docker_image=$1 5 | port=$2 6 | 7 | container_id='' 8 | 9 | wait_start() { 10 | for in in {1..10}; do 11 | if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null; then 12 | docker_cleanup 13 | exit 0 14 | else 15 | sleep 1 16 | fi 17 | done 18 | 19 | exit 1 20 | } 21 | 22 | docker_start() { 23 | container_id=$(docker run -d -p "${port}":"${port}" "${docker_image}") 24 | } 25 | 26 | docker_cleanup() { 27 | docker kill "${container_id}" 28 | } 29 | 30 | if [[ "$#" -ne 2 ]] ; then 31 | echo "Usage: $0 quay.io/prometheus/node-exporter:v0.13.0 9100" >&2 32 | exit 1 33 | fi 34 | 35 | docker_start 36 | wait_start 37 | -------------------------------------------------------------------------------- /text_collector_examples/README.md: -------------------------------------------------------------------------------- 1 | # Text collector example scripts 2 | 3 | The scripts have been moved to 4 | https://github.com/prometheus-community/node-exporter-textfile-collector-scripts 5 | -------------------------------------------------------------------------------- /tls_config_noAuth.bad.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/percona/node_exporter/056f570aa6302c54620b74f38cb45ef40f9ba4eb/tls_config_noAuth.bad.yml --------------------------------------------------------------------------------