Exemple #1
0
static void
render_header (WINDOW * win, GDashModule * data, GModule cur_module, int *y)
{
  char ind;
  char *hd;
  int k, w, h, color;

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

  k = data->module + 1;
  ind = cur_module == data->module ? '>' : ' ';
  color = cur_module == data->module &&
    conf.hl_header ? YELLOW_BLACK : HIGHLIGHT;
  hd = xmalloc (snprintf (NULL, 0, "%c %d - %s", ind, k, data->head) + 1);
  sprintf (hd, "%c %d - %s", ind, k, data->head);

  draw_header (win, hd, " %s", (*y), 0, w, color, 0);
  free (hd);

  render_total_label (win, data, (*y), color);
  data->pos_y = (*y);
  (*y)++;
}
Exemple #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;
   }
}