Hi folks, below you will find and shell script to monitor usage percentage of a filesystem, you can schedule at Schedule Job or OS Crontab
You can custom percentage (I use 85 %), FS List, email recipient, schedule time
The schedule can be:
43 20 * * * /home/oracle/work/tamafs.sh ctgorap2 > /dev/null
the body script is:
#!/bin/bash
export PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin:/usr/sbin:$PATH
export SCRIPT_DIR=/home/oracle/work/scripts
export LOG_DIR=/home/oracle/work/log
CURR_DATE=`date '+%m/%d/%y_%H:%M'`
if [ -e ${LOG_DIR}/FS_Sync_status.txt ]
then
`rm ${LOG_DIR}/FS_Sync_status.txt `
fi
if [ -e ${LOG_DIR}/FS_Sync_output.log ]
then
`rm ${LOG_DIR}/FS_Sync_output.log `
fi
for i in `ssh $1 df -h|awk '{ print $6 }'`
do
# Convert the file size to a numeric value
text="Mounted"
if [ "$i" = $text ] ;
then
text="Mounted"
else
for y in `ssh $1 df -h $i | awk '{ print $5 }'`
do
texto="Use%"
if [ "$y" = $texto ] ;
then
text="Mounted"
else
filesize="${y//%}"
# If any filesystem has less than 100k, issue an alert
if [ $filesize -gt 85 ];
then
html_head="Subject: FS Check REPORT Hostname $1 for ${CURR_DATE}
\nMIME-Version: 1.0 \nContent-Type: text/html \nContent-Disposition: inline \n
<html>
<head>
<meta http-equiv=\"Content-Type\" content=text/html;
charset=\"UTF-8\">
<meta name=\"generator\" content=\"SQL*Plus 11.2.0\">
<style type=\"text/css\">
body {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
p {font:10pt Arial,Helvetica,sans-serif;
color:black; background:White;}
table,tr,td {font:10pt Arial,Helvetica,sans-serif;
color:Black; background:#f7f7e7;
padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;}
th {font:bold 10pt Arial,Helvetica,sans-serif;
color:#336699; background:#cccc99; padding:0px 0px 0px 0px;}
h1 {font:13pt Arial,Helvetica,Geneva,sans-serif;
color:#336699;text-decoration:underline;background-color:White;
border-bottom:1px solid #cccc99;
margin-top:0pt; margin-bottom:0pt;
padding:0px 0px 0px 0px;}
h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;
color:#336699; background-color:White;
margin-top:4pt; margin-bottom:0pt;}
a {font:9pt Arial,Helvetica,sans-serif;
color:#663300; background:#ffffff;
margin-top:0pt; margin-bottom:0pt; vertical-align:top;}
</style>
<title>
FS SYNC STATUS REPORT ${CURR_DATE}
</title>
</head>"
html_tail='<br><a><br>
<br> </a></body></html>'
salida="FileSystem $i esta demasiado lleno: $y Usado"
echo -e $html_head > ${LOG_DIR}/FS_REPORT.html
echo -e $salida >> ${LOG_DIR}/FS_REPORT.html
echo $html_tail >> ${LOG_DIR}/FS_REPORT.html
sendmail -v EMAIL@DOMAIN.com < ${LOG_DIR}/FS_REPORT.html
fi
fi
done
fi
done
Regards