I once came across a scenario where we had an overnight Essbase process running and then there was very low disk space on the server and the process got hung.
Users were trying to login to the server and was not able to….and then we had to kill the process and restart Essbase server.
So I added a small function to my overnight process where it’ll check for disk space and will mail the UNIX admin if there is low disk space.
check_diskspace()
{
df -g /hyperion | awk ‘{print $4}’ > diskspaceenv1.txt
df -g /hyperion > diskspace.txt
sed ‘1d
s/%//g;
s/^[ t]*//;’ diskspaceenv1.txt > diskspaceenv.txt
actualfreesize=`cat diskspaceenv.txt`
allowedsize=25
if [ $allowedsize-ge $actualfreesize ] ; then
echo “* Not Enough Disk Space on Essbase Server. Can’t Continue process…”
(echo “`cat /mail/PMS_disk_error.txt`”; uuencode uuencode /scripts/diskspace.txt DiskSpaceinfo.txt) | mailx -s “Prod Env – Low Disk Space on Essbase Server” user@example.com user2@example.com
exit
else
echo “* Enough Disk Space on Essbase Server. Continue process…”
fi
}
Explanation
creating file diskspaceenv1.txt
I’m checking the free space information (using df -g)
By using awk and print I’m creating a file, which will be used to create a variable later …(you need to check the command on your server…sometimes the information in 4th place can be something else)
creating file diskspace.txt
This file is used for sending the disk space information to Administrators.
creating file diskspaceenv.txt
I’m using sed commands to delete 1st line and the leading, trailing white spaces to create a file diskspaceenv.txt (this file will help in creating a variable). Imagine if the free space is 45 Gb. now diskspaceenv.txt will have 45
$ cat diskspaceenv.txt
45
creating variables
I’m creating two variables called actualfreesize and allowedsize. I’ve kept allowedsize as 25 (Gb).
$ echo
allowedsize
25
$ echo
actualfreesize
45
If the allowedsize is greater than or equal to the actualfreesize the program will send a mail to the Admins and will abort…..else it’ll continue with the process.
This function is called at the beginning of the script.
This is a Unix script….