Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_disk_util.sh
0.1 Gamma "Hulk state"
2014-06-10
- Nagios 3.x
- Nagios 4.x
BSD
21832
File | Description |
---|---|
check_disk_util.sh | check_disk_util.sh |
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!
Examples:
check_disk_util -w 80 -c 90 -d sda
Checks /dev/sda* at 80% and 90% of disk utilization
OK: sda disk utilization 2.52%
OK: sda1 disk utilization 0.00%
OK: sda2 disk utilization 1.31%
OK: sda3 disk utilization 1.52%
OK: sda4 disk utilization 0.05%
Reviews (1)
byhavrla, February 20, 2016
1 of 1 people found this review helpful
#!/bin/bash
# ---------------------------------------------------- #
# File : check_disk_util.sh
# Author : Esteban Monge
# Email : emonge@gbm.net
# Date : 10/06/2014
# Version: 0.1 Gamma "Hulk state"
# ---------------------------------------------------- #
device=""
warning=80
critical=90
was_warning=""
was_critical=""
function help {
echo "Usage"
echo "check_disk {-w limit -c limit -d device}"
echo "Options:"
echo "-h"
echo " Print detailed help screen"
echo "-w=INTEGER"
echo " Exit with WARNING status if more than INTEGER percentaje of utilization are used"
echo "-c=INTEGER"
echo " Exit with CRITICAL status if more than INTEGER percentaje of utilization are used"
echo "-d="
echo " Device without complete route"
echo " "
echo "Example:"
echo "check_disk_util -w 80 -c 90 -d sda1"
echo " Checks /dev/sda1 at 80% and 90% of disk utilization"
echo "check_disk_util -w 80 -c 90 -d sda"
echo " Checks /dev/sda1, /dev/sda2, /dev/sda3, etc (regular expression) at 80% and 90% of disk utilization"
exit 0
}
while getopts "w:c:d:h" args; do
case $args in
w) warning=$OPTARG
;;
c) critical=$OPTARG
;;
d) device=$OPTARG
;;
h) help
;;
esac
done
if [[ $critical -lt $warning ]];then
echo "UNKNOWN: Warning threshold must be lower than Critical threshold"
exit 4
fi
column_number=`iostat -x | grep -e "Device" | awk '{print NF}'`
iostat -x 1 2 |grep -e "$device" | awk -v column=$column_number '/sd|dm/ {print $1,$column}' > /tmp/disk_utili.tmp
radek=`cat /tmp/disk_utili.tmp | wc -l`
polovina=`echo "$radek / 2 "| bc`
cat /tmp/disk_utili.tmp | tail -n $polovina > /tmp/disk_utili1.tmp
while read line
do
device=`echo $line | awk '{print $1}'`
disk_util=`echo $line | awk '{print $2}' | cut -d "," -f1 `
if [ ${disk_util%.*} -ge $critical ];then
echo "CRITICAL: $device disk utilization $disk_util%"
was_critical=1
else if [ ${disk_util%.*} -ge $warning ];then
echo "WARNING: $device disk utilization $disk_util%"
was_warning=1
else echo "OK: $device disk utilization $disk_util%"
fi
fi
done
# ---------------------------------------------------- #
# File : check_disk_util.sh
# Author : Esteban Monge
# Email : emonge@gbm.net
# Date : 10/06/2014
# Version: 0.1 Gamma "Hulk state"
# ---------------------------------------------------- #
device=""
warning=80
critical=90
was_warning=""
was_critical=""
function help {
echo "Usage"
echo "check_disk {-w limit -c limit -d device}"
echo "Options:"
echo "-h"
echo " Print detailed help screen"
echo "-w=INTEGER"
echo " Exit with WARNING status if more than INTEGER percentaje of utilization are used"
echo "-c=INTEGER"
echo " Exit with CRITICAL status if more than INTEGER percentaje of utilization are used"
echo "-d="
echo " Device without complete route"
echo " "
echo "Example:"
echo "check_disk_util -w 80 -c 90 -d sda1"
echo " Checks /dev/sda1 at 80% and 90% of disk utilization"
echo "check_disk_util -w 80 -c 90 -d sda"
echo " Checks /dev/sda1, /dev/sda2, /dev/sda3, etc (regular expression) at 80% and 90% of disk utilization"
exit 0
}
while getopts "w:c:d:h" args; do
case $args in
w) warning=$OPTARG
;;
c) critical=$OPTARG
;;
d) device=$OPTARG
;;
h) help
;;
esac
done
if [[ $critical -lt $warning ]];then
echo "UNKNOWN: Warning threshold must be lower than Critical threshold"
exit 4
fi
column_number=`iostat -x | grep -e "Device" | awk '{print NF}'`
iostat -x 1 2 |grep -e "$device" | awk -v column=$column_number '/sd|dm/ {print $1,$column}' > /tmp/disk_utili.tmp
radek=`cat /tmp/disk_utili.tmp | wc -l`
polovina=`echo "$radek / 2 "| bc`
cat /tmp/disk_utili.tmp | tail -n $polovina > /tmp/disk_utili1.tmp
while read line
do
device=`echo $line | awk '{print $1}'`
disk_util=`echo $line | awk '{print $2}' | cut -d "," -f1 `
if [ ${disk_util%.*} -ge $critical ];then
echo "CRITICAL: $device disk utilization $disk_util%"
was_critical=1
else if [ ${disk_util%.*} -ge $warning ];then
echo "WARNING: $device disk utilization $disk_util%"
was_warning=1
else echo "OK: $device disk utilization $disk_util%"
fi
fi
done