Ejemplo n.º 1
0
static void
render_data_line (WINDOW * win, GDashModule * data, int *y, int j,
                  GScroll * gscroll)
{
  GDashRender render;
  GModule module = data->module;
  int expanded = 0, sel = 0, host_bars = 0;
  int x = 0, w, h;

  if (!conf.skip_term_resolver)
    host_bars = 1;

#ifdef HAVE_LIBGEOIP
  host_bars = 1;
#endif

  getmaxyx (win, h, w);
  (void) h;

  if (gscroll->expanded && module == gscroll->current)
    expanded = 1;

  x = DASH_INIT_X;

  if (j >= data->idx_data)
    goto out;

  sel = expanded && j == gscroll->module[module].scroll ? 1 : 0;

  render.win = win;
  render.y = *y;
  render.w = w;
  render.idx = j;
  render.sel = sel;

  render_hits (data, render, &x);
  render_visitors (data, render, &x);
  render_percent (data, render, &x);

  /* render bandwidth if available */
  if (conf.bandwidth)
    render_bandwidth (data, render, &x);

  /* render avgts, cumts and maxts if available */
  if (conf.serve_usecs) {
    render_avgts (data, render, &x);
    render_cumts (data, render, &x);
    render_maxts (data, render, &x);
  }
  /* render request method if available */
  if (conf.append_method)
    render_method (data, render, &x);
  /* render request protocol if available */
  if (conf.append_protocol)
    render_protocol (data, render, &x);
  render_data (data, render, &x);

  /* skip graph bars if module is expanded and we have sub nodes */
  if (module == HOSTS && expanded && host_bars);
  else
    render_bars (data, render, &x);

out:
  (*y)++;
}
Ejemplo n.º 2
0
/* render dashboard content */
void
render_content (WINDOW * win, GDashModule * module_data, int *y, int *offset,
                int *total, GScrolling * scrolling)
{
   int expanded = 0, sel = 0, host_bars = 0;
   int i, j, x = 0, w, h;
   GModule module = module_data->module;

   if (!conf.skip_resolver)
      host_bars = 1;

#ifdef HAVE_LIBGEOIP
   host_bars = 1;
#endif

   getmaxyx (win, h, w);

   if (scrolling->expanded && module == scrolling->current)
      expanded = 1;

   int size = module_data->dash_size;
   for (i = *offset, j = 0; i < size; i++) {
      /* header */
      if ((i % size) == DASH_HEAD_POS) {
         draw_header (win, module_data->head, 0, (*y), w, 1);
         render_total_label (win, module_data, (*y));
         (*y)++;
      }
      /* description */
      else if ((i % size) == DASH_DESC_POS)
         draw_header (win, module_data->desc, 0, (*y)++, w, 2);
      /* blank lines */
      else if ((i % size) == DASH_EMPTY_POS || (i % size) == size - 1)
         (*y)++;
      /* actual data */
      else if ((i % size) >= DASH_DATA_POS || (i % size) <= size - 2) {
         x = DASH_INIT_X;
         /* account for 2 lines at the header and 2 blank lines */
         j = ((i % size) - DASH_DATA_POS) + scrolling->module[module].offset;

         if (j < module_data->idx_data) {
            sel = expanded && j == scrolling->module[module].scroll ? 1 : 0;
            render_hits (win, module_data, *y, &x, j, w, sel);
            render_percent (win, module_data, *y, &x, j, w, sel);
            render_bandwidth (win, module_data, *y, &x, j, w, sel);

            /* render usecs if available */
            if (conf.serve_usecs)
               render_usecs (win, module_data, *y, &x, j, w, sel);
            render_data (win, module_data, *y, &x, j, w, sel);

            /* skip graph bars if module is expanded and we have sub nodes */
            if (module == HOSTS && expanded && host_bars);
            else
               render_bars (win, module_data, *y, &x, j, w, sel);
         }
         (*y)++;
      }
      /* everything else should be empty */
      else
         (*y)++;
      (*total)++;
      if (*y >= h)
         break;
   }
}