YOU ARE HERE: HOMEWhatsUp Gold (WUG) and Hard drive failure monitor

WhatsUp Gold (WUG) and Hard drive failure monitor

A case one of the existing client is asking for whether can WUG monitoring Windows server hard drive in RAID, and reporting for failure status.

It will depend on the manufacturer, but in general the answer is yes. However, you may need a script similar to what we posted below. Otherwise, typically the systems send a SNMP trap. Make sure it is SNMP enable and monitoring device all is configured ready.

In typical scenario, WUG upon discovered the device hard drive  is look something similar like this.

Screenshot here is Windows server with RAID 5 configured will show as single device for up/down/utilization. Device down or disk % will able to schedule for alert notification, include email (need smtp setup) or sms (need SMS gateway or E-SPIN DirectSMS Hardware Module for WUG for direct trigger SMS thru telco mobile network) in the form of SMS notification just like email notification.

However, for customer depend on proactive hard drive failure and trigger email notification, then you may need additional step to running custom script like below section suggestion. Alternatively, from base on SNMP trap as the form of notification alert.

Example: HP Server Drive Status

This will pull back the status of all drives in an HP server drive array. Note that SNMP and HP Management Agents must be installed on the target system. A side note: you must load the cpqida.mib to WhatsUp Gold for this to work properly!

