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

timestamp #29

Closed
geokal opened this issue Mar 16, 2018 · 10 comments
Closed

timestamp #29

geokal opened this issue Mar 16, 2018 · 10 comments
Assignees

Comments

@geokal
Copy link

geokal commented Mar 16, 2018

Hi, thanks for your effort!! Not an issue but do you have any future plans on adding timestamps on every ping? trying to figure out an elegant way on this.

@thombashi
Copy link
Owner

@geokal
Thank you for your feedback.

It might be considered for the future release.
Let me confirm your expectations for the feature:

1. tamestamps

Does it tamestamps means that parsing ping output with timestamps (by option -D etc.) like following?

$ ping -D google.com
PING google.com (216.58.199.238) 56(84) bytes of data.
[1521287236.410693] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=1 ttl=50 time=60.2 ms
[1521287237.295381] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=2 ttl=50 time=54.2 ms
[1521287238.314844] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=3 ttl=50 time=73.3 ms
[1521287239.315564] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=4 ttl=50 time=73.1 ms

2. Format

If 1. is yes, what kind of output did you expect?.
Adding an interface to get the timestamp for each ping response like following?

parser = pingparsing.PingParsing()
parser.parse("""PING google.com (216.58.199.238) 56(84) bytes of data.
[1521287236.410693] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=1 ttl=50 time=60.2 ms
[1521287237.295381] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=2 ttl=50 time=54.2 ms
[1521287238.314844] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=3 ttl=50 time=73.3 ms
[1521287239.315564] 64 bytes from kix05s02-in-f14.1e100.net (216.58.199.238): icmp_seq=4 ttl=50 time=73.1 ms
...
""")
print(parser.timestamp_list)
[<datetime of the first line>, <datetime of the second line>, ...]

@geokal
Copy link
Author

geokal commented Mar 19, 2018

Hi, @thombashi yes exactly as you said something like ping -D would be great or better format like the %H:%M:%S in date command in Linux. Currently, I was pinging with -D to insert the since epoch time and then parse the ping results but it does not work as expected. Anyways thanks a lot!!

@thombashi
Copy link
Owner

@geokal
Thank you for your answer.
I will consider the feature for the future release.

@thombashi thombashi self-assigned this Mar 21, 2018
@thombashi
Copy link
Owner

@geokal
I had implemented the timestamp parsing feature at pingparsing 0.13.0:
http://pingparsing.readthedocs.io/en/latest/pages/usage/library.html#parsing-ping-command-output
Please try the version.

@geokal
Copy link
Author

geokal commented Apr 29, 2018

@thombashi Thanks will try it as soon as possible!!

@thombashi
Copy link
Owner

I'll close the issue.
Feel free to reopen if you have any problems about the feature.

@marty90
Copy link

marty90 commented May 7, 2019

Hi, with the current implementation, we miss sub-second precision :(

@marty90
Copy link

marty90 commented May 7, 2019

It would be enough to change

Integer(reply["timestamp"].lstrip("[").rstrip("]")).force_convert()

P.S.: the command line utility fails when using --icmp-replies and timestamp, because json cannot serialize datetime. We could add a default argument in the json.dump.

Ciao!

thombashi added a commit that referenced this issue May 11, 2019
Support sub-second precision: #29
@thombashi
Copy link
Owner

Hi @marty90,

Thank you for your feedback.
I had improved timestamp precision at pingparsing 0.18.1.
Please try to upgrade this version.

Example:

$ pingparsing google.com --icmp-replies -c 2 --timestamp epoch
{
    "google.com": {
        "destination": "google.com",
        "packet_transmit": 2,
        "packet_receive": 2,
        "packet_loss_count": 0,
        "packet_loss_rate": 0.0,
        "rtt_min": 67.999,
        "rtt_avg": 72.604,
        "rtt_max": 77.209,
        "rtt_mdev": 4.605,
        "packet_duplicate_count": 0,
        "packet_duplicate_rate": 0.0,
        "icmp_replies": [
            {
                "timestamp": 1557592669.136097,
                "icmp_seq": 1,
                "ttl": 50,
                "time": 67.9,
                "duplicate": false
            },
            {
                "timestamp": 1557592670.036501,
                "icmp_seq": 2,
                "ttl": 50,
                "time": 77.2,
                "duplicate": false
            }
        ]
    }
}

@marty90
Copy link

marty90 commented May 11, 2019

Nice, it works :)
Thank you!

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

No branches or pull requests

3 participants