• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cf_util_get_boolean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cf_util_get_boolean函数的典型用法代码示例。如果您正苦于以下问题:C++ cf_util_get_boolean函数的具体用法?C++ cf_util_get_boolean怎么用?C++ cf_util_get_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cf_util_get_boolean函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rc_config

static int rc_config(oconfig_item_t *ci) {
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t const *child = ci->children + i;
    const char *key = child->key;
    int status = 0;

    if (strcasecmp("DataDir", key) == 0) {
      status = cf_util_get_string(child, &datadir);
      if (status == 0) {
        int len = strlen(datadir);

        while ((len > 0) && (datadir[len - 1] == '/')) {
          len--;
          datadir[len] = 0;
        }

        if (len <= 0)
          sfree(datadir);
      }
    } else if (strcasecmp("DaemonAddress", key) == 0)
      status = cf_util_get_string(child, &daemon_address);
    else if (strcasecmp("CreateFiles", key) == 0)
      status = cf_util_get_boolean(child, &config_create_files);
    else if (strcasecmp("CreateFilesAsync", key) == 0)
      status = cf_util_get_boolean(child, &rrdcreate_config.async);
    else if (strcasecmp("CollectStatistics", key) == 0)
      status = cf_util_get_boolean(child, &config_collect_stats);
    else if (strcasecmp("StepSize", key) == 0) {
      int tmp = -1;

      status = rc_config_get_int_positive(child, &tmp);
      if (status == 0)
        rrdcreate_config.stepsize = (unsigned long)tmp;
    } else if (strcasecmp("HeartBeat", key) == 0)
      status = rc_config_get_int_positive(child, &rrdcreate_config.heartbeat);
    else if (strcasecmp("RRARows", key) == 0)
      status = rc_config_get_int_positive(child, &rrdcreate_config.rrarows);
    else if (strcasecmp("RRATimespan", key) == 0) {
      int tmp = -1;
      status = rc_config_get_int_positive(child, &tmp);
      if (status == 0)
        status = rc_config_add_timespan(tmp);
    } else if (strcasecmp("XFF", key) == 0)
      status = rc_config_get_xff(child, &rrdcreate_config.xff);
    else {
      WARNING("rrdcached plugin: Ignoring invalid option %s.", key);
      continue;
    }

    if (status != 0)
      WARNING("rrdcached plugin: Handling the \"%s\" option failed.", key);
  }

  if (daemon_address != NULL) {
    plugin_register_write("rrdcached", rc_write, /* user_data = */ NULL);
    plugin_register_flush("rrdcached", rc_flush, /* user_data = */ NULL);
  }
  return 0;
} /* int rc_config */
开发者ID:EMSL-MSC,项目名称:collectd,代码行数:59,代码来源:rrdcached.c


示例2: dpdk_events_link_status_config

static int dpdk_events_link_status_config(dpdk_events_ctx_t *ec,
                                          oconfig_item_t *ci) {
  ec->config.link_status.enabled = 1;

  DEBUG(DPDK_EVENTS_PLUGIN ": Subscribed for Link Status Events.");

  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp("EnabledPortMask", child->key) == 0) {
      if (cf_util_get_int(child,
                          (int *)&ec->config.link_status.enabled_port_mask))
        return -1;
      DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:Enabled Port Mask 0x%X",
            ec->config.link_status.enabled_port_mask);
    } else if (strcasecmp("SendEventsOnUpdate", child->key) == 0) {
      if (cf_util_get_boolean(child, &ec->config.link_status.send_updated))
        return -1;
      DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:SendEventsOnUpdate %d",
            ec->config.link_status.send_updated);
    } else if (strcasecmp("SendNotification", child->key) == 0) {
      if (cf_util_get_boolean(child, &ec->config.link_status.notify))
        return -1;

      DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:SendNotification %d",
            ec->config.link_status.notify);
    } else if (strcasecmp("PortName", child->key) != 0) {
      ERROR(DPDK_EVENTS_PLUGIN ": unrecognized configuration option %s.",
            child->key);
      return -1;
    }
  }

  int port_num = 0;

  /* parse port names after EnabledPortMask was parsed */
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;
    if (strcasecmp("PortName", child->key) == 0) {
      while (!(ec->config.link_status.enabled_port_mask & (1 << port_num)))
        port_num++;

      if (cf_util_get_string_buffer(
              child, ec->config.link_status.port_name[port_num],
              sizeof(ec->config.link_status.port_name[port_num]))) {
        return -1;
      }
      DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:Port %d Name: %s", port_num,
            ec->config.link_status.port_name[port_num]);
      port_num++;
    }
  }

  return 0;
}
开发者ID:Feandil,项目名称:collectd,代码行数:55,代码来源:dpdkevents.c


示例3: memory_config

