准备开发网络管理软件,需要用到snmp,c#,oid,要获取每个设备对应的oid值的对应的值,请问有什么思路?

ruan1978 2024-06-18 22:08:55

想用c#,snmp协议去获取某个交换机设备的各种信息,比如运行的cpu的使用率、内存的使用情况、端口的开关状态,通过端口的流量等数据。做过的人能否给一个思路。如果通用化的去开发,可能会有很多这种设备,型号都不一样,它的oid值都是各不相同的,请问如何去实现和思路。

...全文
198 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nvsyp54166 5小时前
  • 打赏
  • 举报
回复

https://h5.weishi.qq.com/weishi/feed/7SQUsyI4e1SwioKqi
https://h5.weishi.qq.com/weishi/feed/7SQV07SEs1SwioIcY
https://h5.weishi.qq.com/weishi/feed/7SQZxwt9W1SwioIs2
https://h5.weishi.qq.com/weishi/feed/7SR3HmSrO1SwioJGO
https://h5.weishi.qq.com/weishi/feed/7SQW6ha021SwioIgU
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1SwioIGW
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1SwioKw8
https://h5.weishi.qq.com/weishi/feed/7SR4XgmNR1SwioEmi
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1SwioFaq
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhl1SwioEaa
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1SwioFUk
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1SwioFQq
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1SwioFgI
https://h5.weishi.qq.com/weishi/feed/7SR3X4knx1SwioH0Q
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1SwioFgi
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhm1SwioFOo
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1SwioF66
https://h5.weishi.qq.com/weishi/feed/7SR3CdZkS1SwioDAC
https://h5.weishi.qq.com/weishi/feed/7SR3G9lOB1SwioEsg
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCd1SwioCuw
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1SwioBAA
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1SwioB6u
https://h5.weishi.qq.com/weishi/feed/7SQVQzI2w1SwioAGe
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1SwioA2A
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1SwioCYq
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1SwioCMA
https://h5.weishi.qq.com/weishi/feed/7SR4WVo4q1SwioyM8
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1SwioBMU
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1SwioyCs
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1SwioAoI
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81Swioyku
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1Swioy6s
https://h5.weishi.qq.com/weishi/feed/7SQXMLDYP1SwiovCc
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01SwioyCq
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1SwiovY0
https://h5.weishi.qq.com/weishi/feed/7SR3IINn81Swiovce
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1SwioxSy
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1Swioys2
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1Swiov4o
https://h5.weishi.qq.com/weishi/feed/7SQV07SEs1SwiosU4
https://h5.weishi.qq.com/weishi/feed/7SQW6C8JD1SwiovCW
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1SwiougY
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1Swiot6W
https://h5.weishi.qq.com/weishi/feed/7SR45FcX51SwiouKe
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1Swiouwy
https://h5.weishi.qq.com/weishi/feed/7SQUsyI4e1Swiot0A
https://h5.weishi.qq.com/weishi/feed/7SR3X4knx1SwiosQ4
https://h5.weishi.qq.com/weishi/feed/7SR3yLZSq1Swioqca
https://h5.weishi.qq.com/weishi/feed/7SQZxwt9W1SwiosGA
https://h5.weishi.qq.com/weishi/feed/7SR3HmSrO1Swios4Q
https://h5.weishi.qq.com/weishi/feed/7SQW6ha021SwioqiS
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1SwioroS
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1SwiorI4
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhm1Swiopq6
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1Swiooaq
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1SwionQu
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1SwiopWU
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011SwioqYE
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1Swiopwc
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1SwiooOs
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1SwiooCW
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgG1SwiopoI
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1SwionCC
https://h5.weishi.qq.com/weishi/feed/7SR3G9lOB1Swiom4e
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1SwiolCm
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy71SwiokUI
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1SwiolsK
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1Swiolsk
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1SwioliW
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1Swioj4Q
https://h5.weishi.qq.com/weishi/feed/7SQVQzI2w1SwiolI6
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81Swiok8s
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1Swioke0
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1SwiofUW
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01Swiojw4
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1SwioiY0
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1SwiogKK
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1SwiofiU
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1Swiog8Y
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1SwioiUw
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1SwiofQU
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1SwiojMo
https://h5.weishi.qq.com/weishi/feed/7SR3IINn81Swioh0G
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1SwioekS

nvsyp54166 5小时前
  • 打赏
  • 举报
回复

https://h5.weishi.qq.com/weishi/feed/7SR67tp0j1SwipWG8
https://h5.weishi.qq.com/weishi/feed/7SR62S51X1SwipVuu
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1SwipTy2
https://h5.weishi.qq.com/weishi/feed/7SR60UoMr1SwipTug
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1SwipPCW
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1SwipTEI
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1SwipSuO
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1SwipSsS
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhl1SwipNQC
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011SwipOS6
https://h5.weishi.qq.com/weishi/feed/7SQXuqyjp1SwipRYy
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1SwipR4W
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1SwipRwk
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhm1SwipPAG
https://h5.weishi.qq.com/weishi/feed/7SR60631j1SwipPoU
https://h5.weishi.qq.com/weishi/feed/7SR3CdZkS1SwipPw4
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1SwipP4W
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1SwipNgK
https://h5.weishi.qq.com/weishi/feed/7SR5Ytlve1SwipNuO
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1SwipMOI
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1SwipLEW
https://h5.weishi.qq.com/weishi/feed/7SR3IINn81SwipJka
https://h5.weishi.qq.com/weishi/feed/7SR5YWIwJ1SwipMWc
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1SwipIiS
https://h5.weishi.qq.com/weishi/feed/7SR5Ytlvf1SwipLKK
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01SwipJyG
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1SwipJSC
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1SwipKQk
https://h5.weishi.qq.com/weishi/feed/7SR5U4BZ31SwipJ64
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1SwipI4U
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1SwipHSO
https://h5.weishi.qq.com/weishi/feed/7SR5RHKR31SwipI2u
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1SwipICi
https://h5.weishi.qq.com/weishi/feed/7SR5VTTWh1SwipHMm
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCd1SwipGUg
https://h5.weishi.qq.com/weishi/feed/7SR5ONkyO1SwipGcM
https://h5.weishi.qq.com/weishi/feed/7SR5VHjv21SwipGQ6
https://h5.weishi.qq.com/weishi/feed/7SR3X4knx1SwipFI4
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1SwipGgy
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1SwipFYG
https://h5.weishi.qq.com/weishi/feed/7SR5XVMkD1SwipFwe
https://h5.weishi.qq.com/weishi/feed/7SQXMLDYP1SwipEeU
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1SwipDUG
https://h5.weishi.qq.com/weishi/feed/7SQW6C8JD1SwipD2y
https://h5.weishi.qq.com/weishi/feed/7SR45FcX51SwipFmg
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81SwipEG6
https://h5.weishi.qq.com/weishi/feed/7SQW6ha021SwipBaw
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCc1SwipDAY
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1SwipEwk
https://h5.weishi.qq.com/weishi/feed/7SQV07SEs1SwipB22
https://h5.weishi.qq.com/weishi/feed/7SR5UOLB21SwipAKe
https://h5.weishi.qq.com/weishi/feed/7SR4WVo4q1SwipAGY
https://h5.weishi.qq.com/weishi/feed/7SR5UOLB11SwipzI4
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgG1SwipyyC
https://h5.weishi.qq.com/weishi/feed/7SQXuqyjp1SwipyQM
https://h5.weishi.qq.com/weishi/feed/7SR3HmSrO1SwipzWW
https://h5.weishi.qq.com/weishi/feed/7SQZxwt9W1Swipz8k
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1Swipyq2
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1SwipzWs
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1SwipxG0
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhl1SwipwaC
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1Swipx8i
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1SwipwGS
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1SwipvG8
https://h5.weishi.qq.com/weishi/feed/7SR3CdZkS1SwipwAe
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhm1SwipvgY
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1SwipwcO
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1SwipuY4
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1Swipv2a
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1SwipuKG
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1Swipu80
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1Swipuea
https://h5.weishi.qq.com/weishi/feed/7SR4XgmNR1Swips4k
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1Swipt8C
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1SwipuuW
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1SwiptC4
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1Swipry8
https://h5.weishi.qq.com/weishi/feed/7SR5U4BZ31SwipsWw
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01Swipry4
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011SwipsE0
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1Swipsm2
https://h5.weishi.qq.com/weishi/feed/7SR5RHKR31Swipqo4
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCd1SwiprcO
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1Swippoa
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1Swippqe
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1SwipqsI
https://h5.weishi.qq.com/weishi/feed/7SQXMLDYP1SwipoUM
https://h5.weishi.qq.com/weishi/feed/7SQW6C8JD1Swipno0
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1SwippAk
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1SwipqOs
https://h5.weishi.qq.com/weishi/feed/7SR3X4knx1Swipnqs
https://h5.weishi.qq.com/weishi/feed/7SR5ONkyO1SwipoE8
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81SwipmyK
https://h5.weishi.qq.com/weishi/feed/7SR45FcX51SwiplIq
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1SwiplOy
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCc1SwipkSo
https://h5.weishi.qq.com/weishi/feed/7SQV07SEs1Swipkwi
https://h5.weishi.qq.com/weishi/feed/7SQW6ha021Swipiew
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1SwipmqQ
https://h5.weishi.qq.com/weishi/feed/7SR4WVo4q1SwiplyS
https://h5.weishi.qq.com/weishi/feed/7SQZxwt9W1Swipjaw
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1SwipjUo
https://h5.weishi.qq.com/weishi/feed/7SQUsyI4e1Swipiiu
https://h5.weishi.qq.com/weishi/feed/7SR3HmSrO1SwipiQK
https://h5.weishi.qq.com/weishi/feed/7SR3CdZkS1SwiphIi
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1SwipgEW
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1SwipjkO
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1Swipgwe
https://h5.weishi.qq.com/weishi/feed/7SQXuqyjp1Swipi0S
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgG1SwipgyK
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1SwipgqE
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1Swipfqi
https://h5.weishi.qq.com/weishi/feed/7SR4XgmNR1Swipf0m
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1Swipc2o
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1Swipf8g
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011SwipeWE
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1Swipecc
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01SwipaUA
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1Swipeem
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1Swipe2E
https://h5.weishi.qq.com/weishi/feed/7SR5PkTJs1Swipe6q
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCd1SwipamO
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1Swip9Ka
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1SwipcSQ
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1Swip6ug
https://h5.weishi.qq.com/weishi/feed/7SQVQzI2w1Swip7cE
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1Swip8oA
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1Swip9QY
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81Swip6qS
https://h5.weishi.qq.com/weishi/feed/7SR5ONkyO1Swip7Go
https://h5.weishi.qq.com/weishi/feed/7SQW6C8JD1Swip6cg
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1Swip8gG
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1Swip6my
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1Swip5ia
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1Swip62e
https://h5.weishi.qq.com/weishi/feed/7SR3HmSrO1Swip0u2
https://h5.weishi.qq.com/weishi/feed/7SR3IINn81Swip5MW
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1Swip5sU
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1Swip5Ay
https://h5.weishi.qq.com/weishi/feed/7SR45FcX51Swip5Oa
https://h5.weishi.qq.com/weishi/feed/7SR3X4knx1Swip3sc
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1Swip5SC
https://h5.weishi.qq.com/weishi/feed/7SR4WVo4q1Swip4W4
https://h5.weishi.qq.com/weishi/feed/7SQXMLDYP1Swip3QQ
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1Swip2wG
https://h5.weishi.qq.com/weishi/feed/7SQZxwt9W1Swip3wA
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCc1Swip2G0
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1Swip20Y
https://h5.weishi.qq.com/weishi/feed/7SQUsyI4e1Swip2y8
https://h5.weishi.qq.com/weishi/feed/7SR3ScdQt1SwioR88
https://h5.weishi.qq.com/weishi/feed/7SQV07SEs1Swip20w
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhm1Swip0E4
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1Swip2S2
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgD1Swip1Qc
https://h5.weishi.qq.com/weishi/feed/7SR4bu3wy1SwioTsY
https://h5.weishi.qq.com/weishi/feed/7SQW6ha021Swip2IE
https://h5.weishi.qq.com/weishi/feed/7SQW6GkSJ1Swip1mI
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgG1Swip0aw
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1Swip2Ag
https://h5.weishi.qq.com/weishi/feed/7SQXuqyjp1Swip04K
https://h5.weishi.qq.com/weishi/feed/7SR3CdZkS1SwioY0m
https://h5.weishi.qq.com/weishi/feed/7SQWm70fz1Swip0o0
https://h5.weishi.qq.com/weishi/feed/7SQZzTkhl1Swip0mE
https://h5.weishi.qq.com/weishi/feed/7SQZySo5g1SwioYUQ
https://h5.weishi.qq.com/weishi/feed/7SR5PkTJs1Swip0qe
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011Swip06i
https://h5.weishi.qq.com/weishi/feed/7SR4XgmNR1SwioWac
https://h5.weishi.qq.com/weishi/feed/7SR420D3I1SwioYGw
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgE1SwioVUe
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJH1SwioXUU
https://h5.weishi.qq.com/weishi/feed/7SR3SxczO1SwioYwq
https://h5.weishi.qq.com/weishi/feed/7SQUbr90Y1SwioVuQ
https://h5.weishi.qq.com/weishi/feed/7SQXNzZJJ1SwioVYO
https://h5.weishi.qq.com/weishi/feed/7SQXNf10l1SwioVkG
https://h5.weishi.qq.com/weishi/feed/7SQWH5JCG1SwioRQa
https://h5.weishi.qq.com/weishi/feed/7SQWGCmB01SwioUSg
https://h5.weishi.qq.com/weishi/feed/7SQXylUNO1SwioU0K
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCd1SwioSga
https://h5.weishi.qq.com/weishi/feed/7SQVQzI2w1SwioQkY
https://h5.weishi.qq.com/weishi/feed/7SQZytdcT1SwioQ2U
https://h5.weishi.qq.com/weishi/feed/7SQZytdcS1SwioOo6
https://h5.weishi.qq.com/weishi/feed/7SQW86rXl1SwioPY0
https://h5.weishi.qq.com/weishi/feed/7SR5ONkyO1SwioOWm
https://h5.weishi.qq.com/weishi/feed/7SQXNaORd1SwioNYm
https://h5.weishi.qq.com/weishi/feed/7SR3IINn81SwioNWK
https://h5.weishi.qq.com/weishi/feed/7SQXNaORc1SwioOCU
https://h5.weishi.qq.com/weishi/feed/7SR42Cons1SwioMYW
https://h5.weishi.qq.com/weishi/feed/7SR4WVo4q1SwioPco
https://h5.weishi.qq.com/weishi/feed/7SQW5x0of1SwioOsu
https://h5.weishi.qq.com/weishi/feed/7SR3XBTy81SwioMsQ
https://h5.weishi.qq.com/weishi/feed/7SQXNZaCc1SwioKMO
https://h5.weishi.qq.com/weishi/feed/7SQW6C8JD1SwioLoa
https://h5.weishi.qq.com/weishi/feed/7SQXMLDYP1SwioJuG
https://h5.weishi.qq.com/weishi/feed/7SR45FcX51SwioLYo
https://h5.weishi.qq.com/weishi/feed/7SQW6ha011SwioGoU
https://h5.weishi.qq.com/weishi/feed/7SQZy42kw1SwioKqK
https://h5.weishi.qq.com/weishi/feed/7SQXuqyjp1SwioI2M
https://h5.weishi.qq.com/weishi/feed/7SQW6GkSJ1SwioLSi
https://h5.weishi.qq.com/weishi/feed/7SR3Z6cLK1SwioLMS
https://h5.weishi.qq.com/weishi/feed/7SQZySo5f1SwioGoW
https://h5.weishi.qq.com/weishi/feed/7SQW5WbgG1SwioI4c

  • 打赏
  • 举报
回复

要使用C#和SNMP协议来获取网络设备(如交换机)的各种信息,您可以遵循以下思路进行开发。由于不同设备的OID(对象标识符)可能不同,需要通用化设计,以便适应各种设备。以下是详细的实现思路和步骤:

  1. 准备工作
    安装SNMP库
    使用C#开发SNMP应用程序,可以使用开源的SNMP库,如 SnmpSharpNet。首先需要安装该库:
Install-Package Lextm.SharpSnmpLib

  1. 获取设备信息的基本步骤
    创建SNMP管理器类
using System;
using System.Collections.Generic;
using Lextm.SharpSnmpLib;
using Lextm.SharpSnmpLib.Messaging;
using Lextm.SharpSnmpLib.Security;
using Lextm.SharpSnmpLib.Pipeline;

public class SnmpManager
{
    private string _host;
    private string _community;
    private int _port;
    private VersionCode _version;

    public SnmpManager(string host, string community, int port = 161, VersionCode version = VersionCode.V2)
    {
        _host = host;
        _community = community;
        _port = port;
        _version = version;
    }

    public IList<Variable> Get(Oid oid)
    {
        var result = Messenger.Get(_version, new IPEndPoint(IPAddress.Parse(_host), _port), new OctetString(_community), new List<Variable> { new Variable(oid) }, 2000);
        return result;
    }

