How to use the pingparsing.PingParsing function in pingparsing

To help you get started, we’ve selected a few pingparsing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombashi / tcconfig / test / test_tcset_dst_two.py View on Github external
def pingparser():
    return pingparsing.PingParsing()
github thombashi / tcconfig / test / test_tcset_dst_one.py View on Github external
def pingparser():
    return pingparsing.PingParsing()
github thombashi / tcconfig / test / test_tcset_dst_two.py View on Github external
def pingparser():
    return pingparsing.PingParsing()
github thombashi / pingparsing / examples / ping_sample.py View on Github external
def main():
    ping_parser = pingparsing.PingParsing()
    transmitter = pingparsing.PingTransmitter()
    transmitter.destination = "google.com"
    transmitter.count = 10
    result = transmitter.ping()

    print(json.dumps(ping_parser.parse(result).as_dict(), indent=4))

    return result.returncode
github Dynatrace / dynatrace-api / third-party-synthetic / active-gate-extensions / extension-third-party-ping / src / ping_extension.py View on Github external
def ping(host: str) -> pingparsing.PingStats:
    ping_parser = pingparsing.PingParsing()
    transmitter = pingparsing.PingTransmitter()
    transmitter.destination = host
    transmitter.count = 2
    transmitter.timeout = 2000
    return ping_parser.parse(transmitter.ping())
github shivammathur / IPpy / ippy / ippy.py View on Github external
for _ in range(self.num_workers):
            self._workers.append(threading.Thread(target=self.worker_func, args=(ping_args, self._pending, self._done)))

        # Put all the addresses into the 'pending' queue.
        with open(file_path, "r") as hostsFile:
            for line in hostsFile:
                self._pending.put(line.strip())

        # Start all the workers.
        for w in self._workers:
            w.daemon = True
            w.start()

        # Parser to parse the ping response
        ping_parser = pingparsing.PingParsing()

        # Get the results as they arrive.
        num_terminated = 0
        while num_terminated < self.num_workers:
            result = self._done.get()
            if result is None:
                # A worker is about to terminate.
                num_terminated += 1
            else:
                # Print as soon as results arrive
                if result[1].decode("utf-8") == '':  # Error is empty string
                    if self.verbose:
                        print("IP", result[0]['ip'])
                        print(result[0]['result'].decode("utf-8"))
                    ping_parser.parse(result[0]['result'].decode("utf-8"))
                    if int(ping_parser.packet_loss) == 100:  # All packets are lost
github thombashi / pingparsing / examples / parse_sample.py View on Github external
def main():
    parser = pingparsing.PingParsing()
    stats = parser.parse(
        dedent(
            """\
        PING google.com (74.125.24.100) 56(84) bytes of data.
        [1524930937.003555] 64 bytes from 74.125.24.100: icmp_seq=1 ttl=39 time=148 ms
        [1524930937.787175] 64 bytes from 74.125.24.100: icmp_seq=2 ttl=39 time=137 ms
        [1524930938.787642] 64 bytes from 74.125.24.100: icmp_seq=3 ttl=39 time=137 ms
        [1524930939.787653] 64 bytes from 74.125.24.100: icmp_seq=4 ttl=39 time=136 ms
        [1524930940.788365] 64 bytes from 74.125.24.100: icmp_seq=5 ttl=39 time=136 ms

        --- google.com ping statistics ---
        5 packets transmitted, 5 received, 0% packet loss, time 4001ms
        rtt min/avg/max/mdev = 136.537/139.174/148.006/4.425 ms
        """
        )
    )