static int memory_config(oconfig_item_t *ci) /* {{{ */
{
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;
    if (strcasecmp("ValuesAbsolute", child->key) == 0)
      cf_util_get_boolean(child, &values_absolute);
    else if (strcasecmp("ValuesPercentage", child->key) == 0)
      cf_util_get_boolean(child, &values_percentage);
    else
      ERROR("memory plugin: Invalid configuration option: "
            "\"%s\".",
            child->key);
  }

  return 0;
} /* }}} int memory_config */
开发者ID:BrandonArp,项目名称:collectd,代码行数:16,代码来源:memory.c


示例4: statsd_config_node

static int statsd_config_node (statsd_config_t *conf, oconfig_item_t *ci)
{
  int i;

  for (i = 0; i < ci->children_num; i++) {

    oconfig_item_t *child = ci->children + i;

    if (strcasecmp ("Host", child->key) == 0)
      cf_util_get_string (child, &conf->host);
    else if (strcasecmp ("Port", child->key) == 0)
      cf_util_get_service (child, &conf->service);
    else if (strcasecmp ("DeleteCounters", child->key) == 0)
      cf_util_get_boolean (child, &conf->delete_counters);
    else if (strcasecmp ("DeleteTimers", child->key) == 0)
      cf_util_get_boolean (child, &conf->delete_timers);
    else if (strcasecmp ("DeleteGauges", child->key) == 0)
      cf_util_get_boolean (child, &conf->delete_gauges);
    else if (strcasecmp ("DeleteSets", child->key) == 0)
      cf_util_get_boolean (child, &conf->delete_sets);
    else if (strcasecmp ("TimerLower", child->key) == 0)
      cf_util_get_boolean (child, &conf->timer_lower);
    else if (strcasecmp ("TimerUpper", child->key) == 0)
      cf_util_get_boolean (child, &conf->timer_upper);
    else if (strcasecmp ("TimerSum", child->key) == 0)
      cf_util_get_boolean (child, &conf->timer_sum);
    else if (strcasecmp ("TimerCount", child->key) == 0)
      cf_util_get_boolean (child, &conf->timer_count);
    else if (strcasecmp ("LeaveMetricsNameASIS", child->key) == 0)
      cf_util_get_boolean (child, &conf->leave_metrics_name_asis);
    else if (strcasecmp ("GlobalPrefix", child->key) == 0)
      cf_util_get_string (child, &conf->global_prefix);
    else if (strcasecmp ("CounterPrefix", child->key) == 0)
      cf_util_get_string (child, &conf->counter_prefix);
    else if (strcasecmp ("TimerPrefix", child->key) == 0)
      cf_util_get_string (child, &conf->timer_prefix);
    else if (strcasecmp ("GaugePrefix", child->key) == 0)
      cf_util_get_string (child, &conf->gauge_prefix);
    else if (strcasecmp ("SetPrefix", child->key) == 0)
      cf_util_get_string (child, &conf->set_prefix);
    else if (strcasecmp ("GlobalPostfix", child->key) == 0)
      cf_util_get_string (child, &conf->global_postfix);
    else if (strcasecmp ("TimerPercentile", child->key) == 0)
      statsd_config_timer_percentile (conf, child);
    else
      ERROR ("statsd plugin: The \"%s\" config option is not valid.",
             child->key);
  }

  return (0);
}
开发者ID:skolot,项目名称:collectd,代码行数:51,代码来源:statsd.c


示例5: dpdk_events_keep_alive_config

static int dpdk_events_keep_alive_config(dpdk_events_ctx_t *ec,
                                         oconfig_item_t *ci) {
  ec->config.keep_alive.enabled = 1;
  DEBUG(DPDK_EVENTS_PLUGIN ": Subscribed for Keep Alive Events.");

  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp("SendEventsOnUpdate", child->key) == 0) {
      if (cf_util_get_boolean(child, &ec->config.keep_alive.send_updated))
        return -1;

      DEBUG(DPDK_EVENTS_PLUGIN ": KeepAlive:SendEventsOnUpdate %d",
            ec->config.keep_alive.send_updated);
    } else if (strcasecmp("LCoreMask", child->key) == 0) {
      char lcore_mask[DATA_MAX_NAME_LEN];

      if (cf_util_get_string_buffer(child, lcore_mask, sizeof(lcore_mask)))
        return -1;
      ec->config.keep_alive.lcore_mask =
          str_to_uint128(lcore_mask, strlen(lcore_mask));
      DEBUG(DPDK_EVENTS_PLUGIN ": KeepAlive:LCoreMask 0x%" PRIX64 "%" PRIX64 "",
            ec->config.keep_alive.lcore_mask.high,
            ec->config.keep_alive.lcore_mask.low);
    } else if (strcasecmp("KeepAliveShmName", child->key) == 0) {
      if (cf_util_get_string_buffer(child, ec->config.keep_alive.shm_name,
                                    sizeof(ec->config.keep_alive.shm_name)))
        return -1;

      DEBUG(DPDK_EVENTS_PLUGIN ": KeepAlive:KeepAliveShmName %s",
            ec->config.keep_alive.shm_name);
    } else if (strcasecmp("SendNotification", child->key) == 0) {
      if (cf_util_get_boolean(child, &ec->config.keep_alive.notify))
        return -1;

      DEBUG(DPDK_EVENTS_PLUGIN ": KeepAlive:SendNotification %d",
            ec->config.keep_alive.notify);
    } else {
      ERROR(DPDK_EVENTS_PLUGIN ": unrecognized configuration option %s.",
            child->key);
      return -1;
    }
  }

  return 0;
}
开发者ID:Feandil,项目名称:collectd,代码行数:46,代码来源:dpdkevents.c


