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
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_lvm

Rating
6 votes
Favoured:
0
Hits
164911
Files:
FileDescription
check_lvmUpdated v1.7
lvm_resizeUpdated v1.1
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
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

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)
byrnicksic, February 28, 2020
1 of 1 people found this review helpful
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
byaltmas5, May 31, 2018
0 of 1 people found this review helpful
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?
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?
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