Beispiel #1
0
  def stats(self, params_list=None):
    """
    'stats' is a more accessible way to get statistics about nodes, processes
    and/or proxies. It could be shown in verbose or not verbose mode,
    it could be sorted by some characteristic and filter to application only
    for proxies statistics. If no options are given it will show full
    statistics about nodes, processes and proxies without filter and
    sorted by default characteristic.

    Args:
      options: A list of additional options about what statistics and how it
        should be shown.

    Raises:
      AppScalefileException: If there is no AppScalefile in the current
      directory.
    """
    contents = self.read_appscalefile()
    command = params_list or []
    contents_as_yaml = yaml.safe_load(contents)
    if 'keyname' in contents_as_yaml:
      command.append("--keyname")
      command.append(contents_as_yaml['keyname'])

    options = ParseArgs(command, "appscale-show-stats").args
    show_stats(options)
Beispiel #2
0
    def stats(self, params_list=None):
        """
    'stats' is a more accessible way to get statistics about nodes, processes
    and/or proxies. It could be shown in verbose or not verbose mode,
    it could be sorted by some characteristic and filter to application only
    for proxies statistics. If no options are given it will show full
    statistics about nodes, processes and proxies without filter and
    sorted by default characteristic.

    Args:
      options: A list of additional options about what statistics and how it
        should be shown.

    Raises:
      AppScalefileException: If there is no AppScalefile in the current
      directory.
    """
        contents = self.read_appscalefile()
        command = params_list or []
        contents_as_yaml = yaml.safe_load(contents)
        if 'keyname' in contents_as_yaml:
            command.append("--keyname")
            command.append(contents_as_yaml['keyname'])

        options = ParseArgs(command, "appscale-show-stats").args
        show_stats(options)
Beispiel #3
0
def main():
  """
  Execute appscale-describe-instances script.
  """
  options = ParseArgs(sys.argv[1:], "appscale-show-stats").args
  try:
    show_stats(options)
    sys.exit(0)
  except Exception, e:
    LocalState.generate_crash_log(e, traceback.format_exc())
    sys.exit(1)
Beispiel #4
0
  def test_show_stats(self, mock_get_stats):
    raw_proxy_stats = {
      '192.168.33.10': {
        'proxies_stats': [
          {
            'unified_service_name': 'taskqueue', 'servers_count': 2,
            'application_id': None, 'backend': {'qcur': 0},
            'frontend': {
              'bin': 0, 'scur': 0, 'hrsp_5xx': 0, 'hrsp_4xx': 0,
              'req_rate': 0, 'req_tot': 0, 'bout': 0
            },
            'servers': [{'status': 'UP'}, {'status': 'DOWN'}]
          },
          {
            'unified_service_name': 'blobstore', 'servers_count': 1,
            'application_id': None, 'backend': {'qcur': 0},
            'frontend': {
              'bin': 0, 'scur': 0, 'hrsp_5xx': 0, 'hrsp_4xx': 0,
              'req_rate': 0, 'req_tot': 0, 'bout': 0
            },
            'servers': [{'status': 'UP'}]
          }
        ]
      }
    }

    mock_get_stats.return_value = (raw_proxy_stats, {})

    options = argparse.Namespace()
    options.keyname = "keyname"
    options.types = ["proxies"]
    options.verbose = False
    options.apps_only = False

    buf = StringIO.StringIO()

    def mock_log(s):
      buf.write(s + "\n")

    logger_fullname = "appscale.tools.appscale_stats.AppScaleLogger.log"

    with patch(logger_fullname, side_effect=mock_log):
      show_stats(options=options)

    expected_table_name = "PROXY STATISTICS"
    unexpected_table_names = [
      "NODE STATISTICS", "SUMMARY PROCESS STATISTICS", "PROCESS STATISTICS"
    ]

    for table_name in unexpected_table_names:
      self.assertNotIn(table_name, buf.getvalue())

    self.assertIn(expected_table_name, buf.getvalue())