Skip to content

Commit

Permalink
add support for monitoring LVM caches (Closes: prometheus-community#158)
Browse files Browse the repository at this point in the history
This is basically a copy-paste of the snapshots code, and seems to
work on my end.
  • Loading branch information
anarcat committed Jun 6, 2023
1 parent 4098ef9 commit aff0998
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lvm-prom-collector
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ snapshots=false
physical=false
groups=false

while getopts "htpsg" opt; do
while getopts "htpscg" opt; do
case $opt in
p)
physical=true
;;
s)
snapshots=true
;;
c)
caches=true
;;
g)
groups=true
;;
Expand Down Expand Up @@ -105,6 +108,20 @@ if [ "$snapshots" = true ]; then
done
fi

if [ "$caches" = true ]; then
echo "# HELP node_lvm_caches_allocated percentage of allocated data to a cache"
echo "# TYPE node_lvm_caches_allocated gauge"

lvs_output=$(lvs --noheadings --select 'lv_attr=~[^C.*]' --units b --nosuffix --unquoted --nameprefixes --options lv_uuid,vg_name,data_percent 2>/dev/null)
echo "$lvs_output" | while IFS= read -r line; do
# Skip if the line is empty
[ -z "$line" ] && continue
# shellcheck disable=SC2086
declare $line
echo "node_lvm_caches_allocated{uuid=\"$LVM2_LV_UUID\", vgroup=\"$LVM2_VG_NAME\"} $LVM2_DATA_PERCENT"
done
fi

if [ "$thin_pools" = true ]; then
lvs_output=$(lvs --noheadings --select 'lv_attr=~[^t.*]' --units b --nosuffix --unquoted --nameprefixes --options lv_uuid,vg_name,data_percent,metadata_percent 2>/dev/null)

Expand Down

0 comments on commit aff0998

Please sign in to comment.