• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python snmp_helper.snmp_get_oid_v3函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中snmp_helper.snmp_get_oid_v3函数的典型用法代码示例。如果您正苦于以下问题:Python snmp_get_oid_v3函数的具体用法?Python snmp_get_oid_v3怎么用?Python snmp_get_oid_v3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了snmp_get_oid_v3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    a_user = 'pysnmp'
    auth_key = 'galileo1'
    encrypt_key = 'galileo1'
    rtr_ip = '50.76.53.27'
    snmp_user = (a_user, auth_key, encrypt_key)

    #prev_rtr1_info = pickle.load(f)
    #print(prev_rtr1_info)
    #prev_rtr2_info = pickle.load(f)
    #print(prev_rtr2_info)

    f = open(device_file, "wb")

    pynet_rtr1 = (rtr_ip, 7961)
    pynet_rtr2 = (rtr_ip, 8061)

    for router in (pynet_rtr1, pynet_rtr2):
        rtr_name = snmp_get_oid_v3(router,snmp_user,oid=router_name)
        rtr_description = snmp_get_oid_v3(router,snmp_user,oid=router_description)
        rtr_uptime = snmp_get_oid_v3(router,snmp_user,oid=router_uptime)
        last_changed = snmp_get_oid_v3(router,snmp_user,oid=config_last_changed)

        name_output = snmp_extract(rtr_name)
        desc_output = snmp_extract(rtr_description)
        uptime_output = snmp_extract(rtr_uptime)
        changed_output = snmp_extract(last_changed)
    
        device_info = (name_output,desc_output,uptime_output,changed_output)

        pickle.dump(device_info, f)
    f.close()
开发者ID:jordanwimb,项目名称:kbpython,代码行数:32,代码来源:get_device_info.py


示例2: get_sysinfo

	def get_sysinfo(self):
		# Uptime when running config last changed
		ccmHistoryRunningLastChanged = '1.3.6.1.4.1.9.9.43.1.1.1.0'   

		# Uptime when running config last saved (note any 'write' constitutes a save)    
		ccmHistoryRunningLastSaved = '1.3.6.1.4.1.9.9.43.1.1.2.0'   

		# Uptime when startup config last saved   
		ccmHistoryStartupLastChanged = '1.3.6.1.4.1.9.9.43.1.1.3.0'

		#system uptime
		sysUptime = '1.3.6.1.2.1.1.3.0'

		oidRunningLastChanged = snmp_helper.snmp_get_oid_v3(self.a_device, self.snmp_user, ccmHistoryRunningLastChanged, display_errors=True)
		self.RunningLastChanged = snmp_helper.snmp_extract(oidRunningLastChanged)
		oidRunningLastSaved = snmp_helper.snmp_get_oid_v3(self.a_device, self.snmp_user, ccmHistoryRunningLastSaved, display_errors=True)
		self.RunningLastSaved = snmp_helper.snmp_extract(oidRunningLastSaved)
		oidStartupLastChanged = snmp_helper.snmp_get_oid_v3(self.a_device, self.snmp_user, ccmHistoryStartupLastChanged, display_errors=True)
		self.StartupLastChanged = snmp_helper.snmp_extract(oidStartupLastChanged)
		sysuptime_oid = snmp_helper.snmp_get_oid_v3(self.a_device, self.snmp_user, sysUptime, display_errors=True)
		self.sysuptime = snmp_helper.snmp_extract(sysuptime_oid)
		sysname_oid = snmp_helper.snmp_get_oid_v3(self.a_device, self.snmp_user, '.1.3.6.1.2.1.1.5.0', display_errors=True)
		self.sysName = snmp_helper.snmp_extract(sysname_oid)
		print "\n" + self.sysName
		print "uptime %s" % self.sysuptime
		self.RunningLastChangedDelta = int(self.sysuptime) - int(self.RunningLastChanged)
		self.RunningLastSavedDelta = int(self.sysuptime) - int(self.RunningLastSaved)
		self.StartupLastChangedDelta = int(self.sysuptime) - int(self.StartupLastChanged)
		print "running changed %s delta %i minutes" % (self.RunningLastChanged, self.RunningLastChangedDelta/6000)
		print "running saved %s delta %i minutes" % (self.RunningLastSaved, self.RunningLastSavedDelta/6000)
		print "startup changed %s delta %i minutes" % (self.StartupLastChanged, self.StartupLastChangedDelta/6000)
开发者ID:Mattinet,项目名称:pynet-class3,代码行数:31,代码来源:q1_snmp.py


示例3: was_config_changed

def was_config_changed( router, snmp_user ):

    # System up time
    sysUptimeOID = '1.3.6.1.2.1.1.3.0'
    # Uptime when running config last changed
    ccmHistoryRunningLastChanged = '1.3.6.1.4.1.9.9.43.1.1.1.0'   

    # Uptime when running config last saved (note any 'write' constitutes a save)    
    ccmHistoryRunningLastSaved = '1.3.6.1.4.1.9.9.43.1.1.2.0'   

    # Uptime when startup config last saved   
    ccmHistoryStartupLastChanged = '1.3.6.1.4.1.9.9.43.1.1.3.0'

    snmp_data = snmp_helper.snmp_get_oid_v3(router, snmp_user, oid=sysUptimeOID)
    router_uptime = int(snmp_helper.snmp_extract(snmp_data))
#    print 'uptime:  ' + str( router_uptime ) + ': ' + covert_seconds_to_human_time( router_uptime )

    snmp_data = snmp_helper.snmp_get_oid_v3(router, snmp_user, oid=ccmHistoryRunningLastChanged)
    running_last_change_time = int(snmp_helper.snmp_extract(snmp_data))
#    print 'running last change: ' + str( running_last_change_time ) + ' ' + str( router_uptime - running_last_change_time )

    snmp_data = snmp_helper.snmp_get_oid_v3(router, snmp_user, oid=ccmHistoryRunningLastSaved)
    running_last_save_time = int(snmp_helper.snmp_extract(snmp_data))
#    print 'running last save:   ' + str( running_last_save_time ) + ' ' + str( router_uptime - running_last_save_time )

    snmp_data = snmp_helper.snmp_get_oid_v3(router, snmp_user, oid=ccmHistoryStartupLastChanged)
    startup_last_change_time = int(snmp_helper.snmp_extract(snmp_data))
#    print 'startup last change: ' + str( startup_last_change_time ) + ' ' + str( router_uptime - startup_last_change_time )

    if (running_last_change_time > 600 and (running_last_change_time > startup_last_change_time)):
        output = covert_seconds_to_human_time(router_uptime - running_last_change_time) + 'since last change of running config\n'
        output += covert_seconds_to_human_time(router_uptime - startup_last_change_time) + 'since last save of running config\n'
        return output

    return ''
开发者ID:kadamski-york,项目名称:pynet_testz,代码行数:35,代码来源:save_needed_check.py


示例4: main

def main():
    a_user = 'pysnmp'
    auth_key = 'galileo1'
    encrypt_key = 'galileo1'
    rtr_ip = '50.76.53.27'
    snmp_user = (a_user, auth_key, encrypt_key)
    f = open(device_file, "rb")

    #prev_rtr1_info = pickle.load(f)
    #prev_rtr2_info = pickle.load(f)
    #f.close()

    pynet_rtr1 = (rtr_ip, 7961)
    pynet_rtr2 = (rtr_ip, 8061)


    if hostname == "pynet-rtr1":
        router = pynet_rtr1
    elif hostname == "pynet-rtr2":
        router = pynet_rtr2

    rtr_name = snmp_get_oid_v3(router,snmp_user,oid=router_name)
    rtr_description = snmp_get_oid_v3(router,snmp_user,oid=router_description)
    rtr_uptime = snmp_get_oid_v3(router,snmp_user,oid=router_uptime)
    last_changed = snmp_get_oid_v3(router,snmp_user,oid=config_last_changed)

    name_output = snmp_extract(rtr_name)
    desc_output = snmp_extract(rtr_description)
    uptime_output = snmp_extract(rtr_uptime)
    changed_output = snmp_extract(last_changed)

    device_info = (name_output,desc_output,uptime_output,changed_output)

    compare_device_info(hostname, device_info)
