Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error/filtered packet not handle by pingparser #6

Open
julowe opened this issue Aug 7, 2017 · 2 comments
Open

Error/filtered packet not handle by pingparser #6

julowe opened this issue Aug 7, 2017 · 2 comments

Comments

@julowe
Copy link

julowe commented Aug 7, 2017

Having an error (in this case a filtered packet) causes pingparser to raise an exception. This may be a known issue or a feature. See code below

Traceback (most recent call last):
  File "./checkSat.py", line 32, in <module>
    ping_results = pingparser.parse(cmd_output)
  File "/usr/local/lib/python2.7/dist-packages/pingparser-0.4-py2.7.egg/pingparser.py", line 77, in parse
    sent, received, packet_loss = _get_match_groups(ping_output, rslt_matcher)
  File "/usr/local/lib/python2.7/dist-packages/pingparser-0.4-py2.7.egg/pingparser.py", line 55, in _get_match_groups
    raise Exception('Invalid PING output:\n' + ping_output)
Exception: Invalid PING output:
PING 10.1.60.1 (10.1.60.1) 56(84) bytes of data.
From x.x.x.x icmp_seq=7 Packet filtered

--- 10.1.60.1 ping statistics ---
7 packets transmitted, 0 received, +1 errors, 100% packet loss, time 6035ms
@bardahlm
Copy link

I got bitten by this, and changed the code so that the parse goes through:
rslt_matcher = re.compile(r'(\d+) packets transmitted, (\d+) (?:packets )?received, (?:\+\d+ errors, )?(\d+\.?\d*)% packet loss')
The error count is discarded, which might not be what one wants.

@keithwirch
Copy link

Oh man. That comment couldn't have come at a better time @bardahlm

I just hit that error when I got TTL Expired output. Your fix worked out great. Might consider a pull request for that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants