diff --git a/netengine/backends/snmp/airos.py b/netengine/backends/snmp/airos.py index 17aa7e1..78ac856 100644 --- a/netengine/backends/snmp/airos.py +++ b/netengine/backends/snmp/airos.py @@ -7,7 +7,6 @@ import binascii import logging -import time from datetime import datetime from .base import SNMP @@ -379,9 +378,7 @@ def local_time(self): returns the local time of the host device as a timestamp """ epoch = str(self.get('1.3.6.1.4.1.41112.1.4.8.1.0')[3][0][1]) - timestamp = int( - time.mktime(datetime.strptime(epoch, '%Y-%m-%d %H:%M:%S').timetuple()) - ) + timestamp = int(datetime.strptime(epoch, '%Y-%m-%d %H:%M:%S').timestamp()) return timestamp @property @@ -422,9 +419,10 @@ def load(self): Returns an array with load average values respectively in the last minute, in the last 5 minutes and in the last 15 minutes """ - one = int(self.get_value('1.3.6.1.4.1.10002.1.1.1.4.2.1.3.1')) - five = int(self.get_value('1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2')) - fifteen = int(self.get_value('1.3.6.1.4.1.10002.1.1.1.4.2.1.3.3')) + array = (self.next('1.3.6.1.4.1.10002.1.1.1.4.2.1.3'))[3] + one = int(array[0][0][1]) + five = int(array[1][0][1]) + fifteen = int(array[2][0][1]) return [one, five, fifteen] @property diff --git a/netengine/backends/snmp/openwrt.py b/netengine/backends/snmp/openwrt.py index 7254125..dbf8546 100644 --- a/netengine/backends/snmp/openwrt.py +++ b/netengine/backends/snmp/openwrt.py @@ -412,7 +412,6 @@ def local_time(self): tzinfo=pytz.utc, ).timestamp() ) - logger.warning('Invalid timestring was supplied') @property def RAM_total(self): diff --git a/tests/test_snmp/test_airos.py b/tests/test_snmp/test_airos.py index 70ee9e0..08e7b58 100644 --- a/tests/test_snmp/test_airos.py +++ b/tests/test_snmp/test_airos.py @@ -158,7 +158,7 @@ def test_local_time(self): def test_load(self): load = self.device.load self.assertIsInstance(load, list) - self.assertEquals(len(load), 3) + self.assertEqual(len(load), 3) self.assertIsInstance(load[0], int) self.assertIsInstance(load[1], int) self.assertIsInstance(load[2], int) diff --git a/tests/utils.py b/tests/utils.py index db1a7f2..04bade5 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -74,6 +74,7 @@ def _get_nextcmd_list(return_value): '1.3.6.1.2.1.4.20.1.2': [[[0, 1]]], '1.3.6.1.2.1.25.3.3.1.2': [0, 2], '1.3.6.1.2.1.4.20.1.3': [[[0, OctetString('192.168.0.1')]]], + '1.3.6.1.4.1.10002.1.1.1.4.2.1.3': [[[0, 51]], [[0, 18]], [[0, 24]]], } oid = args[2] return _get_nextcmd_list(res[oid])