本文介绍了从SNMP到ASP网站获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们

我正在写一个连接到netbots camaras的监控网站.我正在通过HTTP端口80获取图像,但是需要使用SNMP从camaras获取值.有人有访问SNMP的代码吗?我不太熟悉.

我有一个文件,其中包含由SNMP生成的许多内容,但不知道其中发生了什么.

我的问题是我应该使用该文件还是有办法直接从netbot获取数据?

请帮帮我.

我查看了此链接上的代码: http://www.naterice.com/articles/19 [ ^ ]

但是它指定了一个连接字符串,并且我不知道如何声明它.

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.

推荐答案

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



用您的asb页面调用它,如下所示:

代码:



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>


这篇关于从SNMP到ASP网站获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 07:09