开发者ID:jordanwimb,项目名称:kbpython,代码行数:34,代码来源:exercise4d.py


示例5: main

def main():
    a_user = 'pysnmp'
    auth_key = 'galileo1'
    encrypt_key = 'galileo1'
    rtr_ip = '50.76.53.27'
    snmp_user = (a_user, auth_key, encrypt_key)
    f = open(device_file, "rb")

    prev_rtr1_info = pickle.load(f)
    prev_rtr2_info = pickle.load(f)
    f.close()

    pynet_rtr1 = (rtr_ip, 7961)
    pynet_rtr2 = (rtr_ip, 8061)

    hostname = raw_input("Please enter the hostname: ")

    if hostname == "pynet-rtr1":
        router = pynet_rtr1
    elif hostname == "pynet-rtr2":
        router = pynet_rtr2

    rtr_name = snmp_get_oid_v3(router,snmp_user,oid=router_name)
    rtr_description = snmp_get_oid_v3(router,snmp_user,oid=router_description)
    rtr_uptime = snmp_get_oid_v3(router,snmp_user,oid=router_uptime)
    last_changed = snmp_get_oid_v3(router,snmp_user,oid=config_last_changed)

    name_output = snmp_extract(rtr_name)
    desc_output = snmp_extract(rtr_description)
    uptime_output = snmp_extract(rtr_uptime)
    changed_output = snmp_extract(last_changed)
    
    device_info = (name_output,desc_output,uptime_output,changed_output)
    
    if hostname == "pynet-rtr1":
        print(device_info[3], prev_rtr1_info[3])
        if device_info[3] > prev_rtr1_info[3]:
            f = open(device_file, "wb")
            pickle.dump(device_info,f)
            pickle.dump(prev_rtr2_info,f)
            f.close()
        else:
            print("No changes have been made to this device.")

    elif hostname == "pynet-rtr2":
        if device_info[3] > prev_rtr2_info[3]:
            print("Device configuration has been changed.")
            f = open(device_file, "wb")
            pickle.dump(prev_rtr1_info,f)
            pickle.dump(device_info,f)
            f.close()
        else:
            print("No changes have been made to this device.")

    f = open("device_info.pkl", "rb")

    prev_rtr1_info = pickle.load(f)
    prev_rtr2_info = pickle.load(f)
    f.close()
开发者ID:jordanwimb,项目名称:kbpython,代码行数:59,代码来源:exercise4c.py


示例6: main

def main():
    '''
    main routine
    '''


    pickle_file = 'machine_file.pkl'

    ip_address = raw_input("Enter IP address: ")
    machines = ((ip_address, '7961'), (ip_address, '8061'))
    username = raw_input("Enter SNMPv3 Username: ")
    authentication_key = getpass(prompt="Enter Authentication key: ")
    encryption_key = getpass(prompt="Enter Encryption key: ")

    snmp_user = (username, authentication_key, encryption_key)

    # load stored machines from pickle_file into dictionary object

    stored_machines = load_stored_machines(pickle_file)

    # create list to store machine objects created from config_check.NewMachine

    pickle_dump_list = []


    # using SNMPv3 poll all defined machines,
    # grab sysName and ccmHistoryRunningLastChanged OIDs

    for values in machines:
        snmp_data = []

        for snmp_oid in (SYSNAME, LASTCHANGE):
            snmp_poll = snmp_extract(snmp_get_oid_v3(values, snmp_user, snmp_oid))
            snmp_data.append(snmp_poll)

        machine_name = snmp_data[0]
        machine_lastchange = snmp_data[1]

        pickle_dump_list.append(NewMachine(machine_name, machine_lastchange))


        # test if polled sysName matches a previously stored device,
        # if match and config change is detected send email alert

        if machine_name in stored_machines:
            alert_obj = stored_machines[machine_name]

            if machine_lastchange > alert_obj.machine_lastchange:
                print "\n{0}: running-config has changed!".format(machine_name)
                email_alert(alert_obj)

            else:
                print "\n{0}: No running-config change detected!".format(machine_name)

        else:
            print "{0}: Not previously found. Saving to {1}".format(machine_name, pickle_file)

    with open(pickle_file, 'w') as pkl_file:
        for list_item in pickle_dump_list:
            pickle.dump(list_item, pkl_file)
开发者ID:adleff,项目名称:python_ansible,代码行数:60,代码来源:ex1.py


示例7: snmp_get

def snmp_get(whichrouter, which_oid):
    """
    Get snmp result based on which router and OID
    """
    snmp_data = snmp_helper.snmp_get_oid_v3(whichrouter, snmp_user, oid=which_oid)
    snmp_result = snmp_helper.snmp_extract(snmp_data)
    return snmp_result
开发者ID:befthimi,项目名称:be_pynet_course,代码行数:7,代码来源:exercise1.py


示例8: get_snmp_data

def get_snmp_data (router_data, oid):

    if router_data ['snmp_v'] < 3:

        a_device = ( 
                router_data['IP'], 
                router_data['SNMP Community'], 
                router_data['SNMP Port'], 
        )

        snmp_data = snmp_get_oid ( a_device, oid)

        if snmp_data:
            return snmp_extract (snmp_data)

    if router_data ['snmp_v'] == 3:
        a_device = ( 
                router_data['IP'], 
                router_data['SNMP Port'], 
        )
        snmp_user = router_data ['snmp_user']

        snmp_data = snmp_get_oid_v3 ( a_device, snmp_user, oid)

        if snmp_data:
            return snmp_extract (snmp_data)
    
            
    return None
开发者ID:blahu,项目名称:pynet-mat,代码行数:29,代码来源:cl2ex2.py


示例9: get_snmp_conf_time

def get_snmp_conf_time(snmp_conf, snmp_oids):
    snmp_tmp = {}
    for oid_name, oid in snmp_oids:
        snmp_device = (snmp_conf['ip_addr'], int(snmp_conf['snmp_port']))
        snmp_user = (snmp_conf['snmp_user'], snmp_conf['snmp_auth_key'], snmp_conf['snmp_encrypt_key'])
        snmp_tmp[oid_name] = int(snmp_extract(snmp_get_oid_v3(snmp_device, snmp_user, oid))) / 100
    return snmp_tmp # Return dictionary with uptime and run|start time
开发者ID:laetrid,项目名称:learning,代码行数:7,代码来源:ex2_1.py


示例10: get_interface_stats

def get_interface_stats(snmp_device, snmp_user, stat_type, row_number):
    '''
    stat_type can be 'in_octets, out_octets, in_ucast_pkts, out_ucast_pkts

    returns the counter value as an integer
    '''

    oid_dict = {
        'in_octets':    '1.3.6.1.2.1.2.2.1.10',
        'out_octets':   '1.3.6.1.2.1.2.2.1.16',
        'in_ucast_pkts':    '1.3.6.1.2.1.2.2.1.11',
        'out_ucast_pkts':    '1.3.6.1.2.1.2.2.1.17',
    }

    if not stat_type in oid_dict.keys():
        raise ValueError("Invalid value for stat_type: {}" % stat_type)

    # Make sure row_number can be converted to an int
    row_number = int(row_number)

    # Append row number to OID
    oid = oid_dict[stat_type]
    oid = oid + '.' + str(row_number)

    snmp_data = snmp_get_oid_v3(snmp_device, snmp_user, oid)
    return int(snmp_extract(snmp_data))
开发者ID:GnetworkGnome,项目名称:pynet,代码行数:26,代码来源:ex2_snmp_int_graph.py


示例11: update_data

def update_data(NEW,description,in_octets,in_packets,out_octets,out_packets,time):
    if time >= 60:
        time = 5
    else:
        time = time + 5
    for name,oid in oids:
        if name == 'ifDescr_fa4':
            snmp_raw = snmp_helper.snmp_get_oid_v3(rtr1,rtr1_snmp,oid=oid)
            snmp_dec = snmp_helper.snmp_extract(snmp_raw)
            description = snmp_dec
        if name == 'ifInOctets_fa4':
            snmp_raw = snmp_helper.snmp_get_oid_v3(rtr1,rtr1_snmp,oid=oid)
            snmp_dec = snmp_helper.snmp_extract(snmp_raw)
            if NEW == True:
                in_octets.insert(0,int(snmp_dec))
            else:
                in_octets.insert(1,int(snmp_dec) - in_octets[0])
                in_octets[0] = int(snmp_dec)
                in_octets = in_octets[:13]
        if name == 'ifInUcastPkts_fa4':
            snmp_raw = snmp_helper.snmp_get_oid_v3(rtr1,rtr1_snmp,oid=oid)
            snmp_dec = snmp_helper.snmp_extract(snmp_raw)
            if NEW == True:
                in_packets.insert(0,int(snmp_dec))
            else:
                in_packets.insert(1,int(snmp_dec) - in_packets[0])
                in_packets[0] = int(snmp_dec)
                in_packets = in_packets[:13]
        if name == 'ifOutOctets_fa4':
            snmp_raw = snmp_helper.snmp_get_oid_v3(rtr1,rtr1_snmp,oid=oid)
            snmp_dec = snmp_helper.snmp_extract(snmp_raw)
            if NEW == True:
                out_octets.insert(0,int(snmp_dec))
            else:
                out_octets.insert(1,int(snmp_dec) - out_octets[0])
                out_octets[0] = int(snmp_dec)
                out_octets = out_octets[:13]
        if name == 'ifOutUcastPkts_fa4':
            snmp_raw = snmp_helper.snmp_get_oid_v3(rtr1,rtr1_snmp,oid=oid)
            snmp_dec = snmp_helper.snmp_extract(snmp_raw)
            if NEW == True:
                out_packets.insert(0,int(snmp_dec))
            else:
                out_packets.insert(1,int(snmp_dec) - out_packets[0])
                out_packets[0] = int(snmp_dec)
                out_packets = out_packets[:13]
    return(description,in_octets,in_packets,out_octets,out_packets,time)
开发者ID:kroha,项目名称:pynet_class,代码行数:47,代码来源:c3_hw02.py


示例12: get_the_current_value

def get_the_current_value(device, user):
    '''
    to get the current value of ccmHistoryRunningLastChanged
    and the value of uptime
    to calculate out how many hundredths of seconds did the change happen before NOW
    '''
     
    ccmHistoryRunningLastChanged = '1.3.6.1.4.1.9.9.43.1.1.1.0'
    sysUptime = '1.3.6.1.2.1.1.3.0'
    output = snmp_helper.snmp_get_oid_v3(device, user, ccmHistoryRunningLastChanged)
    last_change = snmp_helper.snmp_extract(output)
    output = snmp_helper.snmp_get_oid_v3(device, user, sysUptime)
    uptime = snmp_helper.snmp_extract(output)
    dvalue = int(uptime) - int(last_change)
    value = (last_change, uptime, dvalue)

    return value
开发者ID:zoomhgtk,项目名称:hsun_pynet_exercise,代码行数:17,代码来源:ex1_yaml.py


示例13: main

def main():
    snmp_device = (ip_addr, snmp_port_rtr2)
    snmp_user = (user, auth_key, encrypt_key)

    # Check whether time file already exists.
    try:
        with open('time.pkl') as file:
            pass
    except:
        # If time file does not exist, create first time entry.
        snmp_data = snmp_get_oid_v3(snmp_device, snmp_user, oid=runningLastChanged)
        output = snmp_extract(snmp_data)
        # Store time in a pickle file.
        d = open("time.pkl", "wb")
        pickle.dump(output, d)
        d.close()

    # Get last time stored.
    d = open("time.pkl", "rb")
    last_time = pickle.load(d)
    print "Last time: " + last_time

    # Check time of last running config change.
    snmp_data = snmp_get_oid_v3(snmp_device, snmp_user, oid=runningLastChanged)
    output = snmp_extract(snmp_data)
    print "New time: " + output

    # If time of last change greater than stored time, 
    # store the new change time and send email.
    if output > last_time:
        s = float(output)
        t = Decimal(s/100.0)
        time = round(t,2)
        print "Time is now Greater: " + str(time)
        
        # Store time of latest change in a pickle file.
        d = open("time.pkl", "wb")
        pickle.dump(output, d)
        d.close()
        print "New stored value: " + output

        # Send me an email with the time of last change.
        message = "Running config changed at: " + str(time) + "sec"
        email_helper.send_mail(recipient, subject, message, sender)
    else:
        print "Running config has not changed."
开发者ID:dprzybyla,项目名称:python-ansible,代码行数:46,代码来源:detect_conf_change.py


示例14: get_intf_stats

def get_intf_stats():
    count = 0
    global fa4_in_octets,fa4_out_octets,fa4_in_packets,fa4_out_packets
    print("Gathering statistics.  Check back in 1 hour.")
    while count < 6:
        fa4_in_oct_count = int(snmp_extract(snmp_get_oid_v3(router,snmp_user,oid=input_oct)))
        fa4_in_octets.append(fa4_in_oct_count)
        fa4_out_oct_count = int(snmp_extract(snmp_get_oid_v3(router,snmp_user,oid=output_oct)))
        fa4_out_octets.append(fa4_out_oct_count)
        fa4_in_count = int(snmp_extract(snmp_get_oid_v3(router,snmp_user,oid=input_ucast)))
        fa4_in_packets.append(fa4_in_count)
        fa4_out_count = int(snmp_extract(snmp_get_oid_v3(router,snmp_user,oid=output_ucast)))
        fa4_out_packets.append(fa4_out_count)
        count +=1
        time.sleep(10)
    print("Done.  Generating graph.")
    return(fa4_in_octets,fa4_out_octets,fa4_in_packets,fa4_out_packets)
开发者ID:jordanwimb,项目名称:kbpython,代码行数:17,代码来源:shell-ex2.py


示例15: get_int_value

def get_int_value(oid):

    snmp_device = ('50.76.53.27',7961)
    snmp_user = ('pysnmp','galileo1','galileo1')
    
    value = int(snmp_extract(snmp_get_oid_v3(snmp_device, snmp_user, oid)))
    
    return value
开发者ID:eduardcoll,项目名称:lab_repo,代码行数:8,代码来源:ex2.py


示例16: get_data

def get_data(device, user, filename, time_stemp, inboundOID, outboundOID):
    '''
    to get the value of ifInOctets_fa4 and ifOutOctets_fa4
    '''

    data = []
    data.append({})

    data[-1]['time'] = time_stemp

    output = snmp_helper.snmp_get_oid_v3(device, user, inboundOID)
    data[-1]['inbound'] = snmp_helper.snmp_extract(output)

    output = snmp_helper.snmp_get_oid_v3(device, user, outboundOID)
    data[-1]['outbound'] = snmp_helper.snmp_extract(output)
    
    with open(filename, "a") as stream:
        stream.write(yaml.dump(data, default_flow_style = False))
开发者ID:zoomhgtk,项目名称:hsun_pynet_exercise,代码行数:18,代码来源:ex2_pygal.py


示例17: read_all_oids

 def read_all_oids(self):
     self.oid_values = []
     self.snmp_user = (self.username, self.auth_k, self.encry_k)
     self.dev_tuple = (self.ip_address, self.snmp_port)
     for desc, an_oid, is_count in self.snmp_oids:
         self.snmp_data = snmp_helper.snmp_get_oid_v3(self.dev_tuple,
                                                 self.snmp_user, oid=an_oid)
         self.output = snmp_helper.snmp_extract(self.snmp_data)
         self.oid_values.append((desc, self.output))
     return self.oid_values
