unable to make modifications to fit into my enviroment, this is the check_disc function, but not working correctly in my enviroment where disc is attached through /dev/mapper/ so i have
for exmaple /dev/mapper/debian-var instead of /var.
Function from BASH script:
function check_disks {
THOLD=$1;
DISK_ERROR="";
# df -kl is the most portable options for df
MOUNTS=`df -lk | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`;
for MOUNT in $MOUNTS; do
PERCENT=`df -kl $MOUNT | grep -v Filesystem | awk '{print $5}' | sed 's/\%//'`;
if [ $PERCENT -gt $THOLD ]; then
DISK_ERROR="$DISK_ERROR Volume '$MOUNT' is at $PERCENT% usage.\n";
fi
done
if [ -n "$DISK_ERROR" ]; then
echo -en "ERROR: The following volumes have exceeded the allowable threshold of $THOLD% usage.\n$DISK_ERROR";
return 1;
else
return 0;
fi
}
Output of df -kl cmd:
df -kl
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/debian-root
1919048 493616 1327948 28% /
tmpfs 18717148 12 18717136 1% /lib/init/rw
udev 10240 784 9456 8% /dev
tmpfs 18717148 0 18717148 0% /dev/shm
/dev/cciss/c0d0p1 241116 23679 204989 11% /boot
/dev/mapper/debian-home
3842104 2681264 965668 74% /home
/dev/mapper/debian-tmp
4805760 366228 4195412 9% /tmp
/dev/mapper/debian-usr
3842104 1816200 1830732 50% /usr
/dev/mapper/debian-var
377857560 183429768 175233732 52% /var
This line should be changed i guess:
MOUNTS=`df -lk | grep -v devfs | grep -v none | grep -v Filesystem | awk '{print $6}'`;
But not sure how. Anyone can give me a hand?
Thx
There is a portability option on
dfthat keeps the output in one line per volume :I think changing
to
would help.
FYI, here is an example of the output difference :