示例6: battery_config

static int battery_config(oconfig_item_t *ci) {
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp("ValuesPercentage", child->key) == 0)
      cf_util_get_boolean(child, &report_percent);
    else if (strcasecmp("ReportDegraded", child->key) == 0)
      cf_util_get_boolean(child, &report_degraded);
    else if (strcasecmp("QueryStateFS", child->key) == 0)
      cf_util_get_boolean(child, &query_statefs);
    else
      WARNING("battery plugin: Ignoring unknown "
              "configuration option \"%s\".",
              child->key);
  }

  return (0);
} /* }}} int battery_config */
开发者ID:ajdiaz,项目名称:collectd,代码行数:18,代码来源:battery.c


示例7: swap_config

static int swap_config(oconfig_item_t *ci) /* {{{ */
{
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;
    if (strcasecmp("ReportBytes", child->key) == 0)
#if KERNEL_LINUX
      cf_util_get_boolean(child, &report_bytes);
#else
      WARNING("swap plugin: The \"ReportBytes\" option "
              "is only valid under Linux. "
              "The option is going to be ignored.");
#endif
    else if (strcasecmp("ReportByDevice", child->key) == 0)
#if SWAP_HAVE_REPORT_BY_DEVICE
      cf_util_get_boolean(child, &report_by_device);
#else
      WARNING("swap plugin: The \"ReportByDevice\" option "
              "is not supported on this platform. "
              "The option is going to be ignored.");
#endif /* SWAP_HAVE_REPORT_BY_DEVICE */
    else if (strcasecmp("ValuesAbsolute", child->key) == 0)
开发者ID:Feandil,项目名称:collectd,代码行数:21,代码来源:swap.c


示例8: apcups_config

static int apcups_config (oconfig_item_t *ci)
{
	int i;
	_Bool persistent_conn_set = 0;

	for (i = 0; i < ci->children_num; i++)
	{
		oconfig_item_t *child = ci->children + i;

		if (strcasecmp (child->key, "Host") == 0)
			cf_util_get_string (child, &conf_node);
		else if (strcasecmp (child->key, "Port") == 0)
			cf_util_get_service (child, &conf_service);
		else if (strcasecmp (child->key, "ReportSeconds") == 0)
			cf_util_get_boolean (child, &conf_report_seconds);
		else if (strcasecmp (child->key, "PersistentConnection") == 0) {
			cf_util_get_boolean (child, &conf_persistent_conn);
			persistent_conn_set = 1;
		}
		else
			ERROR ("apcups plugin: Unknown config option \"%s\".", child->key);
	}

	if (!persistent_conn_set) {
		double interval = CDTIME_T_TO_DOUBLE(plugin_get_interval());
		if (interval > APCUPS_SERVER_TIMEOUT) {
			NOTICE ("apcups plugin: Plugin poll interval set to %.3f seconds. "
				"Apcupsd NIS socket timeout is %.3f seconds, "
				"PersistentConnection disabled by default.",
				interval, APCUPS_SERVER_TIMEOUT);
			conf_persistent_conn = 0;
		}
	}

	return (0);
} /* int apcups_config */
开发者ID:strizhechenko,项目名称:collectd,代码行数:36,代码来源:apcups.c


示例9: statsd_config

static int statsd_config (oconfig_item_t *ci) /* {{{ */
{
  int i;

  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp ("Host", child->key) == 0)
      cf_util_get_string (child, &conf_node);
    else if (strcasecmp ("Port", child->key) == 0)
      cf_util_get_service (child, &conf_service);
    else if (strcasecmp ("DeleteCounters", child->key) == 0)
      cf_util_get_boolean (child, &conf_delete_counters);
    else if (strcasecmp ("DeleteTimers", child->key) == 0)
      cf_util_get_boolean (child, &conf_delete_timers);
    else if (strcasecmp ("DeleteGauges", child->key) == 0)
      cf_util_get_boolean (child, &conf_delete_gauges);
    else if (strcasecmp ("DeleteSets", child->key) == 0)
      cf_util_get_boolean (child, &conf_delete_sets);
    else if (strcasecmp ("CounterSum", child->key) == 0)
      cf_util_get_boolean (child, &conf_counter_sum);
    else if (strcasecmp ("TimerLower", child->key) == 0)
      cf_util_get_boolean (child, &conf_timer_lower);
    else if (strcasecmp ("TimerUpper", child->key) == 0)
      cf_util_get_boolean (child, &conf_timer_upper);
    else if (strcasecmp ("TimerSum", child->key) == 0)
      cf_util_get_boolean (child, &conf_timer_sum);
    else if (strcasecmp ("TimerCount", child->key) == 0)
      cf_util_get_boolean (child, &conf_timer_count);
    else if (strcasecmp ("TimerPercentile", child->key) == 0)
      statsd_config_timer_percentile (child);
    else
      ERROR ("statsd plugin: The \"%s\" config option is not valid.",
          child->key);
  }

  return (0);
} /* }}} int statsd_config */
开发者ID:beorn-,项目名称:collectd,代码行数:39,代码来源:statsd.c