Option Explicit

 ‘*****Configuration*****

 Dim nSNMPTimeout : nSNMPTimeout = 3000 ‘Set ms for SNMP timeouts

 Dim nSNMPRetry : nSNMPRetry = 2 ‘Set the number of SNMP retries

 ‘***End Configuration***

 ‘Get Device details

 Dim nDeviceID : nDeviceID = Context.GetProperty(“DeviceID”)

 Dim sAddress : sAddress = Context.GetProperty(“Address”)

 ‘Create SNMP object

 Dim oSnmp : Set oSnmp = CreateObject(“CoreAsp.SnmpRqst”)

 Dim nTimeout : nTimeout = oSnmp.SetTimeoutMs(nSNMPTimeout)

 Dim nRetries : nRetries = oSnmp.SetNumRetries(nSNMPRetry)

 ‘Set script variables

 Dim bSNMPResult : bSNMPResult = 0

 Dim bFail : bFail = 0

 Dim bDown : bDown = 0

 Dim sErrorMsg : sErrorMsg = “”

 Dim sMsg : sMsg = “”

 Dim bVendor : bVendor = 0

 Dim sOid_Initial : sOid_Initial = “1.3.6.1.4.1.232.3.2.5.1.1.2”

 Dim sCpqDaPhyDrvIndex : sCpqDaPhyDrvIndex = “1.3.6.1.4.1.232.3.2.5.1.1.2.”

 ‘Drive Array Physical Drive Index. This index is used for selecting the physical drive table entry.

 ‘This number, along with the cpqDaPhyDrvCntlrIndex uniquely identify a specific physical drive.

 Dim sCpqDaPhyDrvBusNumber : sCpqDaPhyDrvBusNumber = “1.3.6.1.4.1.232.3.2.5.1.1.50.”

 ‘Physical Drive SCSI Bus Number. The bus number indicates to which SCSI bus this physical drive is attached.

 ‘The first instance is one and increments for each SCSI bus on a controller. A value of -1 will be returned if the physical drive

 ‘is attached to a controller that does not support multiple SCSI busses. This is not supported by the IDA, IDA Expansion, or IDA-2 controllers.

 ‘For SAS and SATA drives, the bus number corresponds to the enclosure where the drive resides.

 Dim sCpqDaPhyDrvBay : sCpqDaPhyDrvBay = “1.3.6.1.4.1.232.3.2.5.1.1.5.”

 ‘Physical Drive Bay Location. This value matches the bay location where the physical drive has been installed.

 ‘For a SCSI drive, this is the SCSI ID of the drive. For a SAS or SATA drive, this is the bay number on the enclosure.

 ‘Dim sCpqDaPhyDrvStatus : sCpqDaPhyDrvStatus = “1.3.6.1.4.1.232.3.2.5.1.1.6.”

 Dim sCpqDaPhyDrvStatus : sCpqDaPhyDrvStatus = “1.3.6.1.4.1.232.3.2.5.1.1.6.”

 ‘Physical Drive Status. This shows the status of the physical drive. The following values are valid for the physical drive status:

 ‘Other (1) Indicates that the instrument agent does not recognize the drive. You may need to upgrade your instrument agent and/or driver software.

 ‘Ok (2) Indicates the drive is functioning properly.

 ‘Failed (3) Indicates that the drive is no longer operating and should be replaced.

 ‘Predictive Failure(4) Indicates that the drive has a predictive failure error and should be replaced.

 ‘Erasing(5) Indicates that the drive is being erased.

 ‘Erase Done(6) Indicates that the drive has been erased and is now in an offline state.

 ‘Erase Queued(7) Indicates that an erase operation is currently queued for the drive.

 TestSNMP bFail, sErrorMsg, bSNMPResult

 SNMPLoop bFail, sErrorMsg, bSNMPResult, sCpqDaPhyDrvIndex, sMsg, bDown

 SetResults bFail, sErrorMsg, bSNMPResult, bDown, sMsg

 Sub SNMPLoop(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, sOIDtoLoop, ByRef sMsg, ByRef bDown)

 Dim sSNMPValue, rc, sInstance, sOIDCore, sIdentifier, sSNMPValue2, sSNMPValue3, sTranslate

 If bFail = 0 And bSNMPResult = 0 And bVendor = 0 Then

 sMsg = “”

 ‘Begin SNMP GetNext Loop

 Do

 Set rc = oSnmp.GetNext(sOIDtoLoop)

 If rc.Failed Then

 sErrorMsg = sErrorMsg & rc.GetErrorMsg

 bSNMPResult = 1

 Exit Do

 Else

 ‘Uncomment below to see what OIDs get returned

 ‘Context.Logmessage “OID: ” & rc.GetOID

 sOIDtoLoop = rc.GetOID

 sInstance = rc.GetOIDInstance

 sOIDCore = rc.GetOIDCore

 ‘Context.LogMessage sOIDtoLoop

 ‘Context.LogMessage sInstance

 ‘Context.LogMessage sOIDCore

 End If

 If InStr(sOIDCore, sOid_Initial) <> 0 Then

 sSNMPValue = GetSNMPVal(sCpqDaPhyDrvBusNumber & sInstance, bFail, sErrorMsg)

 sSNMPValue2 = GetSNMPVal(sCpqDaPhyDrvBay & sInstance, bFail, sErrorMsg)

 sSNMPValue3 = GetSNMPVal(sCpqDaPhyDrvStatus & sInstance, bFail, sErrorMsg)

 If sSNMPValue3 = 1 Then sTranslate = “Other”

 If sSNMPValue3 = 2 Then sTranslate = “Ok”

 If sSNMPValue3 = 3 Then sTranslate = “Failed”

 If sSNMPValue3 = 4 Then sTranslate = “Predictive Failure”

 If sSNMPValue3 = 5 Then sTranslate = “Erasing”

 If sSNMPValue3 = 6 Then sTranslate = “Erase Done”

 If sSNMPValue3 = 7 Then sTranslate = “Erase Queued”

 If sTranslate <> “Ok” Then

 bDown = 1

 sMsg = sMsg & sSNMPValue & ” : ” & sSNMPValue2 & ” has a status of: ” & sTranslate & vbCrLf

 End If

 Context.LogMessage sSNMPValue & ” : ” & sSNMPValue2 & ” has a status of: ” & sTranslate & vbCrLf

 End If

 Loop Until InStr(sOIDCore, sOid_Initial) = 0

 End If

 End Sub

 Sub SetResults(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, ByRef bDown, ByRef sMsg)

 ‘Set result based on errors

 Dim bResultSet : bResultSet = 0

 If bVendor = 1 Then

 bResultSet = 1

 Context.SetResult 1, “Either this isn’t a HP system or HP Management Agents are not loaded.”

 End If

 If bSNMPResult = 1 Then

 bResultSet = 1

 Context.SetResult 1, “Error: ” & sErrorMsg

 Else

 If bFail = 1 Then

 If sErrorMsg = “No Such object” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “Cannot find the SNMP object”

 ElseIf sErrorMsg = “Timeout” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “SNMP intilization timed out”

 ElseIf sErrorMsg <> “No Such object” And sErrorMsg <> “Timeout” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “There was a SNMP error” & vbCrLf & “Error: ” & sErrorMsg

 End If

 Else

 End If

 End If

 ‘Set Up or Down

 If bResultSet = 0 Then

 If bDown = 1 Then

 Context.LogMessage “DOWN! ” & sMsg

 Context.SetResult 1, sMsg

 Else

 Context.LogMessage “UP! ” & sMsg

 Context.SetResult 0, “All physical drives have a status of Online or Ready”

 End If

 End If

 End Sub

 ‘ **************

 ‘ * TestSNMP *

 ‘ **************

 Sub TestSNMP(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult)

 Dim rc, sOID

 ‘Initialize and Test SNMP Connection

 Set rc = oSnmp.Initialize(nDeviceID)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bSNMPResult = 1

 bFail = 1

 Else

 Set rc = oSnmp.GetNext(“1.3.6.1.4.1.232”)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bSNMPResult = 1

 bFail = 1

 Else

 sOID = rc.GetOIDCore

 If InStr(sOID, “1.3.6.1.4.1.232”) <> 0 Then

 ‘Do Nothing

 Else

 Context.LogMessage “No value found under CPQIDA-MIB 1.3.6.1.4.1.232” & vbCrLf

 bVendor = 1

 End If

 End If

 End If

 End Sub

 ‘ ****************

 ‘ * GetSNMPVal *

 ‘ ****************

 Function GetSNMPVal(sOID, ByRef bFail, ByRef sErrorMsg)

 GetSNMPVal = 0

 Dim rc

 Set rc = oSnmp.Get(sOID)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bFail = bFail + 1

 Context.LogMessage “Failed to get value!”

 Context.LogMessage sErrorMsg

 Else

 ‘Context.LogMessage rc.GetValue

 GetSNMPVal = rc.GetValue

 End If

 End Function

===

Remark:

If you run the script and got error, make sure HP management agents started on the target system, and load the required MIB to WhatsUp Gold. For some case, may need to add the ill as an additional network adapter and then point the active monitor to that.

The script will loop through all the entires regardless of how many there are (we mean hard drives). If there are a ton of them, make sure to increase the script time value.

Example: Dell Server Drive Status

Option Explicit

 ‘*****Configuration*****

 Dim nSNMPTimeout : nSNMPTimeout = 3000 ‘Set ms for SNMP timeouts

 Dim nSNMPRetry : nSNMPRetry = 2 ‘Set the number of SNMP retries

 ‘***End Configuration***

 ‘Get Device details

 Dim nDeviceID : nDeviceID = Context.GetProperty(“DeviceID”)

 Dim sAddress : sAddress = Context.GetProperty(“Address”)

 ‘Create SNMP object

 Dim oSnmp : Set oSnmp = CreateObject(“CoreAsp.SnmpRqst”)

 Dim nTimeout : nTimeout = oSnmp.SetTimeoutMs(nSNMPTimeout)

 Dim nRetries : nRetries = oSnmp.SetNumRetries(nSNMPRetry)

 ‘Set script variables

 Dim bSNMPResult : bSNMPResult = 0

 Dim bFail : bFail = 0

 Dim bDown : bDown = 0

 Dim bVendor : bVendor = 0

 Dim sErrorMsg : sErrorMsg = “”

 Dim sMsg : sMsg = “”

 Dim sOid_Initial : sOid_Initial = “10893.1.20.130.4.1.1”

 Dim sOIDtoLoop : sOIDtoLoop = “1.3.6.1.4.1.674.10893.1.20.130.4.1.1”

 ‘Instance number of this array disk entry.

 Dim arrayDiskNumber : arrayDiskNumber = “1.3.6.1.4.1.674.10893.1.20.130.4.1.1.”

 ‘The bus to which this array disk is connected.

 Dim arrayDiskChannel : arrayDiskChannel = “1.3.6.1.4.1.674.10893.1.20.130.4.1.15.”

 ‘The SCSI ID of the enclosure processor to which this array disk belongs.

 Dim arrayDiskEnclosureID : arrayDiskEnclosureID = “1.3.6.1.4.1.674.10893.1.20.130.4.1.10.”

 ‘The current condition of the array disk. Possible states:

 ‘0:Unknown

 ‘1:Ready – Available for use, but no RAID configuration has been assigned.

 ‘2:Failed – Not operational.

 ‘3:Online – Operational. RAID configuration has been assigned.

 ‘4:Offline – The drive is not available to the RAID controller.

 ‘6:Degraded – Refers to a fault-tolerant array/virtual disk that has a failed disk.

 ‘7:Recovering – Refers to state of recovering from bad blocks on disks.

 ’11:Removed – Indicates that array disk has been removed.

 ’13:Non-RAID – Indicates that array disk is not a RAID capable disk

 ’14:Not Ready – Applicable for PCIeSSD devices indicating that the device is in locked state

 ’15:Resynching – Indicates one of the following types of disk operations:Transform Type, Reconfiguration, and Check Consistency.

 ’24:Rebuild

 ’25:No Media – CD-ROM or removable disk has no media.

 ’26:Formatting – In the process of formatting.

 ’28:Diagnostics – Diagnostics are running.

 ’34:Predictive failure

 ’35:Initializing:Applies only to virtual disks on PERC, PERC 2/SC, and PERC 2/DC controllers.

 ’39:Foreign

 ’40:Clear

 ’41:Unsupported

 ’53:Incompatible

 ’56:Read Only – Applicable for PCIeSSD devices. Indicates that device has reached read-only state

 Dim arrayDiskState : arrayDiskState = “1.3.6.1.4.1.674.10893.1.20.130.4.1.4.”

 

 TestSNMP bFail, sErrorMsg, bSNMPResult

 SNMPLoop bFail, sErrorMsg, bSNMPResult, arrayDiskNumber, sMsg, bDown

 SetResults bFail, sErrorMsg, bSNMPResult, bDown, sMsg

 Sub SNMPLoop(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, sOIDtoLoop, ByRef sMsg, ByRef bDown)

 Dim sSNMPValue, rc, sInstance, sOIDCore, sIdentifier, sSNMPValue2, sSNMPValue3

 If bFail = 0 And bSNMPResult = 0 Then

 sMsg = “”

 ‘Begin SNMP GetNext Loop

 Do

 Set rc = oSnmp.GetNext(sOIDtoLoop)

 If rc.Failed Then

 sErrorMsg = sErrorMsg & rc.GetErrorMsg

 bSNMPResult = 1

 Exit Do

 Else

 ‘Uncomment below to see what OIDs get returned

 ‘Context.Logmessage “OID: ” & rc.GetOID

 sOIDtoLoop = rc.GetOID

 sInstance = rc.GetOIDInstance

 sOIDCore = rc.GetOIDCore

 ‘Context.LogMessage sOIDtoLoop

 ‘Context.LogMessage sInstance

 ‘Context.LogMessage sOIDCore

 End If

 If InStr(sOIDCore, sOid_Initial) <> 0 Then

 ‘Context.LogMessage sOid_Initial

 ‘Dim sInstanceSplit : sInstanceSplit = Split(sInstance, “10893.1.20.130.4.1.1”)

 ‘Dim sInstance2 : sInstance2 = Replace(sInstanceSplit(1), “.”, “”)

 ‘Context.LogMessage sInstance2

 sSNMPValue = GetSNMPVal(arrayDiskEnclosureID & sInstance, bFail, sErrorMsg)

 sSNMPValue2 = GetSNMPVal(arrayDiskChannel & sInstance, bFail, sErrorMsg)

 sSNMPValue3 = GetSNMPVal(arrayDiskState & sInstance, bFail, sErrorMsg)

 ‘Context.LogMessage “Disk ” & sSNMPValue & “:” & sSNMPValue2 & ” has a status of:” & sSNMPValue3

 Dim sTranslate

 If sSNMPValue3 = 0 Then sTranslate = “Unknown”

 If sSNMPValue3 = 1 Then sTranslate = “Ready”

 If sSNMPValue3 = 2 Then sTranslate = “Failed”

 If sSNMPValue3 = 3 Then sTranslate = “Online”

 If sSNMPValue3 = 4 Then sTranslate = “Offline”

 If sSNMPValue3 = 6 Then sTranslate = “Degraded”

 If sSNMPValue3 = 7 Then sTranslate = “Recovering”

 If sSNMPValue3 = 11 Then sTranslate = “Removed”

 If sSNMPValue3 = 13 Then sTranslate = “Non-RAID”

 If sSNMPValue3 = 14 Then sTranslate = “Not Ready”

 If sSNMPValue3 = 15 Then sTranslate = “Resynching”

 If sSNMPValue3 = 24 Then sTranslate = “Rebuild”

 If sSNMPValue3 = 25 Then sTranslate = “No Media”

 If sSNMPValue3 = 26 Then sTranslate = “Formatting”

 If sSNMPValue3 = 28 Then sTranslate = “Diagnostics”

 If sSNMPValue3 = 34 Then sTranslate = “Predictive failure”

 If sSNMPValue3 = 35 Then sTranslate = “Initializing”

 If sSNMPValue3 = 39 Then sTranslate = “Foreign”

 If sSNMPValue3 = 40 Then sTranslate = “Clear”

 If sSNMPValue3 = 41 Then sTranslate = “Unsupported”

 If sSNMPValue3 = 53 Then sTranslate = “Incompatible”

 If sSNMPValue3 = 56 Then sTranslate = “Read Only”

 If sTranslate = “Online” or sTranslate = “Ready” Then

 ‘Do Nothing

 Else

 bDown = 1

 sMsg = sMsg & “Disk ” & sSNMPValue & “:” & sSNMPValue2 & ” has a status of:” & sTranslate & vbCrLf

 End If

 Context.LogMessage “Disk ” & sSNMPValue & “:” & sSNMPValue2 & ” has a status of:” & sTranslate

 End If

 Loop Until InStr(sOIDCore, sOid_Initial) = 0

 End If

 End Sub

 Sub SetResults(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, ByRef bDown, ByRef sMsg)

 ‘Set result based on errors

 Dim bResultSet : bResultSet = 0

 If bVendor = 1 Then

 bResultSet = 1

 Context.SetResult 1, “Wrong vendor buddy…”

 End If

 If bSNMPResult = 1 Then

 bResultSet = 1

 Context.SetResult 1, “Error: ” & sErrorMsg

 Else

 If bFail = 1 Then

 If sErrorMsg = “No Such object” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “Cannot find the SNMP object”

 ElseIf sErrorMsg = “Timeout” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “SNMP intilization timed out”

 ElseIf sErrorMsg <> “No Such object” And sErrorMsg <> “Timeout” Then

 bResultSet = 1

 Context.LogMessage “Down!”

 Context.SetResult 1, “There was a SNMP error” & vbCrLf & “Error: ” & sErrorMsg

 End If

 Else

 End If

 End If

 ‘Set Up or Down

 If bResultSet = 0 Then

 If bDown = 1 Then

 Context.LogMessage “DOWN! ” & sMsg

 Context.SetResult 1, sMsg

 Else

 Context.LogMessage “UP!” & sMsg

 Context.SetResult 0, “All physical drives have a status of Online or Ready”

 End If

 End If

 End Sub

 ‘ **************

 ‘ * TestSNMP *

 ‘ **************

 Sub TestSNMP(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult)

 Dim rc, sOID

 ‘Initialize and Test SNMP Connection

 Set rc = oSnmp.Initialize(nDeviceID)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bSNMPResult = 1

 bFail = 1

 Else

 Set rc = oSnmp.GetNext(“1.3.6.1.4.1.674”)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bSNMPResult = 1

 bFail = 1

 Else

 sOID = rc.GetOIDCore

 If InStr(sOID, “1.3.6.1.4.1.674”) <> 0 Then

 Else

 Context.LogMessage “SNMP test was successful but this isn’t a Dell dude…” & vbCrLf

 bVendor = 1

 End If

 End If

 End If

 End Sub

 ‘ ****************

 ‘ * GetSNMPVal *

 ‘ ****************

 Function GetSNMPVal(sOID, ByRef bFail, ByRef sErrorMsg)

 GetSNMPVal = 0

 Dim rc

 Set rc = oSnmp.Get(sOID)

 If rc.Failed Then

 sErrorMsg = rc.GetErrorMsg

 bFail = bFail + 1

 Context.LogMessage “Failed to get SNMP value!”

 Else

 ‘ Context.LogMessage rc.GetValue

 GetSNMPVal = rc.GetValue

 End If

 End Function

===

Another example active monitor script below:

Option Explicit
‘*****Configuration*****

Dim nSNMPTimeout : nSNMPTimeout = 3000 ‘Set ms for SNMP timeouts

Dim nSNMPRetry : nSNMPRetry = 2 ‘Set the number of SNMP retries

‘***End Configuration***

‘Get Device details

Dim nDeviceID : nDeviceID = Context.GetProperty(“DeviceID”)

Dim sAddress : sAddress = Context.GetProperty(“Address”)

‘Create SNMP object

Dim oSnmp : Set oSnmp = CreateObject(“CoreAsp.SnmpRqst”)

Dim nTimeout : nTimeout = oSnmp.SetTimeoutMs(nSNMPTimeout)

Dim nRetries : nRetries = oSnmp.SetNumRetries(nSNMPRetry)

‘Set script variables

Dim bSNMPResult : bSNMPResult = 0

Dim bFail : bFail = 0

Dim bDown : bDown = 0

Dim bVendor : bVendor = 0

Dim sErrorMsg : sErrorMsg = “”

Dim sMsg : sMsg = “”

Dim sOid_Initial : sOid_Initial = “10893.1.20.130.4.1.1”

Dim sOIDtoLoop : sOIDtoLoop = “1.3.6.1.4.1.674.10893.1.20.130.4.1.1”

