Closed geokal closed 6 years ago
@geokal Thank you for your feedback.
It might be considered for the future release. Let me confirm your expectations for the feature:
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
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>, ...]
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!!
@geokal Thank you for your answer. I will consider the feature for the future release.
@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.
@thombashi Thanks will try it as soon as possible!!
I'll close the issue. Feel free to reopen if you have any problems about the feature.
Hi, with the current implementation, we miss sub-second precision :(
It would be enough to change https://github.com/thombashi/pingparsing/blob/262d1b55fd460a01e13bc8d93675160bc6f5d63d/pingparsing/_parser.py#L65
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!
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
}
]
}
}
Nice, it works :) Thank you!
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.