prometheus-disk-exporter


Nameprometheus-disk-exporter JSON
Version 0.0.4 PyPI version JSON
download
home_page
SummaryS.M.A.R.T. and partition data exporter for the Prometheus monitoring system
upload_time2024-02-16 12:10:46
maintainer
docs_urlNone
author
requires_python>=3.11
licenseApache-2.0
keywords metrics disk prometheus exporter monitoring smart
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # prometheus-disk-exporter

A prometheus exporter for disk S.M.A.R.T. data and partition usage

## information

For security reasons, this script is *not* supposed to be ran with root
privileges. Instead, the only command which requires these privileges
(`smartctl`) is ran using `sudo` within `getter.sh`. For this reason
the installation step includes adding a sudoers configuration to run
this command without the need of a password for the specified user.

## installing

These steps assume that you are running with root privileges.

### Setup prometheus user

> Note: this step can be skipped if you already have a linux user 
> for exporting prometheus metrics, such as for prometheus-pve-exporter

1. Create linux user with no login
```
# useradd -s /bin/false prometheus
```

### Install package in virtual environment

1. Install the `venv` python module
```
# apt install python3-venv
```
2. Create the virtual environment in `/opt`
```
# python3 -m venv /opt/prometheus-disk-exporter
```
3. Activate the virtual environment
```
# source /opt/prometheus-disk-exporter/bin/activate
```
4. Install the pip package for prometheus-disk-exporter
```
(prometheus-disk-exporter) # pip install prometheus-disk-exporter
```
5. Disable the virtual environment
```
(prometheus-disk-exporter) # deactivate
```

### Setup sudoers and systemd configuration

1. Add sudoers configuration to run `smartctl` without password.
```
# echo "prometheus ALL=(ALL:ALL) NOPASSWD: $(which smartctl)" | tee -a /etc/sudoers.d/99-prometheus-disk-exporter
```
2. Create a systemd service `/etc/systemd/system/prometheus-disk-exporter.service` for this script.
   A sample can be found in the `systemd` folder of the repository.
3. Start and enable the systemd service.
```
# systemctl daemon-reload
# systemctl enable prometheus-disk-exporter.service
# systemctl start prometheus-disk-exporter.service
```
4. Verify that the installation was successful by visiting `0.0.0.0:9313`,
   or whatever address and port you specified in the command arguments

## arguments
```
usage: prometheus_disk_exporter [-h] [--listen-address LISTEN_ADDRESS]
                                [--listen-port LISTEN_PORT]

options:
  -h, --help            show this help message and exit
  --listen-address LISTEN_ADDRESS, -l LISTEN_ADDRESS
                        Address for HTTP server to listen on
  --listen-port LISTEN_PORT, -p LISTEN_PORT
                        Port for HTTP server to listen on
```

* **listen-address:** Address for HTTP server to listen on (string) (Default: '0.0.0.0')
* **listen-port:** Port for HTTP server to listen on (int) (Default: 9313)


## metrics sample

