Feedback

type to search

How to Be Warned if / is About to Be 100% Full?

Asked by

How to Be Warned if / is About to Be 100% Full?

NN comments
evgeni
-

In which environment? Dekstop with GNOME, KDE, Xfce, LXDE, somethingdifferent? Or a server? What kind of warning do you like? A popup on the desktop? Or a mail?

or Cancel

3 answers

3

lehel [ Editor ]

Hello,

You can also use nagios for that.

Cheers,

NN comments
harryxxx
-

Hey.. Thanks but I get this:

No candidate version found for nagios
No candidate version found for nagios No packages will be installed, upgraded, or removed. 0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B of archives. After unpacking 0 B will be used.

??

lehel
-
try nagios3 please. nagios3 – A host/service/network monitoring and management system

apt-get install nagios3

if you have any other questions just reply!

or Cancel
1

amlj [ Editor ]

EDIT: Get the file here


There are many ways… For example, you can add this to your /etc/bash.bashrc file… Or create a command (Put these in a file, and after that, copy that to on of the directories in $PATH, which you can check those using ‘echo $PATH command).
I wrote this script, sometime ago (In an exam):

#!/bin/bash
#This script will send a warning to the administrator if 80% or more of the / is
used.
#By Adel Moin (AMLJ)
# $FSTDIG is the first digit of the amount of the partition which is used.
# $SECDIG is the second digit of the amount of the partition, which is used, if it’s ’%‘, then only a little amount of the partition is used, so there is no need to warn the user. Otherwise, more than 80% of the partition is used, and the user has to be warned.
# If $FULL is '100’, the partition is totally full, and the user needs to be worried.
# In case $ALARM is ‘true’, the warning mail will be sent.
FSTDIG=df -P / |tail -n1 |awk '{ print $5 }' |cut -b1
SECDIG=df -P / |tail -n1 |awk '{ print $5 }' |rev |cut -b1
FULL=df -P / |tail -n1 |awk '{ print $5 }'
if [ $FSTDIG == 8 ] && [ x$SECDIG != x'%‘ ]
then
ALARM=true
fi
if [ $FSTDIG == 9 ] && [ x$SECDIG != x’%‘ ]
then
ALARM=true
fi
if [ $FULL == 100 ]
then
ALARM=true
fi
if [ ’$ALARM' == ‘true’ ]
then
echo ‘80% or more of the / is used!’ |mail -s ‘WARNING!’ root
fi

exit 0



That will send a mail to root… You can add this if you want a message printed:

#!/bin/bash
#This script will print a message if more than 80% of / is full.
#By Adel Moin (AMLJ)
# $FSTDIG is the first digit of the amount of the partition which is used.
# $SECDIG is the second digit of the amount of the partition, which is used, if it’s ‘%’, then only a little amount of the partition is used, so there is no need to warn the user. Otherwise, more than 80% of the partition is used, and the user has to be warned.
# If $FULL is ‘100’, the partition is totally full, and the user needs to be worried.
# In case $ALARM is ‘true’, the warning mail will be sent.
FSTDIG=df -P / |tail -n1 |awk '{ print $5 }' |cut -b1
SECDIG=df -P / |tail -n1 |awk '{ print $5 }' |rev |cut -b1
FULL=df -P / |tail -n1 |awk '{ print $5 }'
if [ $FSTDIG == 8 ] && [ x$SECDIG != x'%‘ ]
then
ALARM=true
fi
if [ $FSTDIG == 9 ] && [ x$SECDIG != x’%‘ ]
then
ALARM=true
fi
if [ $FULL == 100 ]
then
ALARM=true
fi
if [ ’$ALARM' == ‘true’ ]
then
echo -en ‘\E[47;31m’“\033[1mMore than 80% of / is full\033[0m”
fi

exit 0



The script is a bit noobish, as I wrote it when I was kinda a noob! :)
But it’ll work….

Let me know if it had any probs… (Had to edit it… Also, the copy-paste made it a bit ruined, so although I tried to make it better, there might be still problems)

NN comments
harryxxx
-

Thanks… The file worked… Will see other solutions too and decide what to do in the long run… If what lehel mentioned (Nagios) works, it’d be good too…

Thanks

or Cancel

Your answer

You need to join Debian to complete this action, click here to do so.