Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1


Remember Me


4 votes
check_lvmUpdated v1.7
lvm_resizeUpdated v1.1

Help Support Ethan Galstad's New Project:

Help Support Ethan

A Message From The Founder...

As the founder of Nagios, I'm asking for your help in a cause that's dear to my heart.

I'm launching a new project to help better the world by providing the information, ideas, and inspiration that I believe can improve the lives of people everywhere.

I know you're busy managing networks, but I would appreciate it if you would consider liking my Facebook page and showing your support for the content and messages I produce by sharing them with your friends and family.

You can learn more about my project by visiting Thank you for your time. I wish you all the best in your endeavors, whatever they may be.

- Ethan

Scans for LVM logical volumes and checks used space on them. Shell script(sh), GPL
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

This plugin finds all LVM logical volumes, checks their used space, and compares against the supplied thresholds.


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


NOTE: resize_percent is an integer greater than zero (without a '%' character)

This script currently only works with ext2/3 and reiserfs!

Reviews (3)

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

I have I volume group, any ideas of why is complainning about that?
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?
change the line:

## Get lv's and their df's
for vg in `lvs --noheadings --nosuffix --units b --separator " " --options vg_name`; do


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]*%"`
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
msgs="$msgs$outname/$outper ($outmount)"
elif [ $thresh_warn ] && [ "$outnum" -ge "$thresh_warn" ]; then
msgs="$msgs$outname/$outper ($outmount)"