Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #122 from ktbyers/devel
Browse files Browse the repository at this point in the history
Minor documentation change on regex
  • Loading branch information
ktbyers authored Mar 9, 2017
2 parents 36e7491 + fcd1129 commit 55750c6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions napalm_ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,16 +1261,13 @@ def get_interfaces_counters(self):
counters[interface]['tx_discards'] = -1
for line in sh_int_sum_cmd_out.splitlines():
if interface in line:
# ' Interface IHQ IQD OHQ OQD' +\
# ' RXBS RXPS TXBS TXPS TRTL'
# '---------------------------------------------------------------' +\
# '--------------------------------------------------'
# ' FastEthernet0 0 0 0 0' +\
# ' 0 0 0 0 0'
regex = r"\b" + interface +\
r"\b\s+(?P<IHQ>\d+)\s+(?P<IQD>\d+)\s+(?P<OHQ>\d+)" +\
r"\s+(?P<OQD>\d+)\s+(?P<RXBS>\d+)\s+(?P<RXPS>\d+)" + \
r"\s+(?P<TXBS>\d+)\s+(?P<TXPS>\d+)\s+(?P<TRTL>\d+)"
# Line is tabular output with columns
# Interface IHQ IQD OHQ OQD RXBS RXPS TXBS TXPS TRTL
# where columns (excluding interface) are integers
regex = r"\b" + interface + \
r"\b\s+(\d+)\s+(?P<IQD>\d+)\s+(\d+)" + \
r"\s+(?P<OQD>\d+)\s+(\d+)\s+(\d+)" + \
r"\s+(\d+)\s+(\d+)\s+(\d+)"
match = re.search(regex, line)
if match:
counters[interface]['rx_discards'] = int(match.group("IQD"))
Expand Down

0 comments on commit 55750c6

Please sign in to comment.