    public void Walk(Oid oid, Action<Variable> callback)
    {
        var store = new ObjectStore();
        var receiver = new TrapV1MessageHandler(store);
        var result = new List<Variable>();
        Messenger.Walk(_version, new IPEndPoint(IPAddress.Parse(_host), _port), new OctetString(_community), oid, result, WalkMode.WithinSubtree, 2000, receiver, callback);
    }
}

  1. 获取设备信息
    CPU使用率
public static void GetCpuUsage(SnmpManager manager)
{
    var oid = new Oid("1.3.6.1.4.1.9.2.1.56.0"); // 示例OID,需要根据设备具体情况调整
    var result = manager.Get(oid);
    foreach (var variable in result)
    {
        Console.WriteLine($"{variable.Data}");
    }
}

内存使用情况

public static void GetMemoryUsage(SnmpManager manager)
{
    var oid = new Oid("1.3.6.1.4.1.9.2.1.8.0"); // 示例OID,需要根据设备具体情况调整
    var result = manager.Get(oid);
    foreach (var variable in result)
    {
        Console.WriteLine($"{variable.Data}");
    }
}

端口状态和流量

public static void GetPortStatus(SnmpManager manager)
{
    var oid = new Oid("1.3.6.1.2.1.2.2.1.8"); // ifOperStatus OID
    manager.Walk(oid, variable =>
    {
        Console.WriteLine($"{variable.Id}: {variable.Data}");
    });
}

