# Path: credentials.py
# SNMP_COMMUNITY = "public"


from pysnmp.entity.rfc3413.oneliner import cmdgen
from credentials import SNMP_COMMUNITY
import time
import json
import logging.config
    for device in InterfaceDevice.all_devices:

        logger.debug(device.ip + " " + device.name + " " + device.oid)
        # Get the SNMP data
        try:
            snmp_value, snmp_uptime_value, snmp_error = get_snmp(device.ip, device.community,
                                                                 device.oid, device.uptime_oid)
        except Exception as error:
            if not snmp_error:
                snmp_error = str(error)

        if snmp_error:
            logger.warning(snmp_error)
            break
        else:
            # Add the raw SNMP data to a list
            logger.debug("value:" + str(snmp_value) + " uptime:" + str(snmp_uptime_value))
            if len(device.snmp_data) == 0:                # first time through, initialize the list
                device.snmp_data = [SNMPDatapoint(snmp_value, snmp_uptime_value)]
            else:
                device.snmp_data.append(SNMPDatapoint(snmp_value, snmp_uptime_value))
            # If we already have the max number of datapoints in our list, delete the oldest item
            if len(device.snmp_data) >= MAX_DATAPOINTS:
                del(device.snmp_data[0])

            # If we have at least 2 samples, calculate bps by comparing the last item with the second to last item
            if len(device.snmp_data) > 1:
                bps = calculate_bps(
                    device.snmp_data[-1].value,
                    device.snmp_data[-1].timeticks,

# Path: credentials.py
# SNMP_COMMUNITY = "public"


# Path: snmp_interface_3.py
from pysnmp.entity.rfc3413.oneliner import cmdgen
from credentials import SNMP_COMMUNITY
import time
import json
import logging.config

    for device in InterfaceDevice.all_devices:

        logger.debug(device.ip + " " + device.name + " " + device.oid)
        # Get the SNMP data
        try:
            snmp_value, snmp_uptime_value, snmp_error = get_snmp(device.ip, device.community,
                                                                 device.oid, device.uptime_oid)
        except Exception as error:
            if not snmp_error:
                snmp_error = str(error)

        if snmp_error:
            logger.warning(snmp_error)
            break
        else:
            # Add the raw SNMP data to a list
            logger.debug("value:" + str(snmp_value) + " uptime:" + str(snmp_uptime_value))
            if len(device.snmp_data) == 0:                # first time through, initialize the list
                device.snmp_data = [SNMPDatapoint(snmp_value, snmp_uptime_value)]
            else:
                device.snmp_data.append(SNMPDatapoint(snmp_value, snmp_uptime_value))
            # If we already have the max number of datapoints in our list, delete the oldest item
            if len(device.snmp_data) >= MAX_DATAPOINTS:
                del(device.snmp_data[0])

            # If we have at least 2 samples, calculate bps by comparing the last item with the second to last item
            if len(device.snmp_data) > 1:
                bps = calculate_bps(
                    device.snmp_data[-1].value,
                    device.snmp_data[-1].timeticks,

                    device.snmp_data[-2].value,