‘Instance number of this array disk entry.

Dim arrayDiskNumber : arrayDiskNumber = “1.3.6.1.4.1.674.10893.1.20.130.4.1.1.”

‘The bus to which this array disk is connected.

Dim arrayDiskChannel : arrayDiskChannel = “1.3.6.1.4.1.674.10893.1.20.130.4.1.15.”

‘The SCSI ID of the enclosure processor to which this array disk belongs.

Dim arrayDiskEnclosureID : arrayDiskEnclosureID = “1.3.6.1.4.1.674.10893.1.20.130.4.1.10.”

‘The current condition of the array disk. Possible states:

‘0:Unknown

‘1:Ready – Available for use, but no RAID configuration has been assigned.

‘2:Failed – Not operational.

‘3:Online – Operational. RAID configuration has been assigned.

‘4:Offline – The drive is not available to the RAID controller.

‘6:Degraded – Refers to a fault-tolerant array/virtual disk that has a failed disk.

‘7:Recovering – Refers to state of recovering from bad blocks on disks.

’11:Removed – Indicates that array disk has been removed.

’13:Non-RAID – Indicates that array disk is not a RAID capable disk

’14:Not Ready – Applicable for PCIeSSD devices indicating that the device is in locked state

’15:Resynching – Indicates one of the following types of disk operations:Transform Type, Reconfiguration, and Check Consistency.

