[Xymon] DHCP monitoring

Jorge Lopes Jorge.Lopes at optinet.net
Sun Feb 23 22:19:24 CET 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20140223/14f9e8e7/attachment.html>


More information about the Xymon mailing list