示例10: ethstat_config

static int ethstat_config(oconfig_item_t *ci) /* {{{ */
{
  for (int i = 0; i < ci->children_num; i++) {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp("Interface", child->key) == 0)
      ethstat_add_interface(child);
    else if (strcasecmp("Map", child->key) == 0)
      ethstat_add_map(child);
    else if (strcasecmp("MappedOnly", child->key) == 0)
      (void)cf_util_get_boolean(child, &collect_mapped_only);
    else
      WARNING("ethstat plugin: The config option \"%s\" is unknown.",
              child->key);
  }

  return 0;
} /* }}} */
开发者ID:Feandil,项目名称:collectd,代码行数:18,代码来源:ethstat.c


示例11: calloc

/*
 * Public API
 */
curl_stats_t *curl_stats_from_config (oconfig_item_t *ci)
{
	curl_stats_t *s;
	int i;

	if (ci == NULL)
		return NULL;

	s = calloc (1, sizeof (*s));
	if (s == NULL)
		return NULL;

	for (i = 0; i < ci->children_num; ++i)
	{
		oconfig_item_t *c = ci->children + i;
		size_t field;

		_Bool enabled = 0;

		for (field = 0; field < STATIC_ARRAY_SIZE (field_specs); ++field) {
			if (! strcasecmp (c->key, field_specs[field].config_key))
				break;
			if (! strcasecmp (c->key, field_specs[field].name))
				break;
		}
		if (field >= STATIC_ARRAY_SIZE (field_specs))
		{
			ERROR ("curl stats: Unknown field name %s", c->key);
			free (s);
			return NULL;
		}


		if (cf_util_get_boolean (c, &enabled) != 0) {
			free (s);
			return NULL;
		}
		if (enabled)
			enable_field (s, field_specs[field].offset);
	}

	return s;
} /* curl_stats_from_config */
开发者ID:beorn-,项目名称:collectd,代码行数:46,代码来源:utils_curl_stats.c


示例12: kafka_config_topic


//.........这里部分代码省略.........
                break;
            }

            if (strcasecmp(tmp_buf, "Random") != 0) {
                tctx->has_key = 1;
                tctx->key = crc32_buffer((u_char *)tmp_buf, strlen(tmp_buf));
            }
            sfree(tmp_buf);

        } else if (strcasecmp ("Format", child->key) == 0) {
            status = cf_util_get_string(child, &key);
            if (status != 0)
                goto errout;

            assert(key != NULL);

            if (strcasecmp(key, "Command") == 0) {

                tctx->format = KAFKA_FORMAT_COMMAND;

            } else if (strcasecmp(key, "Graphite") == 0) {
                tctx->format = KAFKA_FORMAT_GRAPHITE;

            } else if (strcasecmp(key, "Json") == 0) {
                tctx->format = KAFKA_FORMAT_JSON;

            } else {
                WARNING ("write_kafka plugin: Invalid format string: %s",
                         key);
            }
            sfree(key);

        } else if (strcasecmp ("StoreRates", child->key) == 0) {
            status = cf_util_get_boolean (child, &tctx->store_rates);
            (void) cf_util_get_flag (child, &tctx->graphite_flags,
                                     GRAPHITE_STORE_RATES);

        } else if (strcasecmp ("GraphiteSeparateInstances", child->key) == 0) {
            status = cf_util_get_flag (child, &tctx->graphite_flags,
                                       GRAPHITE_SEPARATE_INSTANCES);

        } else if (strcasecmp ("GraphiteAlwaysAppendDS", child->key) == 0) {
            status = cf_util_get_flag (child, &tctx->graphite_flags,
                                       GRAPHITE_ALWAYS_APPEND_DS);

        } else if (strcasecmp ("GraphitePrefix", child->key) == 0) {
            status = cf_util_get_string (child, &tctx->prefix);
        } else if (strcasecmp ("GraphitePostfix", child->key) == 0) {
            status = cf_util_get_string (child, &tctx->postfix);
        } else if (strcasecmp ("GraphiteEscapeChar", child->key) == 0) {
            char *tmp_buff = NULL;
            status = cf_util_get_string (child, &tmp_buff);
            if (strlen (tmp_buff) > 1)
                WARNING ("write_kafka plugin: The option \"GraphiteEscapeChar\" handles "
                        "only one character. Others will be ignored.");
            tctx->escape_char = tmp_buff[0];
            sfree (tmp_buff);
        } else {
            WARNING ("write_kafka plugin: Invalid directive: %s.", child->key);
        }

        if (status != 0)
            break;
    }

    rd_kafka_topic_conf_set_partitioner_cb(tctx->conf, kafka_partition);
