We had faced the Low disk space problem in our server. There were only 400 MB spaces on that time.All the person unknown about that, fortunately we was in the server and see the low disk space.We all must know about server's disk space, So we have created this VBS script.
Below steps need follow for getting server disk space and alert mail.
1)Save as xxxx.Vbs below code.
2)Put this file in server
3)Run Vbs file(double click file ) with admin rights
4)Mail will send to mentioned email id's
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
On Error Resume Next
Const HARD_DISK = 3
strStafileserver = ""
strStavmapp1 = ""
'enter company name below
strOutput = "<h2>Disk Space Report</h2> </br> </br>"
Dim Servers(9)
Servers(0) = "server1"
Servers(1) = "server2"
Servers(2) = "server3"
Servers(3) = "server4"
Servers(4) = "server5"
Servers(5) = "server6"
Servers(6) = "server7"
Servers(7) = "server8"
Servers(8) = "server9"
Servers(9) = "server10"
For Each serv in Servers
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & serv & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
strthstyle = "<th style = "&"background-color:#6699FF;"&">"
strLow = "<td style = "&"background-color:#CC0033;"&">"
strMed = "<td style = "&"background-color:#FF9900;"&">"
strHigh = "<td style = "&"background-color:#99FF66;"&">"
strOutput = strOutput&"<h3>"&serv&"<h3> </br>"
strHeader = "<table border="&"0"&"><tr>"&strthstyle&"Drive</th>"&strthstyle&"Free Space</th>"&strthstyle&"Total Space</th>"&strthstyle&"Precentage</th></tr>"
strOutput = strOutput&strHeader
For Each objDisk in colDisks
calc = int(objDisk.FreeSpace/1024/1024/1024)/int(objDisk.Size/1024/1024/1024) * 100
if calc < 11 then
strPercentage = strLow&int(calc)&" %</td></tr>"
elseif calc < 21 then
strPercentage = strMed&int(calc)&" %</td></tr>"
else
strPercentage = strHigh&int(calc)&" %</td></tr>"
End if
strTotalSpace = "<td>"&int(objDisk.Size/1024/1024/1024)&" GB</td>"
strFreeSpace = "<td>"&int(objDisk.FreeSpace/1024/1024/1024)&" GB</td>"
strDevice = "<tr><td>"& objDisk.DeviceID &"</td>"
strOutput = strOutput&strDevice&strFreeSpace&strTotalSpace&StrPercentage
Next
strOutput = strOutput&"</table></br></br>"
Next
'The below then mails size
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Todays Disk Space"
objMessage.From = ""
objMessage.To = ""
objMessage.HTMLBody = strOutput
'This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'objMessage.Bcc = ""
objMessage.Cc = ""
objMessage.Send
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
We will get report like below.
Server IP
Drive | Free Space | Total Space | Precentage |
C: | 3 GB | 16 GB | 18 % |
D: | 3 GB | 19 GB | 15 % |
Server IP
Drive | Free Space | Total Space | Precentage |
C: | 4 GB | 16 GB | 25 % |
D: | 3 GB | 20 GB | 15 % |
Server IP
Drive | Free Space | Total Space | Precentage |
C: | 3 GB | 16 GB | 18 % |
D: | 3 GB | 20 GB | 15 % |
Server IP
Drive | Free Space | Total Space | Precentage |
C: | 3 GB | 16 GB | 18 % |
D: | 3 GB | 20 GB | 15 % |
Hello, the whole thing is going perfectly here and of course every one is sharing information, that’s truly good, keep up writing.
ReplyDeleteipod service center in Chennai | Authorized ipod service center in Chennai | ipad service center in chennai | ipod service center in chennai | ipad service center in chennai | apple service center in chennai | iphone unlocking service | Laptop service center in chennai