node-exporter-textfile-collector-scripts
node-exporter-textfile-collector-scripts copied to clipboard
Adds multipathd_metrics.sh
Pull Request for Prometheus Textfile Collector Script for Multipathd
Title: Add script multipathd_exporter.sh to collect multipathd metrics for Prometheus
Description:
This pull request introduces a new script, multipathd_exporter.sh, designed to collect and expose metrics from the multipathd show multipaths command in a format compatible with the Prometheus textfile collector. This script leverages jq to parse the JSON output of multipathd and extracts key information about multipath devices and their paths, output is then written to file using sponge.
Metrics Exposed:
The script currently exposes the following metrics:
node_multipath_paths_dm_st: A gauge representing the count of paths with anactiveDirect Mapped (DM) state within each multipath device's path groups. Labels includename(multipath device name),uuid,vend(vendor),prod(product), andstate="active".node_multipath_paths_chk_st: A gauge representing the count of paths with areadycheck status (chk_st) within each multipath device's path groups. Labels includename,uuid,vend,prod, andstate="ready".node_multipath_paths_dev_st: A gauge representing the count of paths with arunningdevice status (dev_st) within each multipath device's path groups. Labels includename,uuid,vend,prod, andstate="running".node_multipath_dm_st: A gauge representing the count of multipath devices with anactiveDM state. Labels includename,uuid,vend,prod, andstate="active".node_multipath_path_nr: A gauge representing the total number of paths associated with each multipath device. Labels includename,uuid,vend, andprod.node_multipath_path_faults: A gauge representing the number of faults reported for each multipath device. Labels includename,uuid,vend, andprod.
Usage:
- Ensure that
jqandmoreutilsare installed on the system where the script will run. - Save the provided script as
multipathd_exporter.sh(or a similar name). - Make the script executable:
chmod +x multipathd_exporter.sh. - Configure the Prometheus node exporter to collect metrics from the textfile collector. This typically involves setting the
--collector.textfile.directoryflag to a directory where Prometheus can read the output of this script. - Run the script periodically (e.g., via cron) and output its results to a file within the configured textfile collector directory using sponge to write out to file. For example:
*/5 * * * * /usr/local/bin/multipathd_metrics.sh | sponge /var/lib/prometheus/node-exporter/multipathd.prom
Benefits:
- Provides valuable insights into the health and status of multipath devices.
- Allows for monitoring the number of active, ready, and running paths.
- Tracks the total number of paths and reported faults for each multipath device.
- Integrates seamlessly with Prometheus for alerting and visualization.
Author: Nick Galtry