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 %
LVL 5
Naranthiran DSystem AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
you can parse the output of df and convert it to html.
Shiju JacobInfo Security ManagerCommented:
below is a script which mail if crosses 90 %




#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  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%" shiju@dot.com
  fi
done
arnoldCommented:
Are the systems in the same location, you can configure SNMP, snmptrapd with notifications.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Owen RubinConsultantCommented:
From the following website: https://www.linuxjournal.com/content/tech-tip-send-email-alert-when-your-disk-space-gets-low

#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90

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

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

@daily ~/sample.sh

I think this is basically what Shiju Jacob has said with a suttle difference
Robert LemMrCommented:
Have you thought about using webmin? Free software that can give you all information you need about all your servers on your network
Prabhin MPEngineer-TechOPSCommented:
HI,
First create a awk script with following contents,

vi script.awk

BEGIN {
    print "<html><body><table  border=\"8\" cellpadding=\"3\"  style=\"border-collapse: collapse\">"

    print "<tr>"
    print "<th bgcolor=turquoise colspan="6">BEFORE_USAGE</th>"
    print "</tr>"
    print "<tr>"
    print "<th bgcolor=gray>MOUNT</th>"
    print "<th bgcolor=gray>SIZE</th>"
    print "<th bgcolor=gray>USED</th>"
    print "<th bgcolor=gray>AVAILABLE</th>"
    print "<th bgcolor=gray>USE%</th>"
    print "</tr>"
}

NR > 1 {
    bgcolor=""
    if ($5+0 > 70) {
        bgcolor=" bgcolor=azure"
    }
    print "<tr><td>"$6"</td><td>"$2"</td><td>"$3"</td><td>"$4"</td><td"bgcolor">"$5"</td></tr>"
}

END {
    print "</table></body></html>"
}



Then use the command to extract the output to html file,

df -Ph | awk -f aa.awk > disk_usage.html

here is the sample output.

and you can attach this file with email .
Screenshot-at-2018-10-14-08-50-50.png

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Naranthiran DSystem AdministratorAuthor Commented:
Thanks Prabhin ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.