Community discussions

MikroTik App
 
mpaluck
just joined
Topic Author
Posts: 6
Joined: Fri Apr 03, 2009 5:14 pm

Windows Disk Space Monitoring without SNMP

Fri Apr 03, 2009 5:33 pm

Is there someway to monitor Windows Disk Space with the Dude and not use SNMP? I really dont want to put snmp on all of our servers.

Thanks!
 
kennard
just joined
Posts: 1
Joined: Wed May 20, 2009 10:45 pm

Re: Windows Disk Space Monitoring without SNMP

Wed May 20, 2009 10:58 pm

Can a simple thing like this http://directorysize.moleskinsoft.com/d ... toring.php help you out? I used it to free up some disk space, but it's supposed to all this other stuff too. Good luck :)
 
mpaluck
just joined
Topic Author
Posts: 6
Joined: Fri Apr 03, 2009 5:14 pm

Re: Windows Disk Space Monitoring without SNMP

Thu May 21, 2009 7:17 pm

I got it working with VBS. The VBS Script is on the root of my Dude Server.

Basically the function calls the script and the script returns the percentage used of the most used disk. You can create different probes to look for different percentages.

I created a function WinMaxPrctDiskUsed
array_element(execute("cscript.exe",concatenate("c:\diskspace.vbs ",(device_property("Name"))," //nologo"),"c:\windows\system32"),"0")


Probe
Name:WinDiskAny>95%
Type:Function
Available:WinMaxPrctDiskUsed()>0
Error:if(WinMaxPrctDiskUsed()>95,"Low Disk Space","")
Value:WinMaxPrctDiskUsed()
Unit:%
Rate:None

VBS Start
' Sample code for monitoring windows disk space local or remote
'
' if no drive letter is give it will return the percentage of use of the the drive with the highest percentage.
' Can be used local or remote

Dim DriveLetter,PercentHigh,strComputer,args

'Set initial Values
DriveLetter = "None"
PercentHigh = 0
strComputer = "."

Set args = WScript.Arguments

'Check For Drive letter and computername Arguments
If Wscript.Arguments.Count = 0 Then 'No Args do nothing

Elseif Wscript.Arguments.Count = 1 Then 'Check to see if it is a computer name or Drive letter
If Len(args(0)) > 1 Then 'it must be a computer name
strComputer = Args(0)
Else
DriveLetter=ucase(args(0)) 'only the drive letter was given
End If

Elseif Wscript.Arguments.Count = 2 Then 'Check to see if it is a computer name or Drive letter
If Len(args(0)) > 1 Then
strComputer = Args(0)
DriveLetter=ucase(args(1))
Else
'Wscript.echo "The commandline argument must be a single drive letter or Computername and drive letter," & Vbcrlf & " ie C or Computer C."
wscript.quit
End If

Else
'Wscript.echo "The commandline argument must be a single drive letter or Computername and drive letter," & Vbcrlf & " ie C or Computer C."
wscript.quit
End If


'Check the disk space
PCT = "0"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select FreeSpace,Size,Name from Win32_LogicalDisk Where MediaType = 12"):

For Each objDisk In colDisks
If DriveLetter="None" Then 'search all drives and return the highest used percentage
If Not isnull(objDisk.Size) Then
Percentage = 100-round(100*(objDisk.FreeSpace/objDisk.Size),0)

If Percentage > PercentHigh Then
PercentHigh = Percentage
End If
End If 'Null Check
PCT=PercentHigh

Else
'Return Single Disk
If ucase(left(objDisk.Name,1)) = DriveLetter Then
PCT = 100-round(100*(objDisk.FreeSpace/objDisk.Size),0)
End If
'Return All Disks
If DriveLetter = "A" Then

If Not isnull(objDisk.Size) Then
str = str & "Disk " & left(objDisk.Name,1)& " " & 100-round(100*(objDisk.FreeSpace/objDisk.Size),0) & "% Used, " & round(objDisk.FreeSpace/1000000000,1)& " GB Free" & vbCrlf
End If
End If


End If

Next


If DriveLetter = "A" Then
wscript.echo str
Else
exitCode = int(PCT)
End If

Set DriveLetter = Nothing
Set PercentHigh = Nothing
Set strComputer = Nothing
Set args = Nothing
Set objWMIService = Nothing
Set colDisks = Nothing
Set objDisk = Nothing
wscript.Quit(exitCode)
VBS End


I did have problems with the Dude running as a service, for this to work I had to run Dude as an admin. I tried to tell the service to use Admin credentials but it kept running as System. When running as System it cannot do a remote WMI query to another server. I am using 2.2, going to upgrade to 3x but have not yet. 2.2 has been very stable.

I wish 3 had the Shadows and Outlines!

Who is online

Users browsing this forum: No registered users and 15 guests