Exemplo n.º 1
0
def onXfwCommand(cmd, *args):
    try:
        if cmd == XVM_PING_COMMAND.PING:
            pinger.ping()
            return (None, True)
        if cmd == XVM_PING_COMMAND.GETCURRENTSERVER:
            getCurrentServer()
            return (None, True)
    except Exception, ex:
        err(traceback.format_exc())
        return (None, True)
Exemplo n.º 2
0
def onXfwCommand(cmd, *args):
    try:
        if cmd == XVM_PING_COMMAND.PING:
            pinger.ping()
            return (None, True)
        if cmd == XVM_PING_COMMAND.GETCURRENTSERVER:
            getCurrentServer()
            return (None, True)
    except Exception, ex:
        err(traceback.format_exc())
        return (None, True)
Exemplo n.º 3
0
def ping_servers(servers, influx_client):
    points = []
    for server in servers:
        try:
            ping_data = pinger.ping(**server)
            if not ping_data:
                continue
        except socket.timeout:
            continue
        except:
            print(
                f'Error pinging {server["host"]}:{server.get("port", 25565)}. Timeout was {server.get("timeout", 1)}'
            )
            traceback.print_exc()
            continue

        points.append({
            "measurement": "servers_stats",
            "tags": server.get("tags"),
            "time": int(round(time.time() * 1000)),
            "fields": {
                'online': ping_data['players']['online']
            }
        })

    if points:
        try:
            influx_client.write_points(points, time_precision='ms')
        except:
            print(f'Error writing points to influx db: {points}')
            traceback.print_exc()
        def test_5after_reboot(self):
            LOG.info(
                "check ISC appliance is pinging,check services, server counts and number of vms associated with hosts before and after reboot are equal"
            )
            servers_count_before_reboot = servers_count_global
            vm_count_with_hosts_before_reboot = vm_count_with_hosts_global
            ping_time = pinger.ping(common_config.ISC_APPLIANCE_IP)
            LOG.info("pinging system")
            if ping_time is None:
                LOG.info("Appliance not reachable")
            else:
                self.test_1check_services()
                details, servers_count_after_reboot = self.get_servers_details_count(
                )
                vm_count_with_hosts_after_reboot = self.test_3vm_count_with_host(
                )
            try:
                self.assertEquals(servers_count_before_reboot,
                                  servers_count_after_reboot)
                LOG.info("number of servers before and after reboot are equal")
            except Exception as e:
                LOG.error(
                    "number of servers before and after reboot are not equal")
# raise e
            finally:
                try:
                    self.assertEquals(
                        vm_count_with_hosts_before_reboot,
                        vm_count_with_hosts_after_reboot,
                        "number of vms associted with hosts before and after reboot are not equal"
                    )
                    LOG.info(
                        "number of vms associted with hosts before and after reboot are equal"
                    )
                except Exception as e:
                    LOG.error(
                        "number of vms associted with hosts before and after reboot are not equal"
                    )
Exemplo n.º 5
0
#! /usr/bin/env python3
import pinger
from sendemail import notifyadmin
import sys

if __name__ == "__main__":
    hostname = sys.argv[1]
    email = sys.argv[2]
    print("ping testing:", hostname)

    pingIt = pinger.ping(hostname)
    result = pingIt
    print(result)

    if result == False:
        print(hostname, "Ping error, sending e-mail to sysadmin:", email)
        notifyadmin(email, hostname)
    else:
        print(hostname, "... ping ok!")
Exemplo n.º 6
0
def configure(d_ip_list):
    """Using 'ping' it configures Window Size, decides on Bulk ACK, Timeout and if decided on Bulk ACK, ACK Window.
    Takes one argument which is a list of Destination IPs.

    Note that the function calls some functions in which multiprocessing is used.

    For more information about this function refer to README."""

    values = ping(d_ip_list)
    tmp = []
    for d in d_ip_list:
        try:
            tmp.append(values[d])
        except KeyError:    # Appends 100% loss if no ping info is received from that IP, excludes that IP
            tmp.append((4001, 4001, 100, 0))    # ms is 4001 since it waits 4 seconds
    values = tmp

    bulk_size = []
    for value in values:
        if value[2] == 0.:  # Prevents zero division error
            bulk_size.append(ACK_WINDOW_MAX)
            continue
        bulk_size.append(round(10/sqrt(value[2])))
    bulk_size = tuple(bulk_size)

    packet_quantity = []
    for i in range(len(values) - 1):
        x = values[i][2]
        m = values[i][0]
        y = values[i + 1][2]
        n = values[i + 1][0]
        if x == 100:    # If loss is 100% in 2nd one, makes ms 0 in 1st one in order not to give any packet to 2nd line
            n = 0
        a_divided_b = Fraction(n * (100 + y)) / Fraction(m * (100 + x))
        if not packet_quantity:
            packet_quantity.append(a_divided_b.numerator)
            packet_quantity.append(a_divided_b.denominator)
        else:
            packet_quantity.append(a_divided_b.denominator)
            multiplier = packet_quantity.append(a_divided_b.numerator) / packet_quantity[i]
            if multiplier < 1:
                packet_quantity[i + 1] /= multiplier
            else:
                for j in range(i):
                    packet_quantity[j] *= multiplier
    packet_quantity = tuple(packet_quantity)

    timeout = []
    for value in values:
        my_value = value[2]
        if my_value > 12:
            timeout.append(1)
        elif my_value > 6:
            timeout.append(2)
        elif my_value > 4:
            timeout.append(3)
        elif my_value > 3:
            timeout.append(4)
        elif my_value > 2:
            timeout.append(5)
        elif my_value > 1:
            timeout.append(7)
        else:
            timeout.append(9)
    timeout = tuple(timeout)

    window_size = []
    for ack_window in bulk_size:
        window_size.append(ack_window * ack_window)
    window_size = tuple(window_size)

    return packet_quantity, bulk_size, window_size, timeout