’24:Rebuild

’25:No Media – CD-ROM or removable disk has no media.

’26:Formatting – In the process of formatting.

’28:Diagnostics – Diagnostics are running.

’34:Predictive failure

’35:Initializing:Applies only to virtual disks on PERC, PERC 2/SC, and PERC 2/DC controllers.

’39:Foreign

’40:Clear

’41:Unsupported

’53:Incompatible

’56:Read Only – Applicable for PCIeSSD devices. Indicates that device has reached read-only state

Dim arrayDiskState : arrayDiskState = “1.3.6.1.4.1.674.10893.1.20.130.4.1.4.”

TestSNMP bFail, sErrorMsg, bSNMPResult

SNMPLoop bFail, sErrorMsg, bSNMPResult, arrayDiskNumber, sMsg, bDown

SetResults bFail, sErrorMsg, bSNMPResult, bDown, sMsg

Sub SNMPLoop(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, sOIDtoLoop, ByRef sMsg, ByRef bDown)

Dim sSNMPValue, rc, sInstance, sOIDCore, sIdentifier, sSNMPValue2, sSNMPValue3

If bFail = 0 And bSNMPResult = 0 Then

sMsg = “”

‘Begin SNMP GetNext Loop

Do

Set rc = oSnmp.GetNext(sOIDtoLoop)

