示例#1
0
static int do_addlocal(int argc, char **argv)
{
	return do_local(argc, argv, 1);
}
示例#2
0
static int do_dellocal(int argc, char **argv)
{
	return do_local(argc, argv, 0);
}
示例#3
0
int run(void)
{
  xmlDocPtr doc;
  xmlNodePtr node;
  int ct  = STACKCT_OPT(OUTPUT);
  char **output = (char **) &STACKLST_OPT(OUTPUT);
  GString *log;
  int i;
  int color;
  int highest_color = STAT_GREEN;
  char buf[24];
extern int forever;

  uw_setproctitle("sleeping");
  for (i=0; i < OPT_VALUE_INTERVAL; i++) { // wait some minutes
    sleep(1);
    if (!forever)  {
      return(0);
    }
  }

  uw_setproctitle("getting system statistics");
  get_stats();
  doc = UpwatchXmlDoc("result", NULL);
  xmlSetDocCompressMode(doc, OPT_VALUE_COMPRESS);

  // do the sysstat
  node = (xmlNodePtr) newnode(doc, "sysstat");
  add_loadavg(node);
  add_cpu(node);
  add_paging(node);
  add_blockio(node);
  add_swap(node);
  add_memory(node);
  add_systemp(node);
  add_sysstat_info(node);
  color = xmlGetPropInt(node, "color");
  if (color > highest_color) highest_color = color;
#if USE_XMBMON|| defined (__OpenBSD__)
  if (OPT_VALUE_HWSTATS ) { 
    // do the hwstat
    get_hwstats();
    node = (xmlNodePtr) newnode(doc, "hwstat");
    add_hwstat(node);
    color = xmlGetPropInt(node, "color");
    if (color > highest_color) highest_color = color;
  }
#endif
  if (OPT_VALUE_LOCALCHECKS ) { 
   // do the local checks
    color = do_local((xmlNodePtr) doc);
    if (color > highest_color) highest_color = color;
  }

#if HAVE_LIBPCRE
  // do the errlog
  node = (xmlNodePtr) newnode(doc, "errlog");
  log = check_logs(&color);
  if (color > highest_color) highest_color = color;
  sprintf(buf, "%u", color);
  xmlSetProp(node, "color", buf);
  if (log) {
    if (log->str && strlen(log->str) > 0) {
      xmlNewTextChild(node, NULL, "info", log->str);
    }
    g_string_free(log, TRUE);
  }
#endif

  // do the diskfree
  uw_setproctitle("checking diskspace");
  node = (xmlNodePtr) newnode(doc, "diskfree");
  add_diskfree_info(node);
  color = xmlGetPropInt(node, "color");

  if (color > highest_color) highest_color = color;

  if (HAVE_OPT(HPQUEUE) && (highest_color != prv_highest_color)) {
    // if status changed, it needs to be sent immediately. So drop into
    // the high priority queue. Else just drop in the normal queue where
    // uw_send in batched mode will pick it up later
    spool_result(OPT_ARG(SPOOLDIR), OPT_ARG(HPQUEUE), doc, NULL);
  } else {
    for (i=0; i < ct; i++) {
      spool_result(OPT_ARG(SPOOLDIR), output[i], doc, NULL);
    }
  }
  prv_highest_color = highest_color; // remember for next time
  xmlFreeDoc(doc);
  return 0;
}