Good Morning,
Has anyone updated/modified the DHCP plugin for xymon,
Currently we are using the following ext script to monitor our DHCP servers on 2008 however we seem to be running into issues on 2012
Thanks in advance.
Jorge
BBDHCP.VBS
option Explicit
' BigBrother External Script for testing to see if Dhcp is up and responding on Window 2003 and above
' Gives Scope details running on the server specified With Active/Excluded and Available leases
' Installation
' 1) Modify the vairables below to match your system.
' 2) Add the script to your externals list in bbntcfg on the DHCP Server.
' so that it runs at least every 6500 seconds
' 3) Make sure you set the Saved Logs Location to %BBHOME%\ext
' Author Graeme Shea, Shea Technology Pty Ltd. graeme AT shea.com.au
' Adapted from and very heavly based on work by Brett Wilson - Brett_Wilsons at hotmail.com and André Hugener
Dim Server, Alias, Yellow, Red, BBext, Colour, Col, WshShell, FileSys, OutDhcp, Version, BBextFolder
Dim Check, Dhcp, NoDhcp, Status, Scope, Line, u, Tokens, Tmp, InUse, Free, BB, BBin, pend, j
'---Vairables---
Server = "DHCPservername" ' Dhcp Server to test (not neccessarily the server running from)
Alias = "DHCPServername" 'Name machine is known at BB server "," instead of "."!!!
Yellow = 3 ' Min Available Leases when BB turns Yellow
Red = 2 ' Min Available Leases when BB turns Red
'---End Vairables---
'---Nothing to Change under this line---
'On Error Resume Next'
'-------------------------------------------------------------------------------------
' Version 0.1 Oringal version using dhcpcmd.exe for NT4 Resource kit
' Version 0.2 Uses builting Windows 2003 netsh command.
' Version 0.2.1 Fixed dialog error on 64bit systems.
Version = "0.2.1"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSys = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
BBext = WshShell.RegRead("HKLM\SOFTWARE\bbwin\tmppath\")
' If 64 bit system then reg file has moved and will raise an error.
If Err Then
err.clear
BBext = ("c:\progra~2\bbwin\tmp")'
If Err Then
MsgBox " Big Brother Client not installed. ",," Fatal Error. "
End If
on Error GoTo 0
End If
If BBext = "" Then
MsgBox " Big Brother External Path not set. You need to set the Saved Logs Location " _
& VbCrLf & " using the bbntcfg utility. ",," Fatal Error. "
WScript.Quit
End If
On Error GoTo 0
'Need short path names or else Netsh creates a c:\program file.
Set BBextFolder = FileSys.GetFolder(BBext)
BBext = BBextFolder.ShortPath
Status = "status " & Alias & ".dhcp "
Dhcp = "cmd /c " & "Netsh.exe dhcp server \\"& Server & " show mibinfo > " & bbext & "\dhcp.txt"
WshShell.run Dhcp, 0, True
' Check to see that Dhcp is running
Set Check = FileSys.OpenTextFile (bbext & "\dhcp.txt")
NoDhcp = Check.ReadLine
If InStr(1,NoDhcp, "Unable") OR InStr(1,NoDhcp, "Not Found")Then
Dhcp = "No"
Status = "red " & Status & " red" & " " & Now() & Vbcrlf &_
"Warning!! Dhcp Is not Running On Server - " & Server
End If
' If Dhcp is running retrieve Active Scopes and lease numbers
Do While Not check.AtEndOfStream
Line = Check.ReadLine
u = Instr(1,Line,"Subnet")
if u <> 0 Then
tokens = Split( Line,"=")
tmp = Check.ReadLine
Inuse = Split( tmp,"=")
tmp = Check.ReadLine
Free = Split( tmp,"=")
tmp = Check.ReadLine
pend = Split( tmp,"=")
j=(Cint(Free(1))+Cint(Inuse(1))+Cint(pend(1)))
If j < 1 Then
Colour = "blue"
Else
Colour = "green"
if Col < 1 Then
Col = 1
End If
If Cint(Free(1)) <= Yellow Then
Colour = "yellow"
If Col < 2 Then
Col = 2
End If
End If
If Cint(Free(1)) <= Red Then
Colour = "red"
Col = 3
End If
End If
Scope = Scope & " Scope " & Tokens(1) & " " & Fix(Inuse(1)) & " Active/Excluded" &_
VbCrlf & "&" & Colour & " Scope " & Tokens(1) & " " & Fix(Free(1)) & " Available" &_
VbCrlf & " Scope " & Tokens(1) & " " & Fix(pend(1)) & " Pending" & VbCrlf &_
"Status: " & Colour & VbCrlf & VbCrlf
End If
Loop
Colour = "red"
If Col = 0 Then
Colour = "blue"
End If
If Col = 1 Then
Colour = "green"
End If
If Col = 2 Then
Colour = "yellow"
End If
If Dhcp <> "No" Then
Status = colour & "+2h " & Status & Colour & " " & Now() & Vbcrlf & _
"Dhcp is running on Server " & Server & " with the following configuration" & VbCrLf
End If
Set OutDhcp = filesys.CreateTextFile(BBext & "\dhcp", True)
OutDhcp.WriteLine Status
OutDhcp.WriteLine Scope
OutDhcp.WriteLine ""
OutDhcp.WriteLine "BBDhcp Version " & Version
Outdhcp.close
Check.close
This email and its contents are subject to an email legal notice that can be viewed at http://www.naspers.com/disclaimer.php Should you be unable to access the link provided, please email us for a copy at csc at optinet.net
Hierdie e-pos en sy inhoud is onderhewig aan 'n regskennisgewing oor elektroniese pos wat gelees kan word by http://www.naspers.com/afrikaans/voorbehoud.php 'n Afskrif kan aangevra word by csc at optinet.net
Hi Jorge,
Below is the script I use on 2012 and 2012 R2 without any problems (if outlook doesn't mess it up). If you strike any issues can you let me know.
Regards Graeme
'----------------------------------------------------------------------------------- option Explicit ' BigBrother External Script for testing to see if Dhcp is up and responding on Window 2003 and above ' Gives Scope details running on the server specified With Active/Excluded and Available leases
' Installation ' 1) Modify the vairables below to match your system.
' 2) Add the script to your externals list in bbntcfg on the DHCP Server. ' so that it runs at least every 6500 seconds ' 3) Make sure you set the Saved Logs Location to %BBHOME%\ext
' Author Graeme Shea, Shea Technology Pty Ltd. graeme AT shea.com.au ' Adapted from and very heavly based on work by Brett Wilson - Brett_Wilsons at hotmail.com and André Hugener Dim Server, Alias, Yellow, Red, BBext, Colour, Col, WshShell, FileSys, OutDhcp, Version, BBextFolder Dim Check, Dhcp, NoDhcp, Status, Scope, Line, u, Tokens, Tmp, InUse, Free, BB, BBin, pend, j, b64Bit
'---Vairables--- Server = "localhost" ' Dhcp Server to test (not neccessarily the server running from) Alias = "DC1" 'Name machine is known at BB server "," instead of "."!!! Yellow = 20 ' Min Available Leases when BB turns Yellow Red = 5 ' Min Available Leases when BB turns Red '---End Vairables---
'---Nothing to Change under this line---
'On Error Resume Next' '------------------------------------------------------------------------------------- ' Version 0.1 Oringal version using dhcpcmd.exe for NT4 Resource kit ' Version 0.2 Uses builting Windows 2003 netsh command. ' Version 0.2.1 Fixed dialog error on 64bit systems. ' Version 0.3.0 BBWin compatatible 01/05/08 Graeme Shea.
Version = "0.3.0"
Set WshShell = WScript.CreateObject("WScript.Shell") Set FileSys = CreateObject("Scripting.FileSystemObject")
On Error Resume Next BBext = GetBigBrotherPath()
If BBext = "" Then MsgBox " Big Brother External Path not set. You need to set the Saved Logs Location " _ & VbCrLf & " using the bbntcfg utility. ",," Fatal Error. " WScript.Quit End If On Error GoTo 0
'Need short path names or else Netsh creates a c:\program file. Set BBextFolder = FileSys.GetFolder(BBext) BBext = BBextFolder.ShortPath Status = "status " & Alias & ".dhcp "
Dhcp = "cmd /c " & "Netsh.exe dhcp server \\"& Server & " show mibinfo > " & bbext & "\dhcp.txt" WshShell.run Dhcp, 0, True
' Check to see that Dhcp is running Set Check = FileSys.OpenTextFile (bbext & "\dhcp.txt") NoDhcp = Check.ReadLine If InStr(1,NoDhcp, "Unable") OR InStr(1,NoDhcp, "Not Found")Then Dhcp = "No" Status = "red " & Status & " red" & " " & Now() & Vbcrlf &_ "Warning!! Dhcp Is not Running On Server - " & Server End If
' If Dhcp is running retrieve Active Scopes and lease numbers
Do While Not check.AtEndOfStream Line = Check.ReadLine u = Instr(1,Line,"Subnet") if u <> 0 Then tokens = Split( Line,"=") tmp = Check.ReadLine Inuse = Split( tmp,"=") tmp = Check.ReadLine Free = Split( tmp,"=") tmp = Check.ReadLine pend = Split( tmp,"=")
j=(Cint(Free(1))+Cint(Inuse(1))+Cint(pend(1)))
If j < 1 Then
Colour = "blue"
Else
Colour = "green"
if Col < 1 Then
Col = 1
End If
If Cint(Free(1)) <= Yellow Then
Colour = "yellow"
If Col < 2 Then
Col = 2
End If
End If
If Cint(Free(1)) <= Red Then
Colour = "red"
Col = 3
End If
End If
Scope = Scope & " Scope " & Tokens(1) & " " & Fix(Inuse(1)) & " Active/Excluded" &_
VbCrlf & "&" & Colour & " Scope " & Tokens(1) & " " & Fix(Free(1)) & " Available" &_
VbCrlf & " Scope " & Tokens(1) & " " & Fix(pend(1)) & " Pending" & VbCrlf &_
"Status: " & Colour & VbCrlf & VbCrlf
End If
Loop
Colour = "red"
If Col = 0 Then Colour = "blue" End If If Col = 1 Then Colour = "green" End If If Col = 2 Then Colour = "yellow" End If
If Dhcp <> "No" Then Status = colour & "+2h " & Status & Colour & " " & Now() & Vbcrlf & _ "Dhcp is running on Server " & Server & " with the following configuration" & VbCrLf End If
Set OutDhcp = filesys.CreateTextFile(BBext & "\dhcp", True) OutDhcp.WriteLine Status OutDhcp.WriteLine Scope OutDhcp.WriteLine "" OutDhcp.WriteLine "BBDhcp Version " & Version Outdhcp.close Check.close
' Get path to external log files (for BB 1.08d) Function GetBigBrotherPath() Dim ExtPath On Error Resume Next
ExtPath = WshShell.RegRead("HKLM\SOFTWARE\Quest Software\BigBrother\bbnt\ExternalPath\") If IsEmpty(ExtPath) Then ExtPath = WshShell.RegRead("HKLM\SOFTWARE\BBWin\tmppath") End If If Not IsEmpty (ExtPath) Then 'If not empty then we have 32bit machine b64Bit = False End If If IsEmpty(ExtPath) Then ExtPath = WshShell.RegRead("HKLM\SOFTWARE\Wow6432node\Quest Software\BigBrother\bbnt\ExternalPath\") End If If IsEmpty(ExtPath) Then ExtPath = WshShell.RegRead("HKLM\SOFTWARE\Wow6432node\BBWin\tmppath") End If
If Not IsEmpty(ExtPath) And isEmpty(b64Bit) Then b64Bit = True err.clear End If
If IsEmpty(ExtPath) Then 'Put exit stuff here End If on Error GoTo 0 GetBigBrotherPath = ExtPath End Function
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jorge Lopes Sent: Monday, 24 February 2014 8:19 AM To: Xymon MailingList Subject: [Xymon] DHCP monitoring
Good Morning,
Has anyone updated/modified the DHCP plugin for xymon,
Currently we are using the following ext script to monitor our DHCP servers on 2008 however we seem to be running into issues on 2012
Thanks in advance.
Jorge
BBDHCP.VBS
... Old script removed for brevity - GS
..This email and its contents are subject to an email legal notice that can be viewed at: http://www.naspers.com/disclaimer.php Should you be unable to access the link provided, please email us for a copy at csc at optinet.net<mailto:csc at optinet.net>
Hierdie e-pos en sy inhoud is onderhewig aan 'n regskennisgewing oor elektroniese pos wat gelees kan word by http://www.naspers.com/afrikaans/voorbehoud.php 'n Afskrif kan aangevra word by csc at optinet.net<mailto:csc at optinet.net>
Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.
You might try using PowerShell in 2012 too (just an example of some possibilities ... not an actual production script I'm using):
Import-Module DhcpServer
$dhcpServers = @('server1','server2') [bool]$canGetDhcpAddr = $false [long]$freeLeases = 0 [long]$inUseLeases = 0 [double]$percentLeasesUsed = 0.0 [long]$reservedLeases = 0
foreach ($dhcpSvr in $dhcpServers) { foreach ($v4Scope in (Get-DhcpServerv4Scope -ComputerName $dhcpSvr)) { $v4LeaseAddr = Get-DhcpServerv4FreeIPAddress -ComputerName $dhcpSvr -ScopeId $v4Scope.ScopeId if ($v4LeaseAddr -ne $null) { # hey, we were able to obtain a dhcp address $canGetDhcpAddr = $true } else { # oh, darn! we were not able to obtain a dhcp address $canGetDhcpAddr = $false } $v4Stats = Get-DhcpServerv4ScopeStatistics -ComputerName $dhcpSvr -ScopeId $v4Scope.ScopeId $freeLeases = $v4Stats.Free $inUseLeases = $v4Stats.InUse $percentLeasesUsed = $v4Stats.PercentageInUse $reservedLeases = $v4Stats.Reserved } }
Ray Storer NIBCO INC. 574.295.3457
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jorge Lopes Sent: Sunday, February 23, 2014 4:19 PM To: Xymon MailingList Subject: [Xymon] DHCP monitoring
Good Morning,
Has anyone updated/modified the DHCP plugin for xymon,
Currently we are using the following ext script to monitor our DHCP servers on 2008 however we seem to be running into issues on 2012
Thanks in advance.
Jorge
BBDHCP.VBS
option Explicit
' BigBrother External Script for testing to see if Dhcp is up and responding on Window 2003 and above
' Gives Scope details running on the server specified With Active/Excluded and Available leases
' Installation
' 1) Modify the vairables below to match your system.
' 2) Add the script to your externals list in bbntcfg on the DHCP Server.
' so that it runs at least every 6500 seconds
' 3) Make sure you set the Saved Logs Location to %BBHOME%\ext
' Author Graeme Shea, Shea Technology Pty Ltd. graeme AT shea.com.au
' Adapted from and very heavly based on work by Brett Wilson - Brett_Wilsons at hotmail.com<mailto:Brett_Wilsons at hotmail.com> and André Hugener
Dim Server, Alias, Yellow, Red, BBext, Colour, Col, WshShell, FileSys, OutDhcp, Version, BBextFolder
Dim Check, Dhcp, NoDhcp, Status, Scope, Line, u, Tokens, Tmp, InUse, Free, BB, BBin, pend, j
'---Vairables---
Server = "DHCPservername" ' Dhcp Server to test (not neccessarily the server running from)
Alias = "DHCPServername" 'Name machine is known at BB server "," instead of "."!!!
Yellow = 3 ' Min Available Leases when BB turns Yellow
Red = 2 ' Min Available Leases when BB turns Red
'---End Vairables---
'---Nothing to Change under this line---
'On Error Resume Next'
'-------------------------------------------------------------------------------------
' Version 0.1 Oringal version using dhcpcmd.exe for NT4 Resource kit
' Version 0.2 Uses builting Windows 2003 netsh command.
' Version 0.2.1 Fixed dialog error on 64bit systems.
Version = "0.2.1"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSys = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
BBext = WshShell.RegRead("HKLM\SOFTWARE\bbwin\tmppath\")
' If 64 bit system then reg file has moved and will raise an error.
If Err Then
err.clear
BBext = ("c:\progra~2\bbwin\tmp")'
If Err Then
MsgBox " Big Brother Client not installed. ",," Fatal Error. "
End If
on Error GoTo 0
End If
If BBext = "" Then
MsgBox " Big Brother External Path not set. You need to set the Saved Logs Location " _
& VbCrLf & " using the bbntcfg utility. ",," Fatal Error. "
WScript.Quit
End If
On Error GoTo 0
'Need short path names or else Netsh creates a c:\program file.
Set BBextFolder = FileSys.GetFolder(BBext)
BBext = BBextFolder.ShortPath
Status = "status " & Alias & ".dhcp "
Dhcp = "cmd /c " & "Netsh.exe dhcp server \\"& Server & " show mibinfo > " & bbext & "\dhcp.txt"
WshShell.run Dhcp, 0, True
' Check to see that Dhcp is running
Set Check = FileSys.OpenTextFile (bbext & "\dhcp.txt")
NoDhcp = Check.ReadLine
If InStr(1,NoDhcp, "Unable") OR InStr(1,NoDhcp, "Not Found")Then
Dhcp = "No"
Status = "red " & Status & " red" & " " & Now() & Vbcrlf &_
"Warning!! Dhcp Is not Running On Server - " & Server
End If
' If Dhcp is running retrieve Active Scopes and lease numbers
Do While Not check.AtEndOfStream
Line = Check.ReadLine
u = Instr(1,Line,"Subnet")
if u <> 0 Then
tokens = Split( Line,"=")
tmp = Check.ReadLine
Inuse = Split( tmp,"=")
tmp = Check.ReadLine
Free = Split( tmp,"=")
tmp = Check.ReadLine
pend = Split( tmp,"=")
j=(Cint(Free(1))+Cint(Inuse(1))+Cint(pend(1)))
If j < 1 Then
Colour = "blue"
Else
Colour = "green"
if Col < 1 Then
Col = 1
End If
If Cint(Free(1)) <= Yellow Then
Colour = "yellow"
If Col < 2 Then
Col = 2
End If
End If
If Cint(Free(1)) <= Red Then
Colour = "red"
Col = 3
End If
End If
Scope = Scope & " Scope " & Tokens(1) & " " & Fix(Inuse(1)) & " Active/Excluded" &_
VbCrlf & "&" & Colour & " Scope " & Tokens(1) & " " & Fix(Free(1)) & " Available" &_
VbCrlf & " Scope " & Tokens(1) & " " & Fix(pend(1)) & " Pending" & VbCrlf &_
"Status: " & Colour & VbCrlf & VbCrlf
End If
Loop
Colour = "red"
If Col = 0 Then
Colour = "blue"
End If
If Col = 1 Then
Colour = "green"
End If
If Col = 2 Then
Colour = "yellow"
End If
If Dhcp <> "No" Then
Status = colour & "+2h " & Status & Colour & " " & Now() & Vbcrlf & _
"Dhcp is running on Server " & Server & " with the following configuration" & VbCrLf
End If
Set OutDhcp = filesys.CreateTextFile(BBext & "\dhcp", True)
OutDhcp.WriteLine Status
OutDhcp.WriteLine Scope
OutDhcp.WriteLine ""
OutDhcp.WriteLine "BBDhcp Version " & Version
Outdhcp.close
Check.close
This email and its contents are subject to an email legal notice that can be viewed at: http://www.naspers.com/disclaimer.php Should you be unable to access the link provided, please email us for a copy at csc at optinet.net<mailto:csc at optinet.net>
Hierdie e-pos en sy inhoud is onderhewig aan 'n regskennisgewing oor elektroniese pos wat gelees kan word by http://www.naspers.com/afrikaans/voorbehoud.php 'n Afskrif kan aangevra word by csc at optinet.net<mailto:csc at optinet.net>
________________________________
CONFIDENTIALITY NOTICE: This email and any attachments are for the
exclusive and confidential use of the intended recipient. If you are not
the intended recipient, please do not read, distribute or take action in
reliance upon this message. If you have received this in error, please
notify us immediately by return email and promptly delete this message
and its attachments from your computer system. We do not waive
attorney-client or work product privilege by the transmission of this
message.
participants (3)
-
Jorge.Lopes@optinet.net
-
Shea.Graeme.A@edumail.vic.gov.au
-
storerr@nibco.com