If rc.Failed Then

sErrorMsg = sErrorMsg &amp; rc.GetErrorMsg

bSNMPResult = 1

Exit Do

Else

‘Uncomment below to see what OIDs get returned

‘Context.Logmessage “OID: ” &amp; rc.GetOID

sOIDtoLoop = rc.GetOID

sInstance = rc.GetOIDInstance

sOIDCore = rc.GetOIDCore

End If

If InStr(sInstance, sOid_Initial) &lt;&gt; 0 Then

Dim sInstanceSplit : sInstanceSplit = Split(sInstance, “10893.1.20.130.4.1.1”)

Dim sInstance2 : sInstance2 = Replace(sInstanceSplit(1), “.”, “”)

sSNMPValue = GetSNMPVal(arrayDiskEnclosureID &amp; sInstance2, bFail, sErrorMsg)

sSNMPValue2 = GetSNMPVal(arrayDiskChannel &amp; sInstance2, bFail, sErrorMsg)

sSNMPValue3 = GetSNMPVal(arrayDiskState &amp; sInstance2, bFail, sErrorMsg)

Dim sTranslate

If sSNMPValue3 = 0 Then sTranslate = “Unknown”

If sSNMPValue3 = 1 Then sTranslate = “Ready”

If sSNMPValue3 = 2 Then sTranslate = “Failed”

If sSNMPValue3 = 3 Then sTranslate = “Online”

If sSNMPValue3 = 4 Then sTranslate = “Offline”

If sSNMPValue3 = 6 Then sTranslate = “Degraded”

If sSNMPValue3 = 7 Then sTranslate = “Recovering”

If sSNMPValue3 = 11 Then sTranslate = “Removed”

If sSNMPValue3 = 13 Then sTranslate = “Non-RAID”

If sSNMPValue3 = 14 Then sTranslate = “Not Ready”

If sSNMPValue3 = 15 Then sTranslate = “Resynching”

If sSNMPValue3 = 24 Then sTranslate = “Rebuild”

If sSNMPValue3 = 25 Then sTranslate = “No Media”

If sSNMPValue3 = 26 Then sTranslate = “Formatting”

If sSNMPValue3 = 28 Then sTranslate = “Diagnostics”

If sSNMPValue3 = 34 Then sTranslate = “Predictive failure”