开发者ID:adanin,项目名称:collectd,代码行数:67,代码来源:write_kafka.c


示例13: cx_config_add_url

static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
{
  cx_t *db;
  int status = 0;
  int i;

  if ((ci->values_num != 1)
      || (ci->values[0].type != OCONFIG_TYPE_STRING))
  {
    WARNING ("curl_xml plugin: The `URL' block "
             "needs exactly one string argument.");
    return (-1);
  }

  db = (cx_t *) malloc (sizeof (*db));
  if (db == NULL)
  {
    ERROR ("curl_xml plugin: malloc failed.");
    return (-1);
  }
  memset (db, 0, sizeof (*db));

  db->timeout = -1;

  if (strcasecmp ("URL", ci->key) == 0)
  {
    status = cf_util_get_string (ci, &db->url);
    if (status != 0)
    {
      sfree (db);
      return (status);
    }
  }
  else
  {
    ERROR ("curl_xml plugin: cx_config: "
           "Invalid key: %s", ci->key);
    cx_free (db);
    return (-1);
  }

  /* Fill the `cx_t' structure.. */
  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp ("Instance", child->key) == 0)
      status = cf_util_get_string (child, &db->instance);
    else if (strcasecmp ("Host", child->key) == 0)
      status = cf_util_get_string (child, &db->host);
    else if (strcasecmp ("User", child->key) == 0)
      status = cf_util_get_string (child, &db->user);
    else if (strcasecmp ("Password", child->key) == 0)
      status = cf_util_get_string (child, &db->pass);
    else if (strcasecmp ("Digest", child->key) == 0)
      status = cf_util_get_boolean (child, &db->digest);
    else if (strcasecmp ("VerifyPeer", child->key) == 0)
      status = cf_util_get_boolean (child, &db->verify_peer);
    else if (strcasecmp ("VerifyHost", child->key) == 0)
      status = cf_util_get_boolean (child, &db->verify_host);
    else if (strcasecmp ("CACert", child->key) == 0)
      status = cf_util_get_string (child, &db->cacert);
    else if (strcasecmp ("xpath", child->key) == 0)
      status = cx_config_add_xpath (db, child);
    else if (strcasecmp ("Header", child->key) == 0)
      status = cx_config_append_string ("Header", &db->headers, child);
    else if (strcasecmp ("Post", child->key) == 0)
      status = cf_util_get_string (child, &db->post_body);
    else if (strcasecmp ("Namespace", child->key) == 0)
      status = cx_config_add_namespace (db, child);
    else if (strcasecmp ("Timeout", child->key) == 0)
      status = cf_util_get_int (child, &db->timeout);
    else
    {
      WARNING ("curl_xml plugin: Option `%s' not allowed here.", child->key);
      status = -1;
    }

    if (status != 0)
      break;
  }

  if (status == 0)
  {
    if (db->list == NULL)
    {
      WARNING ("curl_xml plugin: No (valid) `Key' block "
               "within `URL' block `%s'.", db->url);
      status = -1;
    }
    if (status == 0)
      status = cx_init_curl (db);
  }

  /* If all went well, register this database for reading */
  if (status == 0)
  {
    user_data_t ud;
    char *cb_name;

//.........这里部分代码省略.........
开发者ID:Mindera,项目名称:collectd,代码行数:101,代码来源:curl_xml.c


示例14: mr_create

static int mr_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
{
	mr_match_t *m;
	int status;
	int i;

	m = (mr_match_t *) malloc (sizeof (*m));
	if (m == NULL)
	{
		log_err ("mr_create: malloc failed.");
		return (-ENOMEM);
	}
	memset (m, 0, sizeof (*m));
	
	m->invert = 0;

	status = 0;
	for (i = 0; i < ci->children_num; i++)
	{
		oconfig_item_t *child = ci->children + i;

		if ((strcasecmp ("Host", child->key) == 0)
				|| (strcasecmp ("Hostname", child->key) == 0))
			status = mr_config_add_regex (&m->host, child);
		else if (strcasecmp ("Plugin", child->key) == 0)
			status = mr_config_add_regex (&m->plugin, child);
		else if (strcasecmp ("PluginInstance", child->key) == 0)
			status = mr_config_add_regex (&m->plugin_instance, child);
		else if (strcasecmp ("Type", child->key) == 0)
			status = mr_config_add_regex (&m->type, child);
		else if (strcasecmp ("TypeInstance", child->key) == 0)
			status = mr_config_add_regex (&m->type_instance, child);
		else if (strcasecmp ("Invert", child->key) == 0)
			status = cf_util_get_boolean(child, &m->invert);
		else
		{
			log_err ("The `%s' configuration option is not understood and "
					"will be ignored.", child->key);
			status = 0;
		}

		if (status != 0)
			break;
	}

	/* Additional sanity-checking */
	while (status == 0)
	{
		if ((m->host == NULL)
				&& (m->plugin == NULL)
				&& (m->plugin_instance == NULL)
				&& (m->type == NULL)
				&& (m->type_instance == NULL))
		{
			log_err ("No (valid) regular expressions have been configured. "
					"This match will be ignored.");
			status = -1;
		}

		break;
	}

	if (status != 0)
	{
		mr_free_match (m);
		return (status);
	}

	*user_data = m;
	return (0);
} /* }}} int mr_create */
开发者ID:BrianB2,项目名称:collectd,代码行数:71,代码来源:match_regex.c


示例15: riemann_config_node

static int
riemann_config_node(oconfig_item_t *ci)
{
	struct riemann_host	*host = NULL;
	int			 status = 0;
	int			 i;
	oconfig_item_t		*child;
	char			 callback_name[DATA_MAX_NAME_LEN];
	user_data_t		 ud;

	if ((host = calloc(1, sizeof (*host))) == NULL) {
		ERROR ("write_riemann plugin: calloc failed.");
		return ENOMEM;
	}
	pthread_mutex_init (&host->lock, NULL);
	host->reference_count = 1;
	host->node = NULL;
	host->service = NULL;
	host->store_rates = 1;
	host->always_append_ds = 0;
	host->use_tcp = 0;

	status = cf_util_get_string (ci, &host->name);
	if (status != 0) {
		WARNING("write_riemann plugin: Required host name is missing.");
		riemann_free (host);
		return -1;
	}

	for (i = 0; i < ci->children_num; i++) {
		/*
		 * The code here could be simplified but makes room
		 * for easy adding of new options later on.
		 */
		child = &ci->children[i];
		status = 0;

		if (strcasecmp ("Host", child->key) == 0) {
			status = cf_util_get_string (child, &host->node);
			if (status != 0)
				break;
		} else if (strcasecmp ("Port", child->key) == 0) {
			status = cf_util_get_service (child, &host->service);
			if (status != 0) {
				ERROR ("write_riemann plugin: Invalid argument "
						"configured for the \"Port\" "
						"option.");
				break;
			}
		} else if (strcasecmp ("Protocol", child->key) == 0) {
			char tmp[16];
			status = cf_util_get_string_buffer (child,
					tmp, sizeof (tmp));
			if (status != 0)
			{
				ERROR ("write_riemann plugin: cf_util_get_"
						"string_buffer failed with "
						"status %i.", status);
				break;
			}

			if (strcasecmp ("UDP", tmp) == 0)
				host->use_tcp = 0;
			else if (strcasecmp ("TCP", tmp) == 0)
				host->use_tcp = 1;
			else
				WARNING ("write_riemann plugin: The value "
						"\"%s\" is not valid for the "
						"\"Protocol\" option. Use "
						"either \"UDP\" or \"TCP\".",
						tmp);
		} else if (strcasecmp ("StoreRates", child->key) == 0) {
			status = cf_util_get_boolean (child, &host->store_rates);
			if (status != 0)
				break;
		} else if (strcasecmp ("AlwaysAppendDS", child->key) == 0) {
			status = cf_util_get_boolean (child,
					&host->always_append_ds);
			if (status != 0)
				break;
		} else {
			WARNING("write_riemann plugin: ignoring unknown config "
				"option: \"%s\"", child->key);
		}
	}
	if (status != 0) {
		riemann_free (host);
		return status;
	}

	ssnprintf (callback_name, sizeof (callback_name), "write_riemann/%s",
			host->name);
	ud.data = host;
	ud.free_func = riemann_free;

	pthread_mutex_lock (&host->lock);

	status = plugin_register_write (callback_name, riemann_write, &ud);
	if (status != 0)
		WARNING ("write_riemann plugin: plugin_register_write (\"%s\") "
//.........这里部分代码省略.........
开发者ID:iriscouch,项目名称:collectd,代码行数:101,代码来源:write_riemann.c


示例16: csnmp_config_add_data

static int csnmp_config_add_data (oconfig_item_t *ci)
{
  data_definition_t *dd;
  int status = 0;
  int i;

  dd = (data_definition_t *) malloc (sizeof (data_definition_t));
  if (dd == NULL)
    return (-1);
  memset (dd, '\0', sizeof (data_definition_t));

  status = cf_util_get_string(ci, &dd->name);
  if (status != 0)
  {
    free (dd);
    return (-1);
  }

  dd->scale = 1.0;
  dd->shift = 0.0;

  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *option = ci->children + i;

    if (strcasecmp ("Type", option->key) == 0)
      status = cf_util_get_string(option, &dd->type);
    else if (strcasecmp ("Table", option->key) == 0)
      status = cf_util_get_boolean(option, &dd->is_table);
    else if (strcasecmp ("Instance", option->key) == 0)
      status = csnmp_config_add_data_instance (dd, option);
    else if (strcasecmp ("InstancePrefix", option->key) == 0)
      status = csnmp_config_add_data_instance_prefix (dd, option);
    else if (strcasecmp ("Values", option->key) == 0)
      status = csnmp_config_add_data_values (dd, option);
    else if (strcasecmp ("Shift", option->key) == 0)
      status = cf_util_get_double(option, &dd->shift);
    else if (strcasecmp ("Scale", option->key) == 0)
      status = cf_util_get_double(option, &dd->scale);
    else if (strcasecmp ("Ignore", option->key) == 0)
      status = csnmp_config_add_data_blacklist(dd, option);
    else if (strcasecmp ("InvertMatch", option->key) == 0)
      status = csnmp_config_add_data_blacklist_match_inverted(dd, option);
    else
    {
      WARNING ("snmp plugin: Option `%s' not allowed here.", option->key);
      status = -1;
    }

    if (status != 0)
      break;
  } /* for (ci->children) */

  while (status == 0)
  {
    if (dd->type == NULL)
    {
      WARNING ("snmp plugin: `Type' not given for data `%s'", dd->name);
      status = -1;
      break;
    }
    if (dd->values == NULL)
    {
      WARNING ("snmp plugin: No `Value' given for data `%s'", dd->name);
      status = -1;
      break;
    }

    break;
  } /* while (status == 0) */

  if (status != 0)
  {
    sfree (dd->name);
    sfree (dd->instance_prefix);
    sfree (dd->values);
    sfree (dd->ignores);
    sfree (dd);
    return (-1);
  }

  DEBUG ("snmp plugin: dd = { name = %s, type = %s, is_table = %s, values_len = %zu }",
      dd->name, dd->type, (dd->is_table != 0) ? "true" : "false", dd->values_len);

  if (data_head == NULL)
    data_head = dd;
  else
  {
    data_definition_t *last;
    last = data_head;
    while (last->next != NULL)
      last = last->next;
    last->next = dd;
  }

  return (0);
} /* int csnmp_config_add_data */
开发者ID:kmiku7,项目名称:collectd,代码行数:97,代码来源:snmp.c


示例17: wm_config_node

static int wm_config_node (oconfig_item_t *ci) /* {{{ */
{
  wm_node_t *node;
  int status;

  node = calloc (1, sizeof (*node));
  if (node == NULL)
    return (ENOMEM);
  mongo_init (node->conn);
  node->host = NULL;
  node->store_rates = 1;
  pthread_mutex_init (&node->lock, /* attr = */ NULL);

  status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name));

  if (status != 0)
  {
    sfree (node);
    return (status);
  }

  for (int i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp ("Host", child->key) == 0)
      status = cf_util_get_string (child, &node->host);
    else if (strcasecmp ("Port", child->key) == 0)
    {
      status = cf_util_get_port_number (child);
      if (status > 0)
      {
        node->port = status;
        status = 0;
      }
    }
    else if (strcasecmp ("Timeout", child->key) == 0)
      status = cf_util_get_int (child, &node->timeout);
    else if (strcasecmp ("StoreRates", child->key) == 0)
      status = cf_util_get_boolean (child, &node->store_rates);
    else if (strcasecmp ("Database", child->key) == 0)
      status = cf_util_get_string (child, &node->db);
    else if (strcasecmp ("User", child->key) == 0)
      status = cf_util_get_string (child, &node->user);
    else if (strcasecmp ("Password", child->key) == 0)
      status = cf_util_get_string (child, &node->passwd);
    else
      WARNING ("write_mongodb plugin: Ignoring unknown config option \"%s\".",
          child->key);

    if (status != 0)
      break;
  } /* for (i = 0; i < ci->children_num; i++) */

  if ((node->db != NULL) || (node->user != NULL) || (node->passwd != NULL))
  {
    if ((node->db == NULL) || (node->user == NULL) || (node->passwd == NULL))
    {
      WARNING ("write_mongodb plugin: Authentication requires the "
          "\"Database\", \"User\" and \"Password\" options to be specified, "
          "but at last one of them is missing. Authentication will NOT be "
          "used.");
      sfree (node->db);
      sfree (node->user);
      sfree (node->passwd);
    }
  }

  if (status == 0)
  {
    char cb_name[DATA_MAX_NAME_LEN];
    user_data_t ud;

    ssnprintf (cb_name, sizeof (cb_name), "write_mongodb/%s", node->name);

    ud.data = node;
    ud.free_func = wm_config_free;

    status = plugin_register_write (cb_name, wm_write, &ud);
    INFO ("write_mongodb plugin: registered write plugin %s %d",cb_name,status);
  }

  if (status != 0)
    wm_config_free (node);

  return (status);
} /* }}} int wm_config_node */
开发者ID:manuelluis,项目名称:collectd,代码行数:87,代码来源:write_mongodb.c


示例18: cc_config_add_page

static int cc_config_add_page (oconfig_item_t *ci) /* {{{ */
{
  web_page_t *page;
  int status;
  int i;

  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
  {
    WARNING ("curl plugin: `Page' blocks need exactly one string argument.");
    return (-1);
  }

  page = calloc (1, sizeof (*page));
  if (page == NULL)
  {
    ERROR ("curl plugin: calloc failed.");
    return (-1);
  }
  page->url = NULL;
  page->user = NULL;
  page->pass = NULL;
  page->digest = 0;
  page->verify_peer = 1;
  page->verify_host = 1;
  page->response_time = 0;
  page->response_code = 0;
  page->timeout = -1;

  page->instance = strdup (ci->values[0].value.string);
  if (page->instance == NULL)
  {
    ERROR ("curl plugin: strdup failed.");
    sfree (page);
    return (-1);
  }

  /* Process all children */
  status = 0;
  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *child = ci->children + i;

    if (strcasecmp ("URL", child->key) == 0)
      status = cf_util_get_string (child, &page->url);
    else if (strcasecmp ("User", child->key) == 0)
      status = cf_util_get_string (child, &page->user);
    else if (strcasecmp ("Password", child->key) == 0)
      status = cf_util_get_string (child, &page->pass);
    else if (strcasecmp ("Digest", child->key) == 0)
      status = cf_util_get_boolean (child, &page->digest);
    else if (strcasecmp ("VerifyPeer", child->key) == 0)
      status = cf_util_get_boolean (child, &page->verify_peer);
    else if (strcasecmp ("VerifyHost", child->key) == 0)
      status = cf_util_get_boolean (child, &page->verify_host);
    else if (strcasecmp ("MeasureResponseTime", child->key) == 0)
      status = cf_util_get_boolean (child, &page->response_time);
    else if (strcasecmp ("MeasureResponseCode", child->key) == 0)
      status = cf_util_get_boolean (child, &page->response_code);
    else if (strcasecmp ("CACert", child->key) == 0)
      status = cf_util_get_string (child, &page->cacert);
    else if (strcasecmp ("Match", child->key) == 0)
      /* Be liberal with failing matches => don't set `status'. */
      cc_config_add_match (page, child);
    else if (strcasecmp ("Header", child->key) == 0)
      status = cc_config_append_string ("Header", &page->headers, child);
    else if (strcasecmp ("Post", child->key) == 0)
      status = cf_util_get_string (child, &page->post_body);
    else if (strcasecmp ("Timeout", child->key) == 0)
      status = cf_util_get_int (child, &page->timeout);
    else
    {
      WARNING ("curl plugin: Option `%s' not allowed here.", child->key);
      status = -1;
    }

    if (status != 0)
      break;
  } /* for (i = 0; i < ci->children_num; i++) */

  /* Additionial sanity checks and libCURL initialization. */
  while (status == 0)
  {
    if (page->url == NULL)
    {
      WARNING ("curl plugin: `URL' missing in `Page' block.");
      status = -1;
    }

    if (page->matches == NULL && !page->response_time && !page->response_code)
    {
      assert (page->instance != NULL);
      WARNING ("curl plugin: No (valid) `Match' block "
          "or MeasureResponseTime or MeasureResponseCode within "
          "`Page' block `%s'.", page->instance);
      status = -1;
    }

    if (status == 0)
      status = cc_page_init_curl (page);

//.........这里部分代码省略.........
开发者ID:NymbleTechnology,项目名称:collectd,代码行数:101,代码来源:curl.c


示例19: cj_config_add_url

static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */
{
    cj_t *db;
    int status = 0;
    int i;

    if ((ci->values_num != 1)
            || (ci->values[0].type != OCONFIG_TYPE_STRING))
    {
        WARNING ("curl_json plugin: The `URL' block "
                 "needs exactly one string argument.");
        return (-1);
    }

    db = (cj_t *) malloc (sizeof (*db));
    if (db == NULL)
    {
        ERROR ("curl_json plugin: malloc failed.");
        return (-1);
    }
    memset (db, 0, sizeof (*db));

    if (strcasecmp ("URL", ci->key) == 0)
        status = cf_util_get_string (ci, &db->url);
    else if (strcasecmp ("Sock", ci->key) == 0)
        status = cf_util_get_string (ci, &db->sock);
    else
    {
        ERROR ("curl_json plugin: cj_config: "
               &quo 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cf_util_get_string函数代码示例发布时间:2022-05-30
下一篇:
C++ cf_section_sub_find函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap