# HG changeset patch # User Matthias Förste # Date 1669819125 -3600 # Node ID 896ffeb44d7c56eb68402223fc4a384661e5c4f7 # Parent 11e1f1430bfd6d3878350c27175903ce9bf5beeb moved to https://gitea.schlittermann.de/IUS/monitoring-plugin-lvmthin diff -r 11e1f1430bfd -r 896ffeb44d7c README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Wed Nov 30 15:38:45 2022 +0100 @@ -0,0 +1,1 @@ +moved to https://gitea.schlittermann.de/IUS/monitoring-plugin-lvmthin diff -r 11e1f1430bfd -r 896ffeb44d7c check_lvmthin --- a/check_lvmthin Sat Jun 11 00:19:59 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -#!/bin/sh -e - -ME=$(basename $0) -NAME='LVMTHIN' -E=3 -INFO= -PERFDATA= - -lvsresults=$(mktemp /tmp/$ME.XXX) - -cleanup() { - [ -n "$lvsresults" ] && rm $lvsresults; -} - -nagiosexit() { - local STATUS='UNKNOWN' - if [ $E = '2' ]; then STATUS='CRITICAL' - elif [ $E = '1' ]; then STATUS='WARNING' - elif [ $E = '0' ]; then STATUS='OK' - fi - echo "$NAME $STATUS${INFO:+: ${INFO}}${PERFDATA:+|$PERFDATA}" - exit $E -} - -trap 'trap - EXIT; cleanup; nagiosexit $E' INT QUIT TERM EXIT - -die() { - INFO="$@" - exit 3 -} - -parse_lvs() { - results=$1 - label=$2 - local id= - if [ ! -s "$results" ]; then - id=$(id -u) - die "No volumes found (effective user ID: $id)" - fi - while read vg lv u; do - [ -n "$vg" -a -n "$lv" -a -n "$u" ] || die "Can't parse results" - addinfo= - if [ "$u" '>' "$C" ]; then - E=2 - addinfo='yes' - elif [ "$u" '>' "$W" ]; then - [ $E != '2' ] && E=1 - addinfo='yes' - fi - [ -n "$addinfo" ] && INFO="${INFO:+${INFO}; }$vg/$lv$label $u%" - PERFDATA="${PERFDATA:+${PERFDATA} }$vg/$lv$label=$u%;$W;$C" - done <$results -} - -W='80.00' -C='90.00' -T= -P= - -while getopts "hm?c:p:t:w:" opt; do - case $opt in - h|\?) - cleanup; exec pod2usage -verbose 1 -exit 0 $0 - ;; - m) - cleanup; exec pod2usage -verbose 3 -exit 0 $0 - ;; - c) - C="$OPTARG" - ;; - p) - P="$P $OPTARG" - ;; - t) - T=$T $OPTARG - ;; - w) - W=$OPTARG - ;; - esac -done -shift $((OPTIND-1)) - -lvs --noheadings -S 'segtype=thin||segtype=thin-pool' -o vg_name,lv_name,data_percent $T $P >$lvsresults; parse_lvs $lvsresults -[ -n "$T" -a -z "$P" ] || lvs --noheadings -S 'segtype=thin-pool' -o vg_name,lv_name,metadata_percent $P >$lvsresults; parse_lvs $lvsresults '(meta)' - -[ $E = '3' ] && E=0 -exit $E - -: < - -Display help. - -=item B<-m> - -Display man page. - -=item B<-c> I - -Exit with status 'CRITICAL' if any checked volume uses more than I percent of its size. - -=item B<-t> I - -check usage of thin provisioned logical volume I. - -=item B<-p> I - -check data and metadata usage of pool volume I. - -=item B<-w> I - -Exit with status 'WARNING' if any checked volume uses more than I percent of its size. - -=back - -I and I should be given as names understood by lvs. If both are omitted, then data usage for all thinlv and poollv and metadata usage for all poollv is checked. Thresholds should be given in decimal notation with 2 positions after the decimal point. - -=head1 EXAMPLE - -check_lvmthin -w 76.54 -t vg/lv - -=head1 AUTHOR - -Matthias Förste - -The lastest version is available at L - -=cut - -EOP