If sSNMPValue3 = 35 Then sTranslate = “Initializing”

If sSNMPValue3 = 39 Then sTranslate = “Foreign”

If sSNMPValue3 = 40 Then sTranslate = “Clear”

If sSNMPValue3 = 41 Then sTranslate = “Unsupported”

If sSNMPValue3 = 53 Then sTranslate = “Incompatible”

If sSNMPValue3 = 56 Then sTranslate = “Read Only”

If sTranslate = “Online” or sTranslate = “Ready” Then

‘Do Nothing

Else

bDown = 1

sMsg = sMsg &amp; “Disk ” &amp; sSNMPValue &amp; “:” &amp; sSNMPValue2 &amp; ” has a status of:” &amp; sTranslate &amp; vbCrLf

End If

Context.LogMessage “Disk ” &amp; sSNMPValue &amp; “:” &amp; sSNMPValue2 &amp; ” has a status of:” &amp; sTranslate

End If

Loop Until InStr(sInstance, sOid_Initial) = 0

End If

End Sub

Sub SetResults(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult, ByRef bDown, ByRef sMsg)

‘Set result based on errors

Dim bResultSet : bResultSet = 0

If bVendor = 1 Then

bResultSet = 1

Context.SetResult 1, “Wrong vendor buddy…”

End If

If bSNMPResult = 1 Then

bResultSet = 1

Context.SetResult 1, “Error: ” &amp; sErrorMsg

Else

If bFail = 1 Then

If sErrorMsg = “No Such object” Then

bResultSet = 1

Context.LogMessage “Down!”

Context.SetResult 1, “Cannot find the SNMP object”

ElseIf sErrorMsg = “Timeout” Then

bResultSet = 1

Context.LogMessage “Down!”

Context.SetResult 1, “SNMP intilization timed out”

ElseIf sErrorMsg &lt;&gt; “No Such object” And sErrorMsg &lt;&gt; “Timeout” Then

bResultSet = 1

Context.LogMessage “Down!”

Context.SetResult 1, “There was a SNMP error” &amp; vbCrLf &amp; “Error: ” &amp; sErrorMsg

End If

Else

End If

End If

‘Set Up or Down

If bResultSet = 0 Then

If bDown = 1 Then

Context.LogMessage “DOWN!” &amp; sMsg

Context.SetResult 1, sMsg

Else

Context.LogMessage “UP!” &amp; sMsg

Context.SetResult 0, “All physical drives have a status of Online or Ready”

End If

End If

End Sub

‘ **************

‘ * TestSNMP *

‘ **************

Sub TestSNMP(ByRef bFail, ByRef sErrorMsg, ByRef bSNMPResult)

Dim rc, sOID

‘Initialize and Test SNMP Connection

Set rc = oSnmp.Initialize(nDeviceID)

If rc.Failed Then

sErrorMsg = rc.GetErrorMsg

bSNMPResult = 1

bFail = 1

Else

Set rc = oSnmp.GetNext(“1.3.6.1.4.1.674”)

If rc.Failed Then

sErrorMsg = rc.GetErrorMsg

bSNMPResult = 1

bFail = 1

Else

sOID = rc.GetOIDCore

If InStr(sOID, “1.3.6.1.4.1.674”) &lt;&gt; 0 Then

Else

Context.LogMessage “SNMP test was successful but this isn’t a Dell dude…” &amp; vbCrLf

bVendor = 1

End If

End If

End If

End Sub

‘ ****************

‘ * GetSNMPVal *

‘ ****************

Function GetSNMPVal(sOID, ByRef bFail, ByRef sErrorMsg)

GetSNMPVal = 0

Dim rc

Set rc = oSnmp.Get(sOID)

If rc.Failed Then

sErrorMsg = rc.GetErrorMsg

bFail = bFail + 1

Context.LogMessage “Failed to get value!”

Else

‘Context.LogMessage rc.GetValue

GetSNMPVal = rc.GetValue

End If

End Function