```
# HELP disk_getter_error Indicates an internal error while getting data from shell script
# TYPE disk_getter_error gauge
disk_getter_error{type="None"} 0.0
# HELP disk_model_info Disk Model Family
# TYPE disk_model_info gauge
disk_model_info{disk_serial="WD-WCC6Y3TVHSKJ",model_family="Western Digital Blue",rpm="7200 rpm"} 1.0
disk_model_info{disk_serial="50026B76821954FF",model_family="Kingston SSDNow UV400/500",rpm="Solid State Device"} 1.0
# HELP disk_power_on_hours Hours spent with disk powered
# TYPE disk_power_on_hours gauge
disk_power_on_hours{disk_serial="WD-WCC6Y3TVHSKJ"} 11583.0
disk_power_on_hours{disk_serial="50026B76821954FF"} 11583.0
# HELP disk_power_cycle_count Disk power cycle count
# TYPE disk_power_cycle_count gauge
disk_power_cycle_count{disk_serial="WD-WCC6Y3TVHSKJ"} 2055.0
disk_power_cycle_count{disk_serial="50026B76821954FF"} 2032.0
# HELP disk_raw_read_error_rate Disk raw read error rate
# TYPE disk_raw_read_error_rate gauge
disk_raw_read_error_rate{disk_serial="WD-WCC6Y3TVHSKJ"} 0.0
disk_raw_read_error_rate{disk_serial="50026B76821954FF"} 2.476152e+06
# HELP disk_temperature Disk temperature in Celsius
# TYPE disk_temperature gauge
disk_temperature{disk_serial="WD-WCC6Y3TVHSKJ"} 41.0
disk_temperature{disk_serial="50026B76821954FF"} 42.0
# HELP partition_info Partition metadata information
# TYPE partition_info gauge
partition_info{block="/dev/sda1",disk_serial="WD-WCC6Y3TVHSKJ",filesystem="ext4",mountpoint="/media"} 1.0
partition_info{block="/dev/sdb1",disk_serial="50026B76821954FF",filesystem="vfat",mountpoint="/boot/efi"} 1.0
partition_info{block="/dev/sdb2",disk_serial="50026B76821954FF",filesystem="ext4",mountpoint="/"} 1.0
# HELP partition_usage_bytes Partition used size in bytes
# TYPE partition_usage_bytes gauge
partition_usage_bytes{block="/dev/sda1",disk_serial="WD-WCC6Y3TVHSKJ"} 1.33785550848e+011
partition_usage_bytes{block="/dev/sdb1",disk_serial="50026B76821954FF"} 303104.0
partition_usage_bytes{block="/dev/sdb2",disk_serial="50026B76821954FF"} 2.4086495232e+010
# HELP partition_size_bytes Partition total size in bytes
# TYPE partition_size_bytes gauge
partition_size_bytes{block="/dev/sda1",disk_serial="WD-WCC6Y3TVHSKJ"} 9.83349346304e+011
partition_size_bytes{block="/dev/sdb1",disk_serial="50026B76821954FF"} 3.13929728e+08
partition_size_bytes{block="/dev/sdb2",disk_serial="50026B76821954FF"} 1.17236166656e+011
```

## credits
- [prometheus_smart_exporter](https://github.com/cloudandheat/prometheus_smart_exporter).
  if all you are looking for is a SMART data exporter, i highly recommend their
  implementation
- [proxmox prometheus metrics](https://community.hetzner.com/tutorials/proxmox-prometheus-metrics),
  for helping me figure out how to properly install the package

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "prometheus-disk-exporter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "metrics,disk,prometheus,exporter,monitoring,smart",
    "author": "",
    "author_email": "Pietro Bonaldo Gregori <pietro.bogre@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1a/cd/bef35e7dd5141ff936f5d2e47fd76dbaac131d6f43d650ef423fe30355f2/prometheus-disk-exporter-0.0.4.tar.gz",
    "platform": null,
    "description": "# prometheus-disk-exporter\n\nA prometheus exporter for disk S.M.A.R.T. data and partition usage\n\n## information\n\nFor security reasons, this script is *not* supposed to be ran with root\nprivileges. Instead, the only command which requires these privileges\n(`smartctl`) is ran using `sudo` within `getter.sh`. For this reason\nthe installation step includes adding a sudoers configuration to run\nthis command without the need of a password for the specified user.\n\n## installing\n\nThese steps assume that you are running with root privileges.\n\n### Setup prometheus user\n\n> Note: this step can be skipped if you already have a linux user \n> for exporting prometheus metrics, such as for prometheus-pve-exporter\n\n1. Create linux user with no login\n```\n# useradd -s /bin/false prometheus\n```\n\n### Install package in virtual environment\n\n1. Install the `venv` python module\n```\n# apt install python3-venv\n```\n2. Create the virtual environment in `/opt`\n```\n# python3 -m venv /opt/prometheus-disk-exporter\n```\n3. Activate the virtual environment\n```\n# source /opt/prometheus-disk-exporter/bin/activate\n```\n4. Install the pip package for prometheus-disk-exporter\n```\n(prometheus-disk-exporter) # pip install prometheus-disk-exporter\n```\n5. Disable the virtual environment\n```\n(prometheus-disk-exporter) # deactivate\n```\n\n### Setup sudoers and systemd configuration\n\n1. Add sudoers configuration to run `smartctl` without password.\n```\n# echo \"prometheus ALL=(ALL:ALL) NOPASSWD: $(which smartctl)\" | tee -a /etc/sudoers.d/99-prometheus-disk-exporter\n```\n2. Create a systemd service `/etc/systemd/system/prometheus-disk-exporter.service` for this script.\n   A sample can be found in the `systemd` folder of the repository.\n3. Start and enable the systemd service.\n```\n# systemctl daemon-reload\n# systemctl enable prometheus-disk-exporter.service\n# systemctl start prometheus-disk-exporter.service\n```\n4. Verify that the installation was successful by visiting `0.0.0.0:9313`,\n   or whatever address and port you specified in the command arguments\n\n## arguments\n```\nusage: prometheus_disk_exporter [-h] [--listen-address LISTEN_ADDRESS]\n                                [--listen-port LISTEN_PORT]\n\noptions:\n  -h, --help            show this help message and exit\n  --listen-address LISTEN_ADDRESS, -l LISTEN_ADDRESS\n                        Address for HTTP server to listen on\n  --listen-port LISTEN_PORT, -p LISTEN_PORT\n                        Port for HTTP server to listen on\n```\n\n* **listen-address:** Address for HTTP server to listen on (string) (Default: '0.0.0.0')\n* **listen-port:** Port for HTTP server to listen on (int) (Default: 9313)\n\n\n## metrics sample\n\n```\n# HELP disk_getter_error Indicates an internal error while getting data from shell script\n# TYPE disk_getter_error gauge\ndisk_getter_error{type=\"None\"} 0.0\n# HELP disk_model_info Disk Model Family\n# TYPE disk_model_info gauge\ndisk_model_info{disk_serial=\"WD-WCC6Y3TVHSKJ\",model_family=\"Western Digital Blue\",rpm=\"7200 rpm\"} 1.0\ndisk_model_info{disk_serial=\"50026B76821954FF\",model_family=\"Kingston SSDNow UV400/500\",rpm=\"Solid State Device\"} 1.0\n# HELP disk_power_on_hours Hours spent with disk powered\n# TYPE disk_power_on_hours gauge\ndisk_power_on_hours{disk_serial=\"WD-WCC6Y3TVHSKJ\"} 11583.0\ndisk_power_on_hours{disk_serial=\"50026B76821954FF\"} 11583.0\n# HELP disk_power_cycle_count Disk power cycle count\n# TYPE disk_power_cycle_count gauge\ndisk_power_cycle_count{disk_serial=\"WD-WCC6Y3TVHSKJ\"} 2055.0\ndisk_power_cycle_count{disk_serial=\"50026B76821954FF\"} 2032.0\n# HELP disk_raw_read_error_rate Disk raw read error rate\n# TYPE disk_raw_read_error_rate gauge\ndisk_raw_read_error_rate{disk_serial=\"WD-WCC6Y3TVHSKJ\"} 0.0\ndisk_raw_read_error_rate{disk_serial=\"50026B76821954FF\"} 2.476152e+06\n# HELP disk_temperature Disk temperature in Celsius\n# TYPE disk_temperature gauge\ndisk_temperature{disk_serial=\"WD-WCC6Y3TVHSKJ\"} 41.0\ndisk_temperature{disk_serial=\"50026B76821954FF\"} 42.0\n# HELP partition_info Partition metadata information\n# TYPE partition_info gauge\npartition_info{block=\"/dev/sda1\",disk_serial=\"WD-WCC6Y3TVHSKJ\",filesystem=\"ext4\",mountpoint=\"/media\"} 1.0\npartition_info{block=\"/dev/sdb1\",disk_serial=\"50026B76821954FF\",filesystem=\"vfat\",mountpoint=\"/boot/efi\"} 1.0\npartition_info{block=\"/dev/sdb2\",disk_serial=\"50026B76821954FF\",filesystem=\"ext4\",mountpoint=\"/\"} 1.0\n# HELP partition_usage_bytes Partition used size in bytes\n# TYPE partition_usage_bytes gauge\npartition_usage_bytes{block=\"/dev/sda1\",disk_serial=\"WD-WCC6Y3TVHSKJ\"} 1.33785550848e+011\npartition_usage_bytes{block=\"/dev/sdb1\",disk_serial=\"50026B76821954FF\"} 303104.0\npartition_usage_bytes{block=\"/dev/sdb2\",disk_serial=\"50026B76821954FF\"} 2.4086495232e+010\n# HELP partition_size_bytes Partition total size in bytes\n# TYPE partition_size_bytes gauge\npartition_size_bytes{block=\"/dev/sda1\",disk_serial=\"WD-WCC6Y3TVHSKJ\"} 9.83349346304e+011\npartition_size_bytes{block=\"/dev/sdb1\",disk_serial=\"50026B76821954FF\"} 3.13929728e+08\npartition_size_bytes{block=\"/dev/sdb2\",disk_serial=\"50026B76821954FF\"} 1.17236166656e+011\n```\n\n## credits\n- [prometheus_smart_exporter](https://github.com/cloudandheat/prometheus_smart_exporter).\n  if all you are looking for is a SMART data exporter, i highly recommend their\n  implementation\n- [proxmox prometheus metrics](https://community.hetzner.com/tutorials/proxmox-prometheus-metrics),\n  for helping me figure out how to properly install the package\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "S.M.A.R.T. and partition data exporter for the Prometheus monitoring system",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/pbogre/prometheus-disk-exporter"
    },
    "split_keywords": [
        "metrics",
        "disk",
        "prometheus",
        "exporter",
        "monitoring",
        "smart"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b8bfeb4e4eb21ed08df7fa1e50d4f14bc92cc45c806d2962c74561b8ac5ab56b",
                "md5": "832646719cb852cf2141eb57a3b5e4e7",
                "sha256": "eeade9fdaded840f4f757e465ded90937d6f8cdf06a85370cee11bd1eaa8b63d"
            },
            "downloads": -1,
            "filename": "prometheus_disk_exporter-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "832646719cb852cf2141eb57a3b5e4e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 10872,
            "upload_time": "2024-02-16T12:10:45",
            "upload_time_iso_8601": "2024-02-16T12:10:45.001522Z",
            "url": "https://files.pythonhosted.org/packages/b8/bf/eb4e4eb21ed08df7fa1e50d4f14bc92cc45c806d2962c74561b8ac5ab56b/prometheus_disk_exporter-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1acdbef35e7dd5141ff936f5d2e47fd76dbaac131d6f43d650ef423fe30355f2",
                "md5": "e05f185df22feb4bf8c43f3acee854d9",
                "sha256": "c765afc60b5165957b4cc6afdf6cb29315ab4bd20b27231ddef311bf3f9b0883"
            },
            "downloads": -1,
            "filename": "prometheus-disk-exporter-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e05f185df22feb4bf8c43f3acee854d9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 11600,
            "upload_time": "2024-02-16T12:10:46",
            "upload_time_iso_8601": "2024-02-16T12:10:46.804065Z",
            "url": "https://files.pythonhosted.org/packages/1a/cd/bef35e7dd5141ff936f5d2e47fd76dbaac131d6f43d650ef423fe30355f2/prometheus-disk-exporter-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-16 12:10:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pbogre",
    "github_project": "prometheus-disk-exporter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "prometheus-disk-exporter"
}
        
Elapsed time: 0.18680s