Exemplo n.º 1
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);
}
Exemplo n.º 2
0
/* follow the JSON style similar to http://developer.github.com/v3/ */
void
output_json (GLog * logger, GHolder * holder)
{
  FILE *fp = stdout;
  fprintf (fp, "{\n");  /* open */

  print_json_summary (fp, logger);
  fprintf (fp, ",\n");

  print_json_visitors (fp, holder + VISITORS);
  fprintf (fp, ",\n");

  print_json_complete (fp, holder, logger->process);
  fprintf (fp, ",\n");

  print_json_generic (fp, holder + OS, get_ht_size (ht_unique_visitors));
  fprintf (fp, ",\n");

  print_json_generic (fp, holder + BROWSERS, get_ht_size (ht_unique_visitors));
  fprintf (fp, ",\n");

  print_json_generic (fp, holder + REFERRERS, logger->process);
  fprintf (fp, ",\n");

  print_json_generic (fp, holder + REFERRING_SITES, logger->process);
  fprintf (fp, ",\n");

  print_json_generic (fp, holder + KEYPHRASES, logger->process);
  fprintf (fp, ",\n");

#ifdef HAVE_LIBGEOIP
  print_json_generic (fp, holder + GEO_LOCATION,
                      get_ht_size (ht_unique_visitors));
  fprintf (fp, ",\n");
#endif

  print_json_generic (fp, holder + STATUS_CODES, logger->process);
  fprintf (fp, "\n");

  fprintf (fp, "\n}\n");        /* close */

  fclose (fp);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
/* Iterate over all panels and generate json output. */
static GJSON *
init_json_output (GLog * glog, GHolder * holder)
{
  GJSON *json = NULL;
  GModule module;
  GPercTotals totals;
  const GPanel *panel = NULL;
  size_t idx = 0, npanels = num_panels (), cnt = 0;

  json = new_gjson ();

  popen_obj (json, 0);
  print_json_summary (json, glog, holder);

  FOREACH_MODULE (idx, module_list) {
    module = module_list[idx];

    if (!(panel = panel_lookup (module)))
      continue;

    set_module_totals (module, &totals);
    panel->render (json, holder + module, totals, panel);
    pjson (json, (cnt++ != npanels - 1) ? ",%.*s" : "%.*s", nlines, NL);
  }