开发者ID:ahsec,项目名称:PyNet_Class_Exercises,代码行数:10,代码来源:exercise_01.py


示例18: poll

def poll(device, oid):
    '''
    This function polls a device for the OID passed in.
    The 'device' variable is a tuple of IP and port.
    '''

    snmp_user = ('pysnmp', 'galileo1', 'galileo1')
    data = snmp_extract(snmp_get_oid_v3((device[1],device[2]),snmp_user, oid, auth_proto='sha', encrypt_proto='aes128', display_errors=True))

    return data
开发者ID:mcaulifn,项目名称:pynetclass,代码行数:10,代码来源:exercise2.py


示例19: main

def main():
#   sleep_time = int(sys.argv.pop())
#   niter = int(sys.argv.pop())
    sleep_time=300
    niter=14
    ip = "184.105.247.70"
    a_user = 'pysnmp'
    auth_key = 'galileo1'
    encrypt_key = 'galileo1'
    snmp_user = (a_user, auth_key, encrypt_key)
    pynet_rtr1 = (ip, 161)

    count = 0
    plot_lists = {}
    line_chart_1 = pygal.Line()
    line_chart_2 = pygal.Line()

# Create results dictionary
    for oid in oids:
        plot_lists[oid[0]] = []

    timestamps = []
    while count < niter:
#       timestamps.append(time.ctime().split()[3])
        print "\nCount %d" %count
        for oid in oids:
            pname = oid[0]
            snmp_data = snmp_helper.snmp_get_oid_v3(pynet_rtr1, snmp_user, oid=oid[1])
            output = snmp_helper.snmp_extract(snmp_data)
#           print "OUTPUT=%s" %output
            print "%s  %s %s" %(time.ctime().split()[3], oid[0], output)
            sys.stdout.flush()
            plot_lists[pname].append((output))
        count += 1
        time.sleep(sleep_time)

    timestamps=[0,5,10,15,20,25,30,35,40,45,50,55,60]
# Generate plot
    line_chart_1.title = 'Input/Output Bytes for %s' %plot_lists[oids[0][0]][0]
    line_chart_2.title = 'Input/Output Packets for %s' %plot_lists[oids[0][0]][0]
#   timestamps=addNone(timestamps,10)
#   for oid in oids[1:]:
#       results = [int(res) for res in plot_lists[oid[0]]]
#       print "%s: %s" %(oid[0], delta(results))
#       line_chart.add(oid[0], delta(results))
    print "OIDS=%s" %oids[1:3]
    line_chart_1.x_labels = timestamps
    line_chart_1 = plot_data(oids[1:3],plot_lists,line_chart_1)
    line_chart_1.render_to_file('test1.svg')

    line_chart_2.x_labels = timestamps
    line_chart_2 = plot_data(oids[3:],plot_lists,line_chart_2)
    line_chart_2.render_to_file('test2.svg')
开发者ID:patrebert,项目名称:pynet_cert,代码行数:53,代码来源:ex2.py


示例20: poll

def poll(device):
    '''
    Poll the device and return the new data.
    Accepts 'device' which is a tuple of name, ip, and snmp port.
    '''


    p_time = strftime(TIMEF, gmtime())
    poll_temp = []
    for name, oid in sorted(oids.items()):
        poll_temp.append(snmp_extract(snmp_get_oid_v3((device[1],device[2]),snmp_user, oid, auth_proto='sha', encrypt_proto='aes128', display_errors=True)))
    newdata = [poll_temp[1], device[1], p_time, int(poll_temp[2]), int(poll_temp[0])]
    return newdata
开发者ID:mcaulifn,项目名称:pynetclass,代码行数:13,代码来源:exercise1.py



注:本文中的snmp_helper.snmp_get_oid_v3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python snowballstemmer.stemmer函数代码示例发布时间:2022-05-27
下一篇:
Python snmp_helper.snmp_get_oid函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap