| ' Active monitor for DHCP on MIcrosoft servers. ' Limits are hard coded below ' Messages in log indicate statistics whether success or failure LimitPct = 0.10 ' Percentage (as real number) below which we alarm LimitAdd = 10 ' Or alarm if less than this many addresses set objSNMP = CreateObject("CoreAsp.SnmpRqst") nDeviceID = Context.GetProperty("DeviceID") set strResult = objSNMP.Initialize(nDeviceID) On Error Resume Next SubnetAdd ="1.3.6.1.4.1.311.1.3.2.1.1.1" noAddInUse="1.3.6.1.4.1.311.1.3.2.1.1.2" NoAddFree ="1.3.6.1.4.1.311.1.3.2.1.1.3" Msg = "" Index = -1 ThisOID = SubnetAdd MaxAddresses = 0 FinalStatus = -1 ' This will mean we got none Set myRegExp = New RegExp ' So we can match subnet myRegExp.IgnoreCase = True myRegExp.Global = True myRegExp.Pattern = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" ' OK, this matches invalid IP's, but it is simpler while index < 200 ' Safety limit just in case set oSnmpResponse= objSNMP.GetNext(ThisOID) if oSnmpResponse.Failed then index = 99999 Msg = "Failed call to GetNext, err=" & oSnmpResponse.GetErrorMsg FinalStatus = 1 else ThisOID = oSnmpResponse.GetOID ' Value returned Subnet = oSnmpResponse.GetValue if myRegExp.Test(Subnet) then if Subnet = right(ThisOID,len(Subnet)) then ' Are we still in the list of subnets? if FinalStatus = -1 then FinalStatus = 0 index = index + 1 InUse = CInt(objSNMP.Get(noAddInUse & "." & Subnet).GetValue) Free = CInt(objSNMP.Get(noAddFree & "." & Subnet).GetValue) if InUse + Free =0 then Pct = 0 else Pct = (Free / (Free + InUse)) If Pct < LimitPct or Free < 10 then FinalStatus = 1 Msg = Msg + vbcr + Subnet & ": In use=" & InUse & " Free=" & Free & " Pct Free=" & FormatPercent(Pct) else ' At end of list MaxAddresses = Index Index = 99999 end if else ' Didn't get something that looks like a subnet MaxAddresses = Index Index = 99999 end if end if wend If FinalStatus = 1 then Msg = "Fail: " & Msg If FinalStatus = 0 then Msg = "Succeed: " & Msg If FinalStatus = -1 then Msg = "Fail No DHCP" FinalStatus = 1 End If Context.SetResult FinalStatus, Msg |
2 Replies
Hi
I have testet the Script on 2 DHCP Servers from Customers. And it works :)
But is there an option to mage the Monitor only for one Subnet?
Because we have got about 250 different Scopes and some of them are full an thats ok. And so i get an alarm because these Scopes are also in the script. So it would be good if you can add an variable where we can describe the subnet we want to be monitored.
Hi, there is a litte erro in the script:
LimitPct = 0.10 ' Percentage (as real number) below which we alarm
LimitAdd = 10 ' Or alarm if less than this many addresses
The variable LimitAdd will not be used in the script in Line 46 the Limit will set HARD so the first definition will never be used.
If Pct < LimitPct or Free < 10 then FinalStatus = 1
Replace 10 with LimitAdd and it will work fine.
Would you like to comment?
You must be a member. Sign In if you are already a member.