Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi people

I am writng a monitoring website that connects to netbots camaras. I am getting the images via HTTP port 80, but need to get values from the camaras using SNMP. Does anyone have code to access SNMP? I am not very familiar with it.

I have a file with lots of stuff in it that is generated by the SNMP, but don't know what is going on in it.

My question is should I use that file or is there a way to get the data straight from the netbot?

Please assist me.

I looked at the code on this link: http://www.naterice.com/articles/19[^]

But it specifies a connection string and a I don't know how to declare it.
Posted
Updated 12-Mar-10 5:31am
v2

1 solution

since nobody answered my question i went further and got a solution?

a vbscript

code:
Option Explicit
Dim objSnmpManager, objSnmpData,objSnmpData1, objConstants
Dim strCommunity,strOID, strNextOID
Dim strHostName, strValue
' Create instances of the objects
Set objSnmpManager  = CreateObject ( "ActiveXperts.SnmpManager" )
Set objConstants    = CreateObject ( "ActiveXperts.ASConstants" )
' Get host information and community information
   strHostName = "IpAddress"
   strCommunity = "Communitystring"

' Initialize SNMP
objSnmpManager.Initialize
If( objSnmpManager.LastError <> 0 ) Then
   WScript.Quit
End If
' Open SNMP session. Pass hostname and community. 
' Note: Port 161 is used by default. To specify  a different port, pass the port number as 3rd parameter (optional) 
objSnmpManager.Open strHostName, strCommunity
If( objSnmpManager.LastError = 0 ) Then
   strOID = "OID"
   If( objSnmpManager.LastError = 0 ) Then
      Set objSnmpData = objSnmpManager.Get( strOID )
         PrintSnmpData( objSnmpData )
      objSnmpManager.Close()
   End If
End If
' ********************************************************************
'  Function PrintSnmpData
' ********************************************************************
Function PrintSnmpData( objSnmpData )
   WScript.Echo objSnmpData.Value &  " %"
End Function


call it with your asb page like so:

code:
 <script language="vbscript" runat="server">
class wscript_class
function echo(s)
response.write(s)
end function
function quit()
' dummy
end function
end class
dim wscript
set wscript = new wscript_class
Include "snmp_walk.vbs"
Function Include (Scriptname)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile(Scriptname)
ExecuteGlobal oFile.ReadAll()
oFile.Close
End Function
</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900