public static void GetPortTraffic(SnmpManager manager)
{
    var oid = new Oid("1.3.6.1.2.1.2.2.1.10"); // ifInOctets OID
    manager.Walk(oid, variable =>
    {
        Console.WriteLine($"{variable.Id}: {variable.Data}");
    });
}

  1. 通用化设计
    为了适应不同设备的OID值,需要建立一个配置文件或者数据库,用于存储不同设备的OID信息。可以使用JSON或XML格式的配置文件:

示例配置文件(JSON)

{
    "devices": {
        "default": {
            "cpuUsage": "1.3.6.1.4.1.9.2.1.56.0",
            "memoryUsage": "1.3.6.1.4.1.9.2.1.8.0",
            "portStatus": "1.3.6.1.2.1.2.2.1.8",
            "portTraffic": "1.3.6.1.2.1.2.2.1.10"
        },
        "deviceA": {
            "cpuUsage": "1.3.6.1.4.1.2021.11.50.0",
            "memoryUsage": "1.3.6.1.4.1.2021.4.6.0",
            "portStatus": "1.3.6.1.2.1.2.2.1.8",
            "portTraffic": "1.3.6.1.2.1.2.2.1.10"
        }
    }
}

加载配置文件

public class SnmpConfiguration
{
    public Dictionary<string, Dictionary<string, string>> Devices { get; set; }

    public static SnmpConfiguration Load(string filePath)
    {
        var json = File.ReadAllText(filePath);
        return JsonConvert.DeserializeObject<SnmpConfiguration>(json);
    }
}

使用配置文件获取OID


public class SnmpManager
{
    private string _host;
    private string _community;
    private int _port;
    private VersionCode _version;
    private Dictionary<string, string> _oids;

    public SnmpManager(string host, string community, Dictionary<string, string> oids, int port = 161, VersionCode version = VersionCode.V2)
    {
        _host = host;
        _community = community;
        _port = port;
        _version = version;
        _oids = oids;
    }

    public IList<Variable> Get(string oidKey)
    {
        if (_oids.TryGetValue(oidKey, out string oidValue))
        {
            var oid = new Oid(oidValue);
            return Messenger.Get(_version, new IPEndPoint(IPAddress.Parse(_host), _port), new OctetString(_community), new List<Variable> { new Variable(oid) }, 2000);
        }
        throw new ArgumentException("Invalid OID key");
    }

    public void Walk(string oidKey, Action<Variable> callback)
    {
        if (_oids.TryGetValue(oidKey, out string oidValue))
        {
            var oid = new Oid(oidValue);
            var store = new ObjectStore();
            var receiver = new TrapV1MessageHandler(store);
            var result = new List<Variable>();
            Messenger.Walk(_version, new IPEndPoint(IPAddress.Parse(_host), _port), new OctetString(_community), oid, result, WalkMode.WithinSubtree, 2000, receiver, callback);
        }
        else
        {
            throw new ArgumentException("Invalid OID key");
        }
    }
}

使用示例


var config = SnmpConfiguration.Load("config.json");
var oids = config.Devices["deviceA"];
var manager = new SnmpManager("192.168.1.1", "public", oids);

GetCpuUsage(manager);
GetMemoryUsage(manager);
GetPortStatus(manager);
GetPortTraffic(manager);

总结
使用SnmpSharpNet库与SNMP设备交互。
定义一个通用的SNMP管理类,封装SNMP的Get和Walk操作。
使用配置文件存储不同设备的OID信息,实现通用化设计。
根据不同设备的配置加载对应的OID信息,调用SNMP管理类的方法获取设备信息。
通过以上步骤,您可以开发一个通用化的SNMP管理工具,适用于不同型号的网络设备。

ruan1978 06-30
  • 举报
回复
@清风明月9987321 您方便吗?想加个qq或者vx,单独再请教下。

110,820

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