diff --git a/CHANGELOG.md b/CHANGELOG.md index 160ec18fede94144ebac2241089d4a50989a6190..24d84339d8506754f184e2c47a891fba53303b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.3.2] - 2023-09-05 +### Fixed +- diskmon: change metric format + ## [1.3.1] - 2023-09-04 ### Fixed - diskmon: use by default diff --git a/src/metric-generators/diskmon.sh b/src/metric-generators/diskmon.sh index 77c4edb56b0ab7f9a8d0645beeb9458164fdccfb..b850dc292a6d0b819573028a2904f2a8dfc899bc 100755 --- a/src/metric-generators/diskmon.sh +++ b/src/metric-generators/diskmon.sh @@ -2,14 +2,22 @@ set -eo pipefail -DEVICES="$(lsblk -o kname,fstype,mountpoint,rota --raw --noheadings | awk 'NF==4{print}')" +DEVICES="$(lsblk -o name,rota --raw --noheadings)" METRIC_NAME="diskmon_is_rotational" printf '# HELP %s Information about disk being rotational.\n' $METRIC_NAME printf '# TYPE %s gauge\n' $METRIC_NAME while read device; do - printf '%s{device="%s",fstype="%s",mountpoint="%s"} %d\n' $METRIC_NAME \ - "$(echo $device | cut -d ' ' -f1)" "$(echo $device | cut -d ' ' -f2)" \ - "$(echo $device | cut -d ' ' -f3)" "$(echo $device | cut -d ' ' -f4)" + name=$(echo $device | cut -d ' ' -f1) + + if ls /dev | grep -q $name; then + name="/dev/${name}" + elif [[ "$name" == "rootfs" ]] || [[ "$name" == "tmpfs" ]]; then + : # name is correct + else + name="/dev/mapper/${name}" + fi + + printf '%s{device="%s"} %d\n' $METRIC_NAME $name "$(echo $device | cut -d ' ' -f2)" done <<< "$DEVICES"