Esempio n. 1
0
File: play.py Progetto: room77/py77
  def play(self):
    """
    play requests on host
    send requests using send

    Returns:
      None
    """
    username, password = get_username_and_password('beta')
    auth = HTTPBasicAuth(username, password) # authentication for beta (does nothing for hosts without authentication (e.g. titan)
    while True:
      timestamp, url, params = yield
      if url == '.ping':
        continue
      request_time = datetime.now().isoformat()
      response = requests.post('%s/%s' % (self.prefix, url),
                               data='q='+params, verify=False,
                               auth=auth, stream=False) # data must be string (not dict) to avoid double url-encoding. stream=False to prevent keep-alive connections
      if response.status_code == requests.codes.ok:
        self.successes += 1
        TermColor.PrintStr('%s %s %s' % (request_time, response.status_code, response.url),
                           'GREEN', print_trace=False)
      else:
        self.failures += 1
        TermColor.PrintStr('%s %s %s' % (request_time, response.status_code, response.url),
                           'RED', print_trace=False)
Esempio n. 2
0
def loop():
  from time import sleep
  import threading
  # names of clusters to monitor
  USERNAME, PASSWORD = get_username_and_password('haproxy')

  monitor_group = HAProxyClusterMonitorGroup.create_from_conditions(
    USERNAME, PASSWORD, Flags.ARGS.alert_email, cluster_conditions())

  while True:
    monitor_group.check()
    sleep(Flags.ARGS.sleep_interval)
Esempio n. 3
0
def loop():
    from time import sleep
    import threading
    # names of clusters to monitor
    USERNAME, PASSWORD = get_username_and_password('haproxy')

    monitor_group = HAProxyClusterMonitorGroup.create_from_conditions(
        USERNAME, PASSWORD, Flags.ARGS.alert_email, cluster_conditions())

    while True:
        monitor_group.check()
        sleep(Flags.ARGS.sleep_interval)
Esempio n. 4
0
    def play(self):
        """
    play requests on host
    send requests using send

    Returns:
      None
    """
        username, password = get_username_and_password('beta')
        auth = HTTPBasicAuth(
            username, password
        )  # authentication for beta (does nothing for hosts without authentication (e.g. titan)
        while True:
            timestamp, url, params = yield
            if url == '.ping':
                continue
            request_time = datetime.now().isoformat()
            response = requests.post(
                '%s/%s' % (self.prefix, url),
                data='q=' + params,
                verify=False,
                auth=auth,
                stream=False
            )  # data must be string (not dict) to avoid double url-encoding. stream=False to prevent keep-alive connections
            if response.status_code == requests.codes.ok:
                self.successes += 1
                TermColor.PrintStr(
                    '%s %s %s' %
                    (request_time, response.status_code, response.url),
                    'GREEN',
                    print_trace=False)
            else:
                self.failures += 1
                TermColor.PrintStr(
                    '%s %s %s' %
                    (request_time, response.status_code, response.url),
                    'RED',
                    print_trace=False)