Showing posts with label WhatsUp Gold. Show all posts
Showing posts with label WhatsUp Gold. Show all posts

Friday, June 10, 2011

Whatsup Gold -- Device Updates

We use some of the wonderful scripts found the ipswitch script library to update our device attributes (in v14.3.x). Below is a version of the vbs to update the location setting on a cisco 2960-3560 model switch. It will work on others, but use the snmpwalker to your advantage. Credit goes to the original poster (I'm still trying to find the original article). Use at your own risk. YMMV.

' Get action on SNMP OID to retrieve values

set snmp = CreateObject("CoreAsp.SnmpRqst")
nDeviceID = Context.GetProperty("DeviceID")
set result = snmp.Initialize(nDeviceID)
set result = snmp.Get("1.3.6.1.2.1.1.6.0")
If Not result.Failed Then
value = result.GetPayload
End If

' Retrieve DB object
Set oDb = Context.GetDB
RESULT_ATTRIBUTE = "Location"
nDeviceID = Context.GetProperty("DeviceID")

' Checking if the attribute already exists. If not we create one, if yes we simply update it.
sqlCheck = "SELECT nDeviceAttributeID FROM DeviceAttribute WHERE (nDeviceID = " & nDeviceID & ") AND (sName = N'" & RESULT_ATTRIBUTE & "')"
Set oRs1 = oDb.Execute(sqlCheck)

' Storing it in DB as needed.
If oRs1.EOF Then
sqlStoreResult = "INSERT INTO DeviceAttribute (nDeviceID, sName, sValue) VALUES (" & _
nDeviceID & ", N'" & RESULT_ATTRIBUTE & "', N'" & value & "')"
Else
sqlStoreResult = "UPDATE DeviceAttribute SET sValue = N'" & value & _
"' WHERE (nDeviceID = " & nDeviceID & ") AND (sName = N'" & RESULT_ATTRIBUTE & "')"
End If

oDb.Execute(sqlStoreResult)

--

To tweak, modify the snmp oid in the snmp get statement and change the RESULT.ATTRIBUTE = statement to what are you retrieving. Simple enough. On our switches we snag location, code version, vendor, model, serial and some others.

Thursday, June 9, 2011

Whatsup Gold -- Back-End SQL for device attributes

I hate maintaining spreadsheets when my group and I have documented our network via whatsup gold. However, extracting that information for various reason has been a pain. I use this script on the back-end to grab devices by campus with the svalues (our defined attributes of importance). FYI, I'm not a SQL person by any stretch. I'm sure the code could be much better (and I'll take the helpful tips). AssetTag and GPTAG are -usually- the same value for us. replace sName = with your values and you should have some luck. Change the sNetworkAddress = to your subnets, etc.
No idea how to pull this into a webpage. I tried. It blew up. We needed the extract in csv so this was good enough. YMMV. I am not an expert. Use at your own risk.



SELECT DISTINCT Device.sDisplayName as DisplayName
,NetworkInterface.sNetworkAddress AS IPAddress
,(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'SerialNumber' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) as SerialNumber
,(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'Name' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) as Hostname,
(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'Location' AND (DeviceAttribute.nDeviceID = Device.nDeviceID))AS Location,
(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'Model' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) AS Model,
(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'GPTAG' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) AS GPTAG,
(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'AssetTag' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) AS AssetTag,
(SELECT DeviceAttribute.sValue FROM DeviceAttribute WHERE DeviceAttribute.sName = 'MACAddress' AND (DeviceAttribute.nDeviceID = Device.nDeviceID)) AS MACAddress
FROM Device JOIN DeviceAttribute ON Device.nDeviceID = DeviceAttribute.nDeviceIDJOIN NetworkInterface ON Device.nDeviceID = NetworkInterface.nDeviceID
WHERE NetworkInterface.sNetworkAddress LIKE '10.63%'ORDER BY IPAddress


PS -- I can send you the raw sql if you desire. Learning mode....