; Note: comment lines in .INI files always start with a semicolon [Template] Description=Use this template to create a job that will monitor free space on your file servers and/or any other remote computers with shares. The job will send an email alert if the amount of free disk space falls bellow specified threshold. [Variables] ; Key values that have their name enclosed in % signs will be used for ; template wizard questionnaire and substitution variables. ; Each key value must contain the following 2 parts separated by comma: ; 1. Field Edit Style (EDIT, YES/NO, FILE BROWSE, ; DIR BROWSE, PROCESS BROWSE, ; FTP BROWSE, MAIL PROFILE LIST, ; REMOTE FILE BROWSE, REMOTE DIR BROWSE, ; REMOTE AGENT LIST, DB PROFILE LIST) ; 2. Prompt ; ; Example: %VAR%=EDIT,What is the name of the service that you want to monitor? ; ; Key values that don't have their name enclosed in % signs will be used for ; job properties (See online help on "Job property names for use with JDL commands" ; topic for more details). ; ; Example: DAY_NUMBER=1 %VOLUME_LIST%=EDIT,Enter comma-separated list of volumes and shares that you want to check.Each volume must specified in \\server\volume format: %THRESHOLD%=EDIT,Enter threshold value for free disk space (Mbytes): %RECIPIENT%=EDIT,To whom do you want to sent the email alert when the amount of free disk space falls bellow threshold value? %EMAIL_PROFILE%=MAIL PROFILE LIST,If you use MAPI email interface, then which email profile do you want to use? If you use Lotus Notes or SMTP email interfaces, enter User ID required for logging to your email system. %EMAIL_PASSWORD%=EDIT,If you are required to login to your email system, what is your password? JOB_TYPE=S SCRIPT_TYPE=VBS LOG=N ASYNC=N DISABLE_ON_ERROR=N SCHEDULE_TYPE=T INTERVAL=0:30 DESCRIPTION=Every 30 minutes this job checks the amount of free disk space on file server volumes. If it falls bellow specified threshold, the job sends email notification to the system administrator. ; Notes: The script bellow can include substitution variables. ; Substitution variables must be specified in %VAR% format ; where VAR is the variable name. ; ; Everything after the next line will be used for the template script. ;======================================================================================== [Body] Sub Main() Dim WshNetwork, DriveLetter, RemotePath, FileSys, list, d, s, pos ' use T as a temp drive, use a different letter if T is already in use DriveLetter = "T:" list = "%VOLUME_LIST%" Set WshNetwork = CreateObject("WScript.Network") ' parse volume list and process each volume one-by-one Set FileSys = CreateObject("Scripting.FileSystemObject") Do While list <> "" ' get path; each item should be in \\my_server\my_volume format pos = InStr(list, ",") if pos = 0 then pos = Len(list) + 1 RemotePath = Trim(Left(list, pos - 1)) list = mid(list, pos + 1) ' map network drive WShNetwork.MapNetworkDrive DriveLetter, RemotePath ' get space usage Set d = FileSys.GetDrive(DriveLetter) ' notify admin if free space has fallen below %THRESHOLD% MBytes If d.FreeSpace/1024/1024 < %THRESHOLD% Then s = "Volume: " & d.VolumeName & " (" & RemotePath & ")" & vbCrLf & _ "Available Space To User: " & FormatNumber(d.AvailableSpace/1024/1024, 0) & " Mbytes" & vbCrLf & _ "Free Space: " & FormatNumber(d.FreeSpace/1024/1024, 0) & " Mbytes" & vbCrLf & _ "Total Size: " & FormatNumber(d.TotalSize/1024/1024, 0) & " Mbytes" & vbCrLf & _ "Percent Free: " & FormatNumber(d.FreeSpace/d.TotalSize*100, 0) & "%" JALScript.Execute("MailSend ""%EMAIL_PROFILE%"", ""%EMAIL_PASSWORD%"", ""%RECIPIENT%"", " & _ " ""Low free space warning"", " & _ " ""Free space on volume " & RemotePath & _ " dropped below %THRESHOLD% MBytes." & vbCrLf & _ vbCrLf & s & " "" ") End If ' remove mapping WShNetwork.RemoveNetworkDrive DriveLetter Loop ' free resources Set d = Nothing Set FileSys = Nothing Set WshNetwork = Nothing End Sub