Server file space monitoring

  • Thread starter Thread starter laurie
  • Start date Start date
L

laurie

Hi.

Does anyone know of a simple asp script that can check free disk space and send an email to someone when low disk space occurs? I
am not familiar with asp. I am from a php background but our server doesn't support php only asp.

Thanks

Laurie
 
This much in ASP.NET will return the disk free space using VB.NET :

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Response.Write(free_space("c:\").ToString)
End Sub

<DllImport("Kernel32.dll")> _
Public Shared Function GetDiskFreeSpaceEx _
(ByVal lpszPath As String, _
ByRef lpFreeBytesAvailable As Long, _
ByRef lpTotalNumberOfBytes As Long, _
ByRef lpTotalNumberOfFreeBytes As Long) As Boolean
End Function

Public Function free_space _
(ByVal folder_name As String) As Long
Dim free As Long = 0
Dim dummy1 As Long = 0
Dim dummy2 As Long = 0

If GetDiskFreeSpaceEx _
(folder_name, free, dummy1, dummy2) Then
Return free
Else
Return -1
End If
End Function 'free_space

Ken
Microsoft MVP [ASP.NET]
 
Back
Top