Exemple #1
0
def main():

	# Get device details
	router = (get_host_details(devices, hostname='pynet-rtr1'))[0]

	# Fa4
	int_index = 5

	graph_stats = {
		'in_octets' : [],
		'out_octets': [],
		'in_ucast_pkts': [],
		'out_ucast_pkts': []
	}

	base_values_d = {}

	# Run every 5 minutes for 1 hour
	for counter in range(0, 29):
		print 'time:', counter

		# Grab SNMP data for each stat
		for stat in ("in_octets", "out_octets", "in_ucast_pkts", "out_ucast_pkts"):

			print get_int_stats(router, stat, int_index)
			# SNMP Get
			snmp_value = get_int_stats(router, stat, int_index)

			base_value = base_values_d.get(stat)
			if base_value:
				# Calculate and store delta from base value to new value
				graph_stats[stat].append(int(snmp_value) - base_value)
				print 'delta:', graph_stats[stat][-1]


			graph_stats[stat].append(snmp_value)

		time.sleep(300)

	print graph_stats
	line_chart.line(graph_stats)
#!/usr/bin/env python

"""
Detect if the running config has changed. If so, send an email including
the router hostname and timestamp of the change.
"""

from pynet_dev import devices, get_host_details, snmp_get_v3
import pprint
import os.path
import pickle
import sys


# Get a list of the devices we want to query
routers_l = get_host_details(devices, model='881')

oid_run_change = '1.3.6.1.4.1.9.9.43.1.1.1.0'
oid_run_last_save = '1.3.6.1.4.1.9.9.43.1.1.2.0'
oid_start_last_save = '1.3.6.1.4.1.9.9.43.1.1.3.0'


def read_run_change(file):
	"""
	Param:
		file : str : data file path

	Returns:
		A dictionary containing hostnames and value pairs
	"""
#!/usr/bin/env python
"""
Detect if the running config has changed. If so, send an email including
the router hostname and timestamp of the change.
"""

from pynet_dev import devices, get_host_details, snmp_get_v3
import pprint
import os.path
import pickle
import sys

# Get a list of the devices we want to query
routers_l = get_host_details(devices, model='881')

oid_run_change = '1.3.6.1.4.1.9.9.43.1.1.1.0'
oid_run_last_save = '1.3.6.1.4.1.9.9.43.1.1.2.0'
oid_start_last_save = '1.3.6.1.4.1.9.9.43.1.1.3.0'


def read_run_change(file):
    """
	Param:
		file : str : data file path

	Returns:
		A dictionary containing hostnames and value pairs
	"""

    with open(file, 'r') as f:
        try: