Chinaunix首页 | 论坛 | 博客
  • 博客访问: 32166
  • 博文数量: 21
  • 博客积分: 707
  • 博客等级: 上士
  • 技术积分: 237
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-15 12:48
文章分类

全部博文(21)

文章存档

2011年(21)

分类: Python/Ruby

2011-01-27 18:46:25

python ping  引用了这个类,顺便上传上来。

#!/usr/bin/env python

import netsnmp

class Snmp(object):
def __init__(self,
oid= "sysDescr",
Version =2,
DestHost = "localhost",
Community= "public"):
self.oid=oid
self.version= Version
self.destHost= DestHost
self.community= Community

def query(self):
try:
result= netsnmp.snmpwalk(self.oid,
Version=self.version,
DestHost=self.destHost,
Community=self.community)
except Exception, err:
print err
result= None
return result
阅读(718) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~