Skip to main content

Exporter for disk usage metrics

Project description

disk_usage_exporter

Exporter for disk usage metrics.

Metrics example
# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 187734.0
python_gc_objects_collected_total{generation="1"} 74395.0
python_gc_objects_collected_total{generation="2"} 6222.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 363.0
python_gc_collections_total{generation="1"} 33.0
python_gc_collections_total{generation="2"} 2.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="9",patchlevel="21",version="3.9.21"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 5.58657536e+08
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.072576e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.73804800503e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 7.79
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024.0
# HELP disk_usage_by_directories Directory size
# TYPE disk_usage_by_directories gauge
disk_usage_by_directories{path="/media"} 4.0
disk_usage_by_directories{path="/tmp"} 78660.0
disk_usage_by_directories{path="/var"} 6.9855712e+07
disk_usage_by_directories{path="/sys"} 0.0
disk_usage_by_directories{path="/etc"} 25232.0
disk_usage_by_directories{path="/lost+found"} 16.0
disk_usage_by_directories{path="/boot"} 274220.0
disk_usage_by_directories{path="/lib64"} 0.0
disk_usage_by_directories{path="/srv"} 4.0
disk_usage_by_directories{path="/opt"} 35116.0
disk_usage_by_directories{path="/sbin"} 0.0
disk_usage_by_directories{path="/data"} 2.7009988e+07
disk_usage_by_directories{path="/bin"} 0.0
disk_usage_by_directories{path="/mnt"} 4.0
disk_usage_by_directories{path="/run"} 1.3066156e+07
disk_usage_by_directories{path="/afs"} 4.0
disk_usage_by_directories{path="/lib"} 0.0
disk_usage_by_directories{path="/dev"} 16.0
disk_usage_by_directories{path="/proc"} 0.0
disk_usage_by_directories{path="/usr"} 4.38558e+06
disk_usage_by_directories{path="/home"} 5.203604e+06
disk_usage_by_directories{path="/root"} 2324.0

Installation

From PyPI (soon)

sudo -H pip install disk_usage_exporter

From source

  1. Install build package
python -m pip install build
  1. Build package
python -m build
  1. Install package
VERSION=0.0.1
sudo -H pip install dist/disk_usage_exporter-$VERSION-py3-none-any.whl

Usage

disk_usage_exporter [-h] [--port PORT] [--search-root SEARCH_ROOT] [--max-depth MAX_DEPTH] [-d] [-v]

options:
  -h, --help            show this help message and exit
  --port PORT           specify metrics port
  --search-root SEARCH_ROOT
                        specify the directory that will be used to search for subdirectories to analyze
  -d, --debug           enable debug logs
  -v, --version         show program's version number and exit

Prometheus configuration

  1. Add a new job to Prometheus configuration: /etc/prometheus/prometheus.yml
...
scrape_configs:
  - job_name: "disk_usage_exporter"
    static_configs:
      - targets: ["localhost:8100"] 
  1. Restart Prometheus:
PROMETHEUS_HOST=localhost
PROMETHEUS_PORT=9091
curl -XPOST $PROMETHEUS_HOST:$PROMETHEUS_PORT/-/reload

Systemd unit

  1. Create a file named /etc/systemd/system/disk_usage_exporter.service and include the following:
[Unit]
Description=disk_usage_exporter service

[Service]
ExecStart=disk_usage_exporter

[Install]
WantedBy=multi-user.target
  1. Reload the service files to include a new service:
sudo systemctl daemon-reload
  1. Start service:
sudo systemctl start disk_usage_exporter

ToDo:

  • Add --host option
  • Add --max-depth option
  • Make getting values asynchronous
  • Make project structure similar to other prometheus exporters
  • Add informative logging messages
  • Add CI with linter
  • Add tests
  • Add name for python process

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disk_usage_exporter-0.0.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

disk_usage_exporter-0.0.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file disk_usage_exporter-0.0.1.tar.gz.

File metadata

  • Download URL: disk_usage_exporter-0.0.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for disk_usage_exporter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4826a3d6bc50e342d508cd1f0b8ac516eaa6444e472c49ed3f2bb807ca82008e
MD5 8d12f76804aa82e489cc2a9d244b8794
BLAKE2b-256 27aa48fe5eeb96d9e17505890f73fae6e28ec299bacc3293215c0b2f49cc87f9

See more details on using hashes here.

File details

Details for the file disk_usage_exporter-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for disk_usage_exporter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bff603fbddb469c84fc57cf07be59563c285b7885bf95d16aecd19e9bbb3519
MD5 0270ba02d95b93786026b87da2f2b200
BLAKE2b-256 39a6dab34bb0f6e1a1cfaca785b3e3c79c4d2586ed6e6ea4a2eaedbf76067d87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page