Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Need to check the disk space and if any portion disk space usage high then write to one file, later will check that file and inform thorough send mail.
- Relevant commands, code, scripts, algorithms:
#MSM2 Disk Check
DIR=/home/mform/healthcheck
rm $DIR/disk.txt
df -h > $DIR/_tmp5
for i in 2 3 4 5 6 7 8 9
do
cat $DIR/_tmp5 | grep -v capacity | awk '{print $5}' | sed 's/%//g' >> $DIR/_tmp6
else
cat $DIR/_tmp5 | grep -v capacity | awk '{print $4}' | sed 's/%//g' >> $DIR/_tmp6
done
touch $DIR/_tmp7
for i in `cat $DIR/_tmp6`
do
if [ $i -ge 75 ];then
grep $i $DIR/_tmp5 >> $DIR/_tmp7
fi
done
chk=`cat $DIR/_tmp7 | wc -l`
if [ $chk -ne 0 ]; then
out=`cat $DIR/_tmp7`
echo "Please check the following disk usage" `cat $DIR/_tmp7` > $DIR/disk.txt
else
echo "MSM disk usage is fine" > $DIR/disk.txt
fi
#rm $DIR/_tmp*
#sh $DIR/top_check.sh
MSMAPP1:/home/mform/healthcheck $
-
The attempts at a solution (include all code and scripts):
Presend disk usage is below
MSMAPP1:/home/mform/healthcheck $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.5G 940M 8.1G 11% /
/dev/sda9 189G 18G 162G 10% /data
/dev/sda8 9.5G 2.4G 6.7G 27% /usr
/dev/sda7 15G 553M 13G 5% /var
/dev/sda6 15G 165M 14G 2% /tmp
/dev/sda3 19G 13G 5.7G 69% /home
/dev/sda1 289M 17M 258M 6% /boot
tmpfs 7.9G 0 7.9G 0% /dev/shm
10.50.11.86:/export/msmshare
14T 220M 14T 1% /msmshare
10.50.11.86:/export/backup
2.0T 43G 2.0T 3% /Backup -
Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).