Link to home
Start Free TrialLog in
Avatar of Naranthiran D
Naranthiran DFlag for India

asked on

Linux Disk space

Need a script to Monitor disk space alert in Linux servers.

I need to run the script for one server and collect the results(HTML Out Put with colour ) of all the server and created a consolidated report with the below columns

Server IP Volume name volume %
Avatar of noci

you can parse the output of df and convert it to html.
below is a script which mail if crosses 90 %

df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
  echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge 90]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail -s "Alert: Almost out of disk space $usep%"
Are the systems in the same location, you can configure SNMP, snmptrapd with notifications.
From the following website:

CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s 'Disk Space Alert' << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%

To run it daily, for example, save the script to the file in your home directory, change the email to your email, and add the following line at the end of /etc/crontab file:

@daily ~/

I think this is basically what Shiju Jacob has said with a suttle difference
Have you thought about using webmin? Free software that can give you all information you need about all your servers on your network
Avatar of Prabhin MP
Prabhin MP
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Naranthiran D


Thanks Prabhin ;)