simplified awk expression, fixed unit test

This commit is contained in:
Nurlan Nugumanov 2014-02-18 17:37:23 +04:00
parent 14075de0d8
commit 59a115eb72
2 changed files with 3 additions and 3 deletions

View File

@ -341,7 +341,7 @@ class NetTcp(AbstractMetric):
if note set it to 0.
* make output ordered as "fields" list
'''
fetch = lambda: commands.getoutput("ss -s | awk -F'(\()|(\)|(\/))' '$0 ~ \"TCP:\" {print $2}'")
fetch = lambda: commands.getoutput("ss -s | awk -F'\(|\)|\/' '/^TCP:/ {print $2}'")
data = {}
result = []
raw_lines = fetch().split(',')

View File

@ -115,8 +115,8 @@ class NetTcpTestCase(unittest.TestCase):
def test_net_tcp_(self):
print self.foo.check()
self.assertEquals(4, len(self.foo.check()))
self.assertNotEquals(['0', '0', '0', '0'], self.foo.check())
self.assertEquals(3, len(self.foo.check()))
self.assertNotEquals(['0', '0', '0'], self.foo.check())
class NetTxRxTestCase(unittest.TestCase):