@echo off :***************************************** : set environment variables :***************************************** set working_path=\\filer\c$\etc\scripts set summary_report=\\filer\c$\etc\scripts\summary_report.txt set percentage_used_file=\\filer\c$\etc\scripts\temp\percentage_used_file.txt : The following 3 variable are passed from the main batch file (quota.bat) set department=%1 set /a disk_usage=%2 set /a disk_available=%3 : Set Warning and Critical variable for triggers set /a ThreshWarn=75 set /a ThreshCritical=90 : Set the Distribution list for E-Mail Notification set DIST_LIST=first.last@company.com,You@mail.com :***************************************** : Perform Calculation to determine : Percentage of Available Disk Space Used : : Send output to a file (percentage_used.txt) :***************************************** %working_path%\eval %disk_usage%/%disk_available%*100 > %percentage_used_file% :***************************************** : Read in the Percentage from file : strip off the decimal point and everything after :***************************************** for /F "eol= tokens=1 delims=." %%i in (%percentage_used_file%) do set percentage_used=%%i :***************************************** : Write the information to a Report File (%summary_report%) :***************************************** @echo Department: %department% >> %summary_report% @echo Disk Allocation: %disk_available% >> %summary_report% @echo Disk Allocation Used: %disk_usage% >> %summary_report% @echo Percentage of Space Available Used: %percentage_used% >> %summary_report% @echo. >> %summary_report% :***************************************** : Check to see if percentage_used variable : is greater then %ThreshWarn% or %ThreshCritical% Variables :***************************************** if %percentage_used% GEQ %ThreshCritical% goto SendCritical if %percentage_used% GEQ %ThreshWarn% goto SendWarn goto the_end :***************************************** : Warning Notification :***************************************** : SendWarn if exist %working_path%\temp\%department%.wrn goto the_end : You must replace X.X.X.X with your mail servers IP Address. %working_path%\blat.exe %working_path%\blat.exe -to %dist_list% -f Storage.Allocation@yourcompany.com -subject "WARNING - Storage Allocation on Filer %department% QTREE" -server X.X.X.X -body "The %department% QTREE on Filer is currently using %percentage_used% percent of available disk allocation. Contact the IT Representative for this Department and inform them. For a summary of the processing results please view the following file: %summary_report% Please Note: The Storage.Allocation ID has out-going mail capabilities only and can't receive any incoming e-mail." -q echo Warning Sent > %working_path%\temp\%department%.wrn goto the_end :***************************************** : Critical Notification :***************************************** : SendCritical : You must replace X.X.X.X with your mail servers IP Address. %working_path%\blat.exe %working_path%\blat.exe -to %dist_list% -f Storage.Allocation@yourcompany.com -subject "CRITICAL - Storage Allocation on Filer %department% QTREE" -server X.X.X.X -body "This is a CRITICAL Notification. The %department% QTREE on Filer is currently using %percentage_used% percent of available disk allocation. Contact the IT Representative for this Department and inform them. Monitor and add additional quota space to this QTREE if required. For a summary of the processing results please view the following file: %summary_report% Please Note: The Storage.Allocation ID has out-going mail capabilities only and can't receive any incoming e-mail." -q goto the_end :***************************************** : Exit Script :***************************************** : the_end