Verified Commit edb6bb6c authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Set TYPE/HELP once for multi value metrics for btrfs

parent 0d5eb65a
Pipeline #5402 passed with stage
in 35 seconds
...@@ -23,14 +23,24 @@ btrfs_errors=(write_io_errs read_io_errs flush_io_errs corruption_errs generatio ...@@ -23,14 +23,24 @@ btrfs_errors=(write_io_errs read_io_errs flush_io_errs corruption_errs generatio
for btrfs_mount in ${list_btrfs_submounts[@]}; do for btrfs_mount in ${list_btrfs_submounts[@]}; do
for btrfs_error in "${btrfs_errors[@]}" for btrfs_error in "${btrfs_errors[@]}"
do
echo "# HELP btrfs_${btrfs_error} error" >> $TMP_FILE
echo "# TYPE btrfs_${btrfs_error} gauge" >> $TMP_FILE
done
# Break, as we can only have one HELP/TYPE line
break
done
for btrfs_mount in ${list_btrfs_submounts[@]}; do
for btrfs_error in "${btrfs_errors[@]}"
#echo "# HELP btrfs_${btrfs_error} error" >> $TMP_FILE
#echo "# TYPE btrfs_${btrfs_error} gauge" >> $TMP_FILE
do do
jq_filter=".[\"device-stats\"][].${btrfs_error}" jq_filter=".[\"device-stats\"][].${btrfs_error}"
errors=$(sudo btrfs --format json device stats $btrfs_mount | jq -r ${jq_filter}) errors=$(sudo btrfs --format json device stats $btrfs_mount | jq -r ${jq_filter})
device=$(sudo btrfs --format json device stats $btrfs_mount | jq -r '.["device-stats"][].device') device=$(sudo btrfs --format json device stats $btrfs_mount | jq -r '.["device-stats"][].device')
echo "# HELP btrfs_${btrfs_error} error" >> $TMP_FILE
echo "# TYPE btrfs_${btrfs_error} gauge" >> $TMP_FILE
echo "btrfs_${btrfs_error}{device=\"${device}\"} ${errors}" >> $TMP_FILE echo "btrfs_${btrfs_error}{device=\"${device}\"} ${errors}" >> $TMP_FILE
done done
done done
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment