第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

只走特定的節(jié)點(diǎn)

只走特定的節(jié)點(diǎn)

狐的傳說 2021-05-07 14:27:20
我正在構(gòu)建一個(gè)腳本,該腳本應(yīng)該通過SNMP(漫游)從調(diào)制解調(diào)器獲取MAC / IP地址。為此,我正在使用PySNMP和nextCmd(asyncore)。盡管我得到了想要的東西,但是目前我得到的比預(yù)期的要多:在特定節(jié)點(diǎn)上行走之后,它會與剩下的所有其他節(jié)點(diǎn)一起繼續(xù)工作。代碼:nextCmd(snmpEngine,        CommunityData('private'),        UdpTransportTarget(('IP.goes.right.here', 161)),        ContextData(),        ObjectType(ObjectIdentity('1.3.6.1.2.1.4.22.1.2')),        cbFun=cbFun)snmpEngine.transportDispatcher.runDispatcher()cbFundef cbFun(snmpEngine, sendRequestHandle, errorIndication,      errorStatus, errorIndex, varBindTable, cbCtx):if errorIndication:    print(errorIndication)    returnelif errorStatus:    print('%s at %s' % (errorStatus.prettyPrint(),                        errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))    returnelse:    for varBindRow in varBindTable:        for varBind in varBindRow:            print(' = '.join([x.prettyPrint() for x in varBind]))return True 這純粹是基于文檔和Internet上的其他一些示例。樣本輸出:1.3.6.1.2.1.4.22.1.2.536870914.some.ip.was.here = 0xMacAddress1.3.6.1.2.1.4.22.1.3.1182728.some.ip.was.here = some.ip.was.here  # next node1.3.6.1.2.1.4.22.1.4.1182736.some.ip.was.here = 3  # and even further...因此,這樣做的意圖僅限于步行1.3.6.1.2.1.4.22.1.2。PS我只是從PySNMP開始,我想要類似 snmpwalk -v 2c -c private some.ip.was.here ipNetToPhysicalPhysAddress
查看完整描述

2 回答

?
Cats萌萌

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超9個(gè)贊

缺少解決此問題的任何內(nèi)置方法,我對進(jìn)行了更改cbFun()?,F(xiàn)在,它包含一些額外的行,re.search()并且pattern是OID(因此,如果pattern不匹配,即nextCmd轉(zhuǎn)到另一個(gè)級別(節(jié)點(diǎn)),它就可以了return)。我已經(jīng)很簡單了,因?yàn)橐呀?jīng)構(gòu)造了帶有response的字符串print(' = '.join([x.prettyPrint() for x in varBind])),所以我已經(jīng)添加了if條件,并將上面代碼的結(jié)果分配給了變量,因此使實(shí)現(xiàn)此檢查成為可能。

作為另一種可能的解決方案,也可以使用示例中描述的方法-使用varBindHead并進(jìn)行比較。

隨時(shí)添加您的解決方案。


查看完整回答
反對 回復(fù) 2021-05-11
  • 2 回答
  • 0 關(guān)注
  • 294 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號