Most networks have redundant links to provide continued connectivity in case of equipment or cable failures. Failover is generally automatic using STP or LACP protocols and it is difficult to tell if a link has failed without actively looking for it. I have written this probe so that it will provide an alert if a "critical" switchport is inactive for some reason. I am running The Dude 4 Beta 2 on Win 2K3 server. There are no doubt, improvements that can be made to this system. But for the moment it is doing what I require.
I have accepted a value of up(1) or dormant(5) as normal states for the switchports and any other state as abnormal.
There are a few different components to this probe. They are:
1. The SNMPGet executable. http://www.snmpsoft.com/freetools/snmpget.html
This is a commandline SNMP tool free for non-commercial use
2. The link-test.vbs script which I have written. It makes use of SNMPGet to retrieve the appropriate OID values:
'This script checks the link status of critical switchports. If no port is down it returns a null. If a switchport is down it returns the interface number.
'Usage: cscript link-test.vbs //NoLogo [/d] /i=<x.x.x.x> /p=<a:b:c:d:n>
' //NoLogo specifies the script engine not to output the banner
' /d switches on debug mode
' /i is the IP address of the switch
' /p is a colon delimited list of critical switchport interface numbers
'Set the defaults
Set WshShell = WScript.CreateObject("WScript.Shell")
'Get the input parameters
For ParNo=0 to (ParCount-1)
Select Case ParSwitch
if Dbg Then WScript.Echo ("Processing IP Address :" & wscript.arguments.item(ParNo))
if Dbg Then WScript.Echo ("Processing Port Numbers :" & wscript.arguments.item(ParNo))
if Dbg Then WScript.Echo ("Second Port Number:" & PortArray(1))
WScript.Echo ("Debugging output is enabled")
For Each PortNo in PortArray
if Dbg Then wscript.echo("Port Number = " & PortNo)
PortCommand = chr(34) & SnmpGet & chr(34) & " -q -r:" & IPAddr & " -o:184.108.40.206.220.127.116.11.1.8." & PortNo
if Dbg Then wscript.echo("Command = " & PortCommand)
Set oExec = WshShell.Exec(PortCommand)
PortState = oExec.StdOut.ReadLine
if Dbg Then wscript.echo("Port state = " & PortState)
if not(PortState="1" or PortState="5") then DownPorts = DownPorts & PortNo & ","
3. The Link-Test.Bat batch script which is the conduit between The Dude and the VB script
cscript link-test.vbs //NoLogo /i=%1 /p=%2
4. The Dude Probe itself:
for those like me with old eyes:
Error: if(string_size(array_element(execute("link-test.bat",concatenate(device_property("FirstAddress")," ", device_property("CustomField2")),"c:\\snmpget"),1))<3,"",concatenate("Ports ",array_element(execute("link-test.bat",concatenate(device_property("FirstAddress")," ", device_property("CustomField2")),"c:\\snmpget"),1) ," have failed"))
5. The Dude Device configuration panel. Switchports that are critical are to be listed in Custom Field 2 as a colon separated list.
Unfortunately the probe returns two unprintable characters under normal circumstances and if a port (or ports) go down these characters are also appended to the result. I am not sure what they are or why they are there. I have spent enough time on this already and have decided to ignore them and make allowances that they are there hence the test for string_size<3.
I hope this is of use to others and if someone can improve on it, then go for it.
You do not have the required permissions to view the files attached to this post.