| | | Forum Newbie
       
Group: Forum Members Last Login: 7/16/2008 12:18:06 PM Posts: 4, Visits: 20 |
| | Yes, the Disk Utilization performance monitor is enabled and I can see data in the report. Also, we are running version 11. |
| | | | Time Traveler
       
Group: Forum Members Last Login: 10/6/2008 10:25:48 AM Posts: 534, Visits: 1,880 |
| | Could you post the script you're using ? |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 7/16/2008 12:18:06 PM Posts: 4, Visits: 20 |
| ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' This script is a merge of 2 scripts. Credits go to :
' - XXXXX's , which use the performance monitors values to test the disk space, and most code for this script.
' - YYYYYY's, which retrieve the thresholds from a specified attribute
' I added the feature that, if the given attribute is not set, you can use a default value for all disks.
' Also, specifying a threshold of 0 disables the check on that disk. You must always specify the unit (%, G or M), even when disabling the check.
' Format for the thresholds are something like this : 'C:\=10%;D:\=5G;E:\=650M;G:\=0%'
' THE DRIVE NAME IN THE ATTRIBUTE MUST BE THE SAME AS THE ONE RETURNED BY THE DISK PERF MONITOR. (e.g. for Windows : C:\, D:\, and so on...)
' You can see see the name of each drive by using the Test button and scanning the result.
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Name of the attribute which will contain the specific thresholds
THRESHOLDS_ATTRIBUTE = "Disk_Space_Thresholds"
' Name of the attribute which will contain the result of the check. Automatically created.
RESULT_ATTRIBUTE = "Disk_Space_Results"
' If the threshold attribute is not found, should the monitor report as DOWN ?
' If set to False, it will use the default value for all disks.
DOWN_NO_ATTRIBUTE = true
' If there are no recent performance entries for at least one device, should the monitor report as DOWN ? - NOT IMPLEMENTED
DOWN_ON_AGED_VALUES = true
' MAX_AGE value specify the maximum age for entries, in seconds - NOT IMPLEMENTED
MAX_ENTRIES_AGE = 3600
' Default value to be used, in percentage. We monitor the FREE SPACE, which must not go below the threshold.
' 1- when the attribute doesn't specify the threshold for a given disk
' 2- for all disks if there is no attribute AND DOWN_NO_ATTRIBUTE = True
' If set to 0, not specified disks will not be checked.
DEFAULT_THRESHOLD = 10
' Unit of default threshold - THIS IS NOT A DEFAULT UNIT FOR SPECIFIED THRESHOLDS
' "%" = percentage
' "G" = gigabyte
' "M" = megabyte
DEFAULT_THRESHOLD_UNIT = "%"
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Set the result code of the check (0=Success, 1=Error)
Context.SetResult 0, "No error"
bAlarm = false
' Retrieve DB object
Set oDb = Context.GetDB
If IsNull(oDb) Then
Context.SetResult 1, "Could not create DB object"
Else
' Fetch deviceID
nDeviceID = Context.GetProperty ("DeviceID")
' Get the attribute which contains the specific value.
sqlGetDS = "select sValue from DeviceAttribute where (nDeviceID = " & nDeviceID & ") and (sName = '" & THRESHOLDS_ATTRIBUTE & "')"
Set oRs1 = oDb.Execute(sqlGetDS)
' We report a DOWN if no attribute and script is configured as such.
If DOWN_NO_ATTRIBUTE and oRs1.EOF Then
Context.SetResult 1, "This monitor needs a attribute named " & THRESHOLDS_ATTRIBUTE & " to work."
Else
drvMonitors = null
If Not oRs1.EOF Then
oRs1.moveFirst
drvMonitors = split(oRs1("sValue"),";")
End If
' SQL request. We ask SQL to compute the value we want itself : it return the remaining percentage, megabytes and gigabytes on each disk.
sSql = "SELECT SDI.sDescription, SD.dPollTime, D.sDisplayName, (1 - SD.nUsed_Avg / SD.nSize) * 100 AS perc, (SD.nSize - SD.nUsed_Avg) / 1073741824 AS giga, (SD.nSize - SD.nUsed_Avg) / 1048576 AS mega FROM Device AS D INNER JOIN PivotStatisticalMonitorTypeToDevice AS PSM ON PSM.nDeviceID = D.nDeviceID INNER JOIN StatisticalDiskIdentification AS SDI ON SDI.nPivotStatisticalMonitorTypeToDeviceID = PSM.nPivotStatisticalMonitorTypeToDeviceID INNER JOIN StatisticalDisk AS SD ON SD.nStatisticalDiskIdentificationID = SDI.nStatisticalDiskIdentificationID WHERE D.nDeviceID = '" & nDeviceID & "' AND SD.dPollTime = (SELECT top 1 SD.dPollTime FROM Device AS D INNER JOIN PivotStatisticalMonitorTypeToDevice AS PSM ON PSM.nDeviceID = D.nDeviceID INNER JOIN StatisticalDiskIdentification AS SDI ON SDI.nPivotStatisticalMonitorTypeToDeviceID = PSM.nPivotStatisticalMonitorTypeToDeviceID INNER JOIN StatisticalDisk AS SD ON SD.nStatisticalDiskIdentificationID = SDI.nStatisticalDiskIdentificationID WHERE D.nDeviceID = '" & nDeviceID & "' ORDER BY SD.dPollTime DESC) ORDER BY SDI.sDescription"
Set oRs2 = oDb.Execute(sSql)
oRs2.moveFirst
While Not oRs2.EOF
' First we check if the last polled value is a recent one, if that check is enabled
' TODO
displayName = oRs2("sDisplayName")
description = ucase(oRs2("sDescription"))
'Default value
drvMonitorLimit = DEFAULT_THRESHOLD
drvMonitorUnit = DEFAULT_THRESHOLD_UNIT
' We retrieve the threshold from the attribute, if it exists.
If Not IsNull(drvMonitors) Then
For each drvMonitor in drvMonitors
'Is it a matching threshold ?
tokens = split(drvMonitor, "=")
If tokens(0) = description Then
' We then retrieve the threshold value AND the unit. The unit MUST be specified.
' Correct format is "100M", "10%", "4G" for example.
drvMonitorUnit = ucase(Right(tokens(1),1))
drvMonitorLimit = int(Left(tokens(1),len(tokens(1))-1))
Exit For
End If
Next
End If
Select Case drvMonitorUnit
Case "%"
value = int(oRs2("10"))
Case "G"
value = int(oRs2("giga"))
Case "M"
value = int(oRs2("mega"))
Case Else
' Invalid unit, we will report a Down.
value = -1
End Select
' If unit is invalid, it' a down.
If value = -1 Then
bAlarm = true
oChecksResult = oChecksResult & "Disk " & description & " : threshold unit is invalid (" & drvMonitorUnit & "). You MUST specify %, G or M as a threshold unit (example : C=10%;D=5G;E=650M)" & vbCrLf
Else
' If unit is valid, but threshold is zero, we don't check.
If drvMonitorLimit = 0 Then
oChecksResult = oChecksResult & "Disk " & description & " : " & Round(value) & drvMonitorUnit & _
" remaining space - not checked because threshold is zero." & vbCrLf
Else
' Else we check.
If value < drvMonitorLimit Then
bAlarm = true
oChecksResult = oChecksResult & "Disk " & description & " : " & Round(value) & drvMonitorUnit & _
" remaining space is below threshold (" & drvMonitorLimit & drvMonitorUnit & ") - DOWN !!" & vbCrLf
Else
oChecksResult = oChecksResult & "Disk " & description & " : " & Round(value) & drvMonitorUnit & _
" remaining space is above threshold (" & drvMonitorLimit & drvMonitorUnit & ") - UP" & vbCrLf
End If
End If
End If
oRs2.moveNext
Wend
' Store the result in an attribute. Allows to access details even on a Device-configured action by using the %Device.Attribute.* variable.
' Formatting it to a SQL compatible format.
if (Right(oChecksResult,1) = vbCrLf) Then
oChecksResultSQL = Replace(Left(oChecksResult,len(oChecksResult)-1), vbCrLf, "' + CHAR(10) + N'")
Else
oChecksResultSQL = Replace(oChecksResult, vbCrLf, "' + CHAR(10) + N'")
End If
' Checking if the attribute already exists. If not we create one, if yes we simply update it.
sqlCheck = "SELECT nDeviceAttributeID FROM DeviceAttribute WHERE (nDeviceID = " & nDeviceID & ") AND (sName = N'" & RESULT_ATTRIBUTE & "')"
Set oRs1 = oDb.Execute(sqlCheck)
' Storing it in DB as needed.
If oRs1.EOF Then
sqlStoreResult = "INSERT INTO DeviceAttribute (nDeviceID, sName, sValue) VALUES (" & _
nDeviceID & ", N'" & RESULT_ATTRIBUTE & "', N'" & oChecksResultSQL & "')"
Else
sqlStoreResult = "UPDATE DeviceAttribute SET sValue = N'" & oChecksResultSQL & _
"' WHERE (nDeviceID = " & nDeviceID & ") AND (sName = N'" & RESULT_ATTRIBUTE & "')"
End If
oDb.Execute(sqlStoreResult)
' Set the result of the monitor.
If bAlarm Then
oChecksResult = oChecksResult & vbCrLf & "Monitor is DOWN"
Context.SetResult 1, oChecksResult
Else
oChecksResult = oChecksResult & vbCrLf & "Monitor is UP"
Context.SetResult 0, oChecksResult
End If
End If
End If
' Cleanup code
Set oDb = Nothing
Set oRs2 = Nothing
Set oRs1 = Nothing |
| | | | Time Traveler
       
