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
sudo -H pip install disk_usage_exporter
From source
- Install
buildpackage
python -m pip install build
- Build package
python -m build
- Install package
VERSION=0.1.0
sudo -H pip install dist/disk_usage_exporter-$VERSION-py3-none-any.whl
Usage
usage: disk_usage_exporter [-h] [--addr ADDR] [--port PORT] [--search-root SEARCH_ROOT] [-d] [-v]
options:
-h, --help show this help message and exit
--addr ADDR specify metrics host
--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
- Add a new job to Prometheus configuration:
/etc/prometheus/prometheus.yml
...
scrape_configs:
- job_name: "disk_usage_exporter"
static_configs:
- targets: ["localhost:8100"]
- Restart Prometheus:
PROMETHEUS_HOST=localhost
PROMETHEUS_PORT=9091
curl -XPOST $PROMETHEUS_HOST:$PROMETHEUS_PORT/-/reload
Systemd unit
- Create a file named
/etc/systemd/system/disk_usage_exporter.serviceand include the following:
[Unit]
Description=disk_usage_exporter service
[Service]
ExecStart=disk_usage_exporter
[Install]
WantedBy=multi-user.target
- Reload the service files to include a new service:
sudo systemctl daemon-reload
- Start service:
sudo systemctl start disk_usage_exporter
ToDo:
- Rename
constants.pytoconst.py - Add default host and port to
const.py - Add
--hostoption - Add
--hostdescription toREADME.md - Add
--max-depthoption - 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
- Add badges with code coverage and tests passing
- Add test that checks metrics after a few seconds after startup
- Add info about cmd args default values to README.md
- Add
--excludeoption - Add documentation (docstring)
- Exit with non-zero code when exception caught
- Exclude directory name from
get_dir_sizereturn value
Project details
Release history Release notifications | RSS feed
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.1.0.tar.gz
(19.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file disk_usage_exporter-0.1.0.tar.gz.
File metadata
- Download URL: disk_usage_exporter-0.1.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5afe5e7d95f4c0e9bbb3e9a0d97f3d2b0e4f8ce64a5b29ef5617129dfd5135ca
|
|
| MD5 |
7d39b7cb467df918fe9b79bd1c4103f5
|
|
| BLAKE2b-256 |
e3c57395fd1dd2e61a7e2ee25b686fb88ae3d3de247aeaac4e74f6e4a7897690
|
File details
Details for the file disk_usage_exporter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: disk_usage_exporter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3724952ffd5cad8de3d50dc712e9c12474d4da4d89a44bb21083d79719bf5c20
|
|
| MD5 |
c2baa8b7898fd66de0c57cb21f1b3a72
|
|
| BLAKE2b-256 |
53b8e74a57fd3947d9016ce3f5a3e3f0df352a0d52acc36cf4aaaf3f2923c239
|