Exemple #1
0
/* Entry point to generate a a csv report writing it to the fp */
void
output_csv (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  GPercTotals totals = {
    .hits = logger->valid,
    .visitors = ht_get_size_uniqmap (VISITORS),
    .bw = logger->resp_size,
  };

  if (!conf.no_csv_summary)
    print_csv_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, totals);
  }

  fclose (fp);
}
Exemple #2
0
/* Entry point to generate a a json report writing it to the fp */
void
output_json (GLog * logger, GHolder * holder)
{
  FILE *fp = stdout;
  GModule module;

  GPercTotals totals = {
    .hits = logger->valid,
    .visitors = ht_get_size_uniqmap (VISITORS),
    .bw = logger->resp_size,
  };

  /* use new lines to prettify output */
  if (conf.json_pretty_print)
    nlines = 1;

  pjson (fp, "{%.*s", nlines, NL);
  print_json_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;

    panel->render (fp, holder + module, totals, panel);
    pjson (fp, (module != TOTAL_MODULES - 1) ? ",%.*s" : "%.*s", nlines, NL);
  }
  pjson (fp, "}");

  fclose (fp);
}
Exemple #3
0
static void
set_module_to (GScroll * scrll, GModule module)
{
  if (ignore_panel (module)) {
    disabled_panel_msg (module);
    return;
  }
  /* reset expanded module */
  collapse_current_module ();
  scrll->current = module;
  render_screens ();
}
Exemple #4
0
static int
next_module (void)
{
  gscroll.current++;
  if (gscroll.current == TOTAL_MODULES)
    gscroll.current = 0;

  if (ignore_panel (gscroll.current)) {
    disabled_panel_msg (gscroll.current);
    return 1;
  }

  return 0;
}
Exemple #5
0
static int
previous_module (void)
{
  if (gscroll.current == 0)
    gscroll.current = TOTAL_MODULES - 1;
  else
    gscroll.current--;

  if (ignore_panel (gscroll.current)) {
    disabled_panel_msg (gscroll.current);
    return 1;
  }

  return 0;
}
Exemple #6
0
/* Build an array of available modules (ignores listed panels).
 *
 * If there are no modules enabled, 0 is returned.
 * On success, the first enabled module is returned. */
int
init_modules (void)
{
  GModule module;
  int i;

  /* init - terminating with -1 */
  for (module = 0; module < TOTAL_MODULES; ++module)
    module_list[module] = -1;

  for (i = 0, module = 0; module < TOTAL_MODULES; ++module) {
    if (!ignore_panel (module)) {
      module_list[i++] = module;
    }
  }

  return module_list[0] > -1 ? module_list[0] : 0;
}
Exemple #7
0
/* Entry point to generate a a csv report writing it to the fp */
void
output_csv (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  if (!conf.no_csv_summary)
    print_csv_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, logger->valid);
  }

  fclose (fp);
}
Exemple #8
0
/* follow the JSON style similar to http://developer.github.com/v3/ */
void
output_json (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  fprintf (fp, "{\n");
  print_json_summary (fp, logger);
  for (module = 0; module < TOTAL_MODULES; module++) {
    const GJSON *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, logger->process);
    module != TOTAL_MODULES - 1 ? fprintf (fp, ",\n") : fprintf (fp, "\n");
  }
  fprintf (fp, "}");

  fclose (fp);
}
Exemple #9
0
/* allocate memory for an instance of dashboard */
static void
allocate_data (void)
{
  GModule module;
  int col_data = get_num_collapsed_data_rows ();
  int size = 0;

  dash = new_gdash ();
  for (module = 0; module < TOTAL_MODULES; module++) {
    if (ignore_panel (module))
      continue;

    switch (module) {
    case VISITORS:
      dash->module[module].head =
        (!conf.ignore_crawlers ? VISIT_HEAD INCLUDE_BOTS : VISIT_HEAD);
      break;
    case REQUESTS:
      dash->module[module].head = REQUE_HEAD;
      break;
    case REQUESTS_STATIC:
      dash->module[module].head = STATI_HEAD;
      break;
    case NOT_FOUND:
      dash->module[module].head = FOUND_HEAD;
      break;
    case HOSTS:
      dash->module[module].head = HOSTS_HEAD;
      break;
    case OS:
      dash->module[module].head = OPERA_HEAD;
      break;
    case BROWSERS:
      dash->module[module].head = BROWS_HEAD;
      break;
    case VISIT_TIMES:
      dash->module[module].head = VTIME_HEAD;
      break;
    case REFERRERS:
      dash->module[module].head = REFER_HEAD;
      break;
    case REFERRING_SITES:
      dash->module[module].head = SITES_HEAD;
      break;
    case KEYPHRASES:
      dash->module[module].head = KEYPH_HEAD;
      break;
#ifdef HAVE_LIBGEOIP
    case GEO_LOCATION:
      dash->module[module].head = GEOLO_HEAD;
      break;
#endif
    case STATUS_CODES:
      dash->module[module].head = CODES_HEAD;
      break;
    }

    size = holder[module].idx;
    if (gscroll.expanded && module == gscroll.current) {
      size = size > MAX_CHOICES ? MAX_CHOICES : holder[module].idx;
    } else {
      size = holder[module].idx > col_data ? col_data : holder[module].idx;
    }

    dash->module[module].alloc_data = size;     /* data allocated  */
    dash->module[module].ht_size = holder[module].ht_size;      /* hash table size */
    dash->module[module].idx_data = 0;
    dash->module[module].pos_y = 0;

    if (gscroll.expanded && module == gscroll.current)
      dash->module[module].dash_size = DASH_EXPANDED;
    else
      dash->module[module].dash_size = DASH_COLLAPSED;
    dash->total_alloc += dash->module[module].dash_size;

    pthread_mutex_lock (&gdns_thread.mutex);
    load_data_to_dash (&holder[module], dash, module, &gscroll);
    pthread_mutex_unlock (&gdns_thread.mutex);
  }
}