Group: Forum Members Last Login: 10/6/2008 10:25:48 AM Posts: 534, Visits: 1,880 |
| Do you have several devices with the same IP address, by any chance ?
Does the script work on some devices, or none at all ? |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 7/16/2008 12:18:06 PM Posts: 4, Visits: 20 |
| | I am getting the same error message on each server i try. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 9/26/2008 6:43:23 PM Posts: 1, Visits: 25 |
| | Hi MB-NS, thanks for the script, it works on all the Win2k/2k3 servers except one Win2k server. I'm getting this error during the Active Script Monitor Test: Error: Source:'Microsoft OLE DB Provider for ODBC Drivers' Line:76 Char:2 Error:0 '[Microsoft][ODBC SQL Server Driver][SQL Server]Divide by zero error encountered.' -v (null)
FYI:I'm running WUG Ver. 11 Disk utilization perfmon is enabled but I can't get any results in the reports. So does this error mean there are some kind of problem with the WMI? Thanks in advance, Tony |
| | | | Time Traveler
       
Group: Forum Members Last Login: 10/6/2008 10:25:48 AM Posts: 534, Visits: 1,880 |
| nickcarbone (5/28/2008) I am getting the same error message on each server i try.
Then I really don't know. Do you have access to a SQL Enterprise Manager ?
If yes, then try to run the SQL query directly using this tool, to see what you get.
Hi MB-NS, thanks for the script, it works on all the Win2k/2k3 servers except one Win2k server.
I'm getting this error during the Active Script Monitor Test:
Error: Source:'Microsoft OLE DB Provider for ODBC Drivers'
Line:76 Char:2
Error:0 '[Microsoft][ODBC SQL Server Driver][SQL Server]Divide by zero error encountered.'
-v
(null)
FYI:I'm running WUG Ver. 11
Disk utilization perfmon is enabled but I can't get any results in the reports.
So does this error mean there are some kind of problem with the WMI?
Thanks in advance,
Tony
It does not use WMI at all, but only SNMP.
Please check that :
1- SNMP credentials are set on the device.
2- the SNMP is installed, running and configured with the correct community (these settings are on the service settings, in the services.msc snapin), and also that the WUG IP is allowed (same place). |
| | | | 
Forum Member
       
Group: Forum Members Last Login: 10/8/2008 6:00:35 PM Posts: 30, Visits: 114 |
| MB - NS (2/8/2008)
There are some scripts around which use directly the values retrieved by the Disk Utilization perf monitors.
The one I wrote also allows you to specify the thresholds using the device attributes (enclosed in this post). This way you avoid having multiple monitors depending on the letters and thresholds you need. Please note that you need to have 'disk Utilization' enabled and working on the device.
This script is WONDERFUL, and saved my ***. 
-... |
| | | |
|