Skip to content
Snippets Groups Projects
Commit fa688210 authored by Josef Němec's avatar Josef Němec
Browse files

Merge branch 'fix/diskmon-metric-format' into 'master'

Change diskmon

See merge request !9
parents ead77b71 e8f4b568
No related branches found
No related tags found
1 merge request!9Change diskmon
Pipeline #317514 passed
......@@ -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
......
......@@ -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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment