Linux

check_lvm

Description:

Scans for LVM logical volumes and checks used space on them. Shell script(sh), GPL

Current Version

Last Release Date

June 16, 2009

Compatible With


Project Files
Project Notes
Plugin for Nagios to monitor the used space on LVM logical volumes Written by Richard Taylor You are free to use this script under the terms of the Gnu Public License. I make no guarantee as to whether this will harm anything, much less work - use at your own risk. NOTE - This script only works on _mounted_ volumes! Usage: ./check_lvm -w -c Description: This plugin finds all LVM logical volumes, checks their used space, and compares against the supplied thresholds. Output: The plugin prints "ok" or either "warning" or "critical" if the corresponing threshold is reached, followed by the used space info for the offending volumes. Exit Codes 0 OK 1 Warning 2 Critical 3 Unknown Invalid command line arguments or could not determine used space Example: check_dirsize -w 90% -c 95% OK (exit code 0) WARNING - /dev/vg1/lv0 92% (exit code 1) CRITICAL - /dev/vg0/lv0 97% (exit code 2) I've also made an event handler to resize the lv's from the output of the check plugin: lvm_resize 1.1 (c) 2006 Richard Taylor Event handler script for Nagios for resizing LVM logical volumes Usage: lvm_resize $SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$ resize_percent $OUTPUT$ NOTE: resize_percent is an integer greater than zero (without a '%' character) This script currently only works with ext2/3 and reiserfs!
Reviews (4) Add a Review
need to sudo the check config
by rnicksic, February 29, 2020

nagios user doesn't have permission to check the LVM status. Need to allow nagios user to run the check with sudo permission and add sudo to the check configuration



Error on brackets (if statements)
by altmas5, May 31, 2018

Hello, I have this output using the plugin on one specific box: sudo ./check_lvm -w 20% -c 10% ./check_lvm: 73: ./check_lvm: [[: not found ./check_lvm: 110: ./check_lvm: [[: not found ./check_lvm: 125: ./check_lvm: [[: not found ./check_lvm: 143: ./check_lvm: [[: not found ./check_lvm: 143: ./check_lvm: [[: not found ./check_lvm: 143: ./check_lvm: [[: not found ./check_lvm: 143: ./check_lvm: [[: not found OK I have I volume group, any ideas of why is complainning about that?



Returns ok even if LVM full
by nick, April 30, 2016

Hi, Whenever I run the script on the client server, the scripts works well, it takes few seconds to scan and give the results but whenever I run NRPE from the Nagios servers to query the client, it give the result "ok" instantly, giving the result before waiting for the scan to finish. This is the command on the Nagios server ./check_nrpe -H HOST -c check_lvm please can you help me?



A litle correction and contrib
by lionbatata, April 30, 2011

change the line: ## Get lv's and their df's for vg in `lvs --noheadings --nosuffix --units b --separator " " --options vg_name`; do for: for vg in `vgs --noheadings --nosuffix --units b --separator " " --options vg_name`; do For enhanced the output, change the entire block code as above: ## Get lv's and their df's for vg in `vgs --noheadings --nosuffix --units b --separator " " --options vg_name`; do for lv in `lvs --noheadings --nosuffix --units b --separator " " --options lv_name $vg`; do if [[ `mount | grep $vg | grep $lv` ]]; then dfout=`df -P --block-size=1 | grep $vg | grep $lv` outper=`echo "$dfout" | grep --only-matching "[0-9]*%"` outname="$vg/$lv" outmount=`echo "$dfout" | awk '{print $6}'` #`echo "$dfout" | awk '{ print $1 }'` outnum=`expr match "$outper" '([0-9]*)'` if [ $thresh_crit ] && [ "$outnum" -ge "$thresh_crit" ]; then critflag=1 msgs="$msgs$outname/$outper ($outmount)" elif [ $thresh_warn ] && [ "$outnum" -ge "$thresh_warn" ]; then warnflag=1 msgs="$msgs$outname/$outper ($outmount)" fi fi done done



Project Stats
Rating
2.8 (6)
Favorites
0
Views
164,871