您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ssnprintf函数代码示例

51自学网 2021-06-03 08:20:07
  C++
这篇教程C++ ssnprintf函数代码示例写得很实用,希望能帮到您。

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

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

示例1: varnish_config_instance

//.........这里部分代码省略.........		else if (strcasecmp ("CollectPurge", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_purge);#else		else if (strcasecmp ("CollectBan", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_ban);#endif		else if (strcasecmp ("CollectSession", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_session);		else if (strcasecmp ("CollectSHM", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_shm);		else if (strcasecmp ("CollectSMS", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_sms);#if HAVE_VARNISH_V2		else if (strcasecmp ("CollectSMA", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_sma);		else if (strcasecmp ("CollectSM", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_sm);#endif		else if (strcasecmp ("CollectStruct", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_struct);		else if (strcasecmp ("CollectTotals", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_totals);#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4		else if (strcasecmp ("CollectUptime", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_uptime);#endif		else if (strcasecmp ("CollectVCL", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_vcl);		else if (strcasecmp ("CollectWorkers", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_workers);#if HAVE_VARNISH_V4		else if (strcasecmp ("CollectVSM", child->key) == 0)			cf_util_get_boolean (child, &conf->collect_vsm);#endif		else		{			WARNING ("Varnish plugin: Ignoring unknown "					"configuration option: /"%s/". Did "					"you forget to add an <Instance /> "					"block around the configuration?",					child->key);		}	}	if (!conf->collect_cache			&& !conf->collect_connections			&& !conf->collect_esi			&& !conf->collect_backend#ifdef HAVE_VARNISH_V3			&& !conf->collect_dirdns#endif			&& !conf->collect_fetch			&& !conf->collect_hcb			&& !conf->collect_objects#if HAVE_VARNISH_V2			&& !conf->collect_purge#else			&& !conf->collect_ban#endif			&& !conf->collect_session			&& !conf->collect_shm			&& !conf->collect_sms#if HAVE_VARNISH_V2			&& !conf->collect_sma			&& !conf->collect_sm#endif			&& !conf->collect_struct			&& !conf->collect_totals#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4			&& !conf->collect_uptime#endif			&& !conf->collect_vcl			&& !conf->collect_workers#if HAVE_VARNISH_V4			&& !conf->collect_vsm#endif	)	{		WARNING ("Varnish plugin: No metric has been configured for "				"instance /"%s/". Disabling this instance.",				(conf->instance == NULL) ? "localhost" : conf->instance);		return (EINVAL);	}	ssnprintf (callback_name, sizeof (callback_name), "varnish/%s",			(conf->instance == NULL) ? "localhost" : conf->instance);	ud.data = conf;	ud.free_func = varnish_config_free;	plugin_register_complex_read (/* group = */ "varnish",			/* name      = */ callback_name,			/* callback  = */ varnish_read,			/* interval  = */ 0,			/* user data = */ &ud);	have_instance = 1;	return (0);} /* }}} int varnish_config_instance */
开发者ID:QualityUnit,项目名称:collectd,代码行数:101,


示例2: gr_format_name

static int gr_format_name (char *ret, int ret_len,        value_list_t const *vl,        char const *ds_name,        char const *prefix,        char const *postfix,        char const escape_char,        unsigned int flags){    char n_host[DATA_MAX_NAME_LEN];    char n_plugin[DATA_MAX_NAME_LEN];    char n_plugin_instance[DATA_MAX_NAME_LEN];    char n_type[DATA_MAX_NAME_LEN];    char n_type_instance[DATA_MAX_NAME_LEN];    char tmp_plugin[2 * DATA_MAX_NAME_LEN + 1];    char tmp_type[2 * DATA_MAX_NAME_LEN + 1];    if (prefix == NULL)        prefix = "";    if (postfix == NULL)        postfix = "";    gr_copy_escape_part (n_host, vl->host,            sizeof (n_host), escape_char);    gr_copy_escape_part (n_plugin, vl->plugin,            sizeof (n_plugin), escape_char);    gr_copy_escape_part (n_plugin_instance, vl->plugin_instance,            sizeof (n_plugin_instance), escape_char);    gr_copy_escape_part (n_type, vl->type,            sizeof (n_type), escape_char);    gr_copy_escape_part (n_type_instance, vl->type_instance,            sizeof (n_type_instance), escape_char);    if (n_plugin_instance[0] != '/0')        ssnprintf (tmp_plugin, sizeof (tmp_plugin), "%s%c%s",            n_plugin,            (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',            n_plugin_instance);    else        sstrncpy (tmp_plugin, n_plugin, sizeof (tmp_plugin));    if (n_type_instance[0] != '/0')    {        if ((flags & GRAPHITE_DROP_DUPE_FIELDS) && strcmp(n_plugin, n_type) == 0)            sstrncpy (tmp_type, n_type_instance, sizeof (tmp_type));        else            ssnprintf (tmp_type, sizeof (tmp_type), "%s%c%s",                n_type,                (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',                n_type_instance);    }    else        sstrncpy (tmp_type, n_type, sizeof (tmp_type));    /* Assert always_append_ds -> ds_name */    assert (!(flags & GRAPHITE_ALWAYS_APPEND_DS) || (ds_name != NULL));    if (ds_name != NULL)    {        if ((flags & GRAPHITE_DROP_DUPE_FIELDS) && strcmp(tmp_plugin, tmp_type) == 0)            ssnprintf (ret, ret_len, "%s%s%s.%s.%s",                prefix, n_host, postfix, tmp_plugin, ds_name);        else            ssnprintf (ret, ret_len, "%s%s%s.%s.%s.%s",                prefix, n_host, postfix, tmp_plugin, tmp_type, ds_name);    }    else        ssnprintf (ret, ret_len, "%s%s%s.%s.%s",            prefix, n_host, postfix, tmp_plugin, tmp_type);    return (0);}
开发者ID:jconroy77,项目名称:collectd,代码行数:72,


示例3: config_add

static int config_add (oconfig_item_t *ci){	apache_t *st;	int i;	int status;	if ((ci->values_num != 1)		|| (ci->values[0].type != OCONFIG_TYPE_STRING))	{		WARNING ("apache plugin: The `%s' config option "			"needs exactly one string argument.", ci->key);		return (-1);	}	st = (apache_t *) malloc (sizeof (*st));	if (st == NULL)	{		ERROR ("apache plugin: malloc failed.");		return (-1);	}	memset (st, 0, sizeof (*st));	status = config_set_string (&st->name, ci);	if (status != 0)	{		sfree (st);		return (status);	}	assert (st->name != NULL);	for (i = 0; i < ci->children_num; i++)	{		oconfig_item_t *child = ci->children + i;		if (strcasecmp ("URL", child->key) == 0)			status = config_set_string (&st->url, child);		else if (strcasecmp ("Host", child->key) == 0)			status = config_set_string (&st->host, child);		else if (strcasecmp ("User", child->key) == 0)			status = config_set_string (&st->user, child);		else if (strcasecmp ("Password", child->key) == 0)			status = config_set_string (&st->pass, child);		else if (strcasecmp ("VerifyPeer", child->key) == 0)			status = config_set_boolean (&st->verify_peer, child);		else if (strcasecmp ("VerifyHost", child->key) == 0)			status = config_set_boolean (&st->verify_host, child);		else if (strcasecmp ("CACert", child->key) == 0)			status = config_set_string (&st->cacert, child);		else if (strcasecmp ("Server", child->key) == 0)			status = config_set_string (&st->server, child);		else		{			WARNING ("apache plugin: Option `%s' not allowed here.",					child->key);			status = -1;		}		if (status != 0)			break;	}	/* Check if struct is complete.. */	if ((status == 0) && (st->url == NULL))	{		ERROR ("apache plugin: Instance `%s': "				"No URL has been configured.",				st->name);		status = -1;	}	if (status == 0)	{		user_data_t ud;		char callback_name[3*DATA_MAX_NAME_LEN];		memset (&ud, 0, sizeof (ud));		ud.data = st;		ud.free_func = (void *) apache_free;		memset (callback_name, 0, sizeof (callback_name));		ssnprintf (callback_name, sizeof (callback_name),				"apache/%s/%s",				(st->host != NULL) ? st->host : hostname_g,				(st->name != NULL) ? st->name : "default"),		status = plugin_register_complex_read (/* group = */ NULL,				/* name      = */ callback_name,				/* callback  = */ apache_read_host,				/* interval  = */ NULL,				/* user_data = */ &ud);	}	if (status != 0)	{		apache_free(st);		return (-1);	}	return (0);//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:collectd,代码行数:101,


示例4: switch

void CFieldPrinter::PrintField(_nbExtractedFieldsDescriptor &FieldDescriptor, _nbExtractFieldInfo &FieldInfo, _nbExtractFieldInfo AllFieldsInfo[], int FieldNumber, const unsigned char *PktData){_nbExtractedFieldsDescriptor *FieldsDescriptorVector= FieldDescriptor.DVct;int RetVal;	switch (FieldInfo.FieldType)	{	case PDL_FIELD_TYPE_ALLFIELDS:		{			if (FieldDescriptor.Valid)			{				for (int i=0; i < FieldDescriptor.num_entries; i++)					PrintField(FieldsDescriptorVector[i], AllFieldsInfo[i], AllFieldsInfo, FieldNumber, PktData);			}		};		break;	case PDL_FIELD_TYPE_BIT:		{			if (FieldDescriptor.Valid)			{				if (FieldsDescriptorVector != NULL)				{					for (int i=0; i < FieldDescriptor.num_entries; i++)						PrintField(FieldsDescriptorVector[i], FieldInfo, AllFieldsInfo, FieldNumber, PktData);					return;				}				switch (m_PrintingMode)				{					case DEFAULT:						fprintf(m_OutputFile, "/t%s.%s : value=%u/n", FieldInfo.Proto, FieldInfo.Name, (unsigned int) FieldDescriptor.BitField_Value);						break;#ifdef ENABLE_REDIS					case REDIS:						ssnprintf(m_FormattedField, sizeof(m_FormattedField), "%u, ", (unsigned int) FieldDescriptor.BitField_Value);						break;#endif#ifdef ENABLE_SQLITE3					case SQLITE3:						ssnprintf(m_FormattedField, sizeof(m_FormattedField), "%u, ", (unsigned int) FieldDescriptor.BitField_Value);						break;#endif					default:						fprintf(m_OutputFile, "%u, ", (unsigned int) FieldDescriptor.BitField_Value);						break;				}			}			else			{				switch (m_PrintingMode)				{					case DEFAULT:						fprintf(m_OutputFile, "/t%s.%s : value=*/n", FieldInfo.Proto, FieldInfo.Name);						break;#ifdef ENABLE_REDIS					case REDIS:						ssnprintf(m_FormattedField, sizeof(m_FormattedField), "-");						break;#endif#ifdef ENABLE_SQLITE3					case SQLITE3:						ssnprintf(m_FormattedField, sizeof(m_FormattedField), "-");						break;#endif					default:						fprintf(m_OutputFile, " , ");						break;				}			}		};		break;	default:		{			if (FieldDescriptor.Valid)			{				if (FieldsDescriptorVector != NULL)				{					for (int i=0; i < FieldDescriptor.num_entries; i++)						PrintField(FieldsDescriptorVector[i], FieldInfo, AllFieldsInfo, FieldNumber, PktData);					return;				}				if (FieldDescriptor.Length > MAX_FIELD_SIZE)				{					fprintf(stderr, "The size of field '%s' is larger than the max value allowed in this program. ",FieldInfo.Name);					fprintf(stderr, "Max allowed: %d - Current: %d/n", MAX_FIELD_SIZE, FieldDescriptor.Length);					return;				}#ifdef PROFILING				int64_t StartTime, EndTime;				StartTime= nbProfilerGetTime();#endif				// Here we use the 'UserExtension' member in order to store the 'fast printing' function code, if available.				if (FieldDescriptor.UserExtension)//.........这里部分代码省略.........
开发者ID:jjones646,项目名称:netbee,代码行数:101,


示例5: camqp_config_connection

//.........这里部分代码省略.........            status = cf_util_get_boolean (child, &conf->queue_auto_delete);        else if (strcasecmp ("RoutingKey", child->key) == 0)            status = cf_util_get_string (child, &conf->routing_key);        else if ((strcasecmp ("Persistent", child->key) == 0) && publish)        {            _Bool tmp = 0;            status = cf_util_get_boolean (child, &tmp);            if (tmp)                conf->delivery_mode = CAMQP_DM_PERSISTENT;            else                conf->delivery_mode = CAMQP_DM_VOLATILE;        }        else if ((strcasecmp ("StoreRates", child->key) == 0) && publish)        {            status = cf_util_get_boolean (child, &conf->store_rates);            (void) cf_util_get_flag (child, &conf->graphite_flags,                    GRAPHITE_STORE_RATES);        }        else if ((strcasecmp ("Format", child->key) == 0) && publish)            status = camqp_config_set_format (child, conf);        else if ((strcasecmp ("GraphiteSeparateInstances", child->key) == 0) && publish)            status = cf_util_get_flag (child, &conf->graphite_flags,                    GRAPHITE_SEPARATE_INSTANCES);        else if ((strcasecmp ("GraphiteAlwaysAppendDS", child->key) == 0) && publish)            status = cf_util_get_flag (child, &conf->graphite_flags,                    GRAPHITE_ALWAYS_APPEND_DS);        else if ((strcasecmp ("GraphitePrefix", child->key) == 0) && publish)            status = cf_util_get_string (child, &conf->prefix);        else if ((strcasecmp ("GraphitePostfix", child->key) == 0) && publish)            status = cf_util_get_string (child, &conf->postfix);        else if ((strcasecmp ("GraphiteEscapeChar", child->key) == 0) && publish)        {            char *tmp_buff = NULL;            status = cf_util_get_string (child, &tmp_buff);            if (strlen (tmp_buff) > 1)                WARNING ("amqp plugin: The option /"GraphiteEscapeChar/" handles "                        "only one character. Others will be ignored.");            conf->escape_char = tmp_buff[0];            sfree (tmp_buff);        }        else if (strcasecmp ("ConnectionRetryDelay", child->key) == 0)            status = cf_util_get_int (child, &conf->connection_retry_delay);        else            WARNING ("amqp plugin: Ignoring unknown "                    "configuration option /"%s/".", child->key);        if (status != 0)            break;    } /* for (i = 0; i < ci->children_num; i++) */    if ((status == 0) && (conf->exchange == NULL))    {        if (conf->exchange_type != NULL)            WARNING ("amqp plugin: The option /"ExchangeType/" was given "                    "without the /"Exchange/" option. It will be ignored.");        if (!publish && (conf->routing_key != NULL))            WARNING ("amqp plugin: The option /"RoutingKey/" was given "                    "without the /"Exchange/" option. It will be ignored.");    }    if (status != 0)    {        camqp_config_free (conf);        return (status);    }    if (conf->exchange != NULL)    {        DEBUG ("amqp plugin: camqp_config_connection: exchange = %s;",                conf->exchange);    }    if (publish)    {        char cbname[128];        user_data_t ud = { conf, camqp_config_free };        ssnprintf (cbname, sizeof (cbname), "amqp/%s", conf->name);        status = plugin_register_write (cbname, camqp_write, &ud);        if (status != 0)        {            camqp_config_free (conf);            return (status);        }    }    else    {        status = camqp_subscribe_init (conf);        if (status != 0)        {            camqp_config_free (conf);            return (status);        }    }    return (0);} /* }}} int camqp_config_connection */
开发者ID:Mindera,项目名称:collectd,代码行数:101,


示例6: cx_handle_instance_xpath

static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */    cx_xpath_t *xpath, value_list_t *vl,    _Bool is_table){  xmlXPathObjectPtr instance_node_obj = NULL;  xmlNodeSetPtr instance_node = NULL;  memset (vl->type_instance, 0, sizeof (vl->type_instance));  /* If the base xpath returns more than one block, the result is assumed to be   * a table. The `Instance' option is not optional in this case. Check for the   * condition and inform the user. */  if (is_table && (xpath->instance == NULL))  {    WARNING ("curl_xml plugin: "        "Base-XPath %s is a table (more than one result was returned), "        "but no instance-XPath has been defined.",        xpath->path);    return (-1);  }  /* instance has to be an xpath expression */  if (xpath->instance != NULL)  {    int tmp_size;    instance_node_obj = cx_evaluate_xpath (xpath_ctx, BAD_CAST xpath->instance);    if (instance_node_obj == NULL)      return (-1); /* error is logged already */    instance_node = instance_node_obj->nodesetval;    tmp_size = (instance_node) ? instance_node->nodeNr : 0;    if (tmp_size <= 0)    {      WARNING ("curl_xml plugin: "          "relative xpath expression for 'InstanceFrom' /"%s/" doesn't match "          "any of the nodes. Skipping the node.", xpath->instance);      xmlXPathFreeObject (instance_node_obj);      return (-1);    }    if (tmp_size > 1)    {      WARNING ("curl_xml plugin: "          "relative xpath expression for 'InstanceFrom' /"%s/" is expected "          "to return only one text node. Skipping the node.", xpath->instance);      xmlXPathFreeObject (instance_node_obj);      return (-1);    }    /* ignoring the element if other than textnode/attribute */    if (cx_if_not_text_node(instance_node->nodeTab[0]))    {      WARNING ("curl_xml plugin: "          "relative xpath expression /"%s/" is expected to return only text node "          "which is not the case. Skipping the node.", xpath->instance);      xmlXPathFreeObject (instance_node_obj);      return (-1);    }  } /* if (xpath->instance != NULL) */  if (xpath->instance_prefix != NULL)  {    if (instance_node != NULL)    {      char *node_value = (char *) xmlNodeGetContent(instance_node->nodeTab[0]);      ssnprintf (vl->type_instance, sizeof (vl->type_instance),"%s%s",          xpath->instance_prefix, node_value);      sfree (node_value);    }    else      sstrncpy (vl->type_instance, xpath->instance_prefix,          sizeof (vl->type_instance));  }  else  {    /* If instance_prefix and instance_node are NULL, then     * don't set the type_instance */    if (instance_node != NULL)    {      char *node_value = (char *) xmlNodeGetContent(instance_node->nodeTab[0]);      sstrncpy (vl->type_instance, node_value, sizeof (vl->type_instance));      sfree (node_value);    }  }  /* Free `instance_node_obj' this late, because `instance_node' points to   * somewhere inside this structure. */  xmlXPathFreeObject (instance_node_obj);  return (0);} /* }}} int cx_handle_instance_xpath */
开发者ID:Mindera,项目名称:collectd,代码行数:93,


示例7: kafka_config_topic

//.........这里部分代码省略.........            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);    rd_kafka_topic_conf_set_opaque(tctx->conf, tctx);    if ((tctx->topic = rd_kafka_topic_new(tctx->kafka, tctx->topic_name,                                       tctx->conf)) == NULL) {        ERROR("write_kafka plugin: cannot create topic.");        goto errout;    }    tctx->conf = NULL;    ssnprintf(callback_name, sizeof(callback_name),              "write_kafka/%s", tctx->topic_name);    ud.data = tctx;    ud.free_func = kafka_topic_context_free;	status = plugin_register_write (callback_name, kafka_write, &ud);	if (status != 0) {		WARNING ("write_kafka plugin: plugin_register_write (/"%s/") "				"failed with status %i.",				callback_name, status);        goto errout;    }    return; errout:    if (conf != NULL)        rd_kafka_conf_destroy(conf);    if (tctx->kafka != NULL)        rd_kafka_destroy(tctx->kafka);    if (tctx->topic != NULL)        rd_kafka_topic_destroy(tctx->topic);    if (tctx->topic_name != NULL)        free(tctx->topic_name);    if (tctx->conf != NULL)        rd_kafka_topic_conf_destroy(tctx->conf);    sfree(tctx);} /* }}} int kafka_config_topic */
开发者ID:adanin,项目名称:collectd,代码行数:101,


示例8: uc_send_notification

static int uc_send_notification (const char *name){  cache_entry_t *ce = NULL;  int status;  char *name_copy;  char *host;  char *plugin;  char *plugin_instance;  char *type;  char *type_instance;  notification_t n;  name_copy = strdup (name);  if (name_copy == NULL)  {    ERROR ("uc_send_notification: strdup failed.");    return (-1);  }  status = parse_identifier (name_copy, &host,      &plugin, &plugin_instance,      &type, &type_instance);  if (status != 0)  {    ERROR ("uc_send_notification: Cannot parse name `%s'", name);    return (-1);  }  /* Copy the associative members */  notification_init (&n, NOTIF_FAILURE, /* host = */ NULL,      host, plugin, plugin_instance, type, type_instance);  sfree (name_copy);  name_copy = host = plugin = plugin_instance = type = type_instance = NULL;  pthread_mutex_lock (&cache_lock);  /*   * Set the time _after_ getting the lock because we don't know how long   * acquiring the lock takes and we will use this time later to decide   * whether or not the state is OKAY.   */  n.time = time (NULL);  status = c_avl_get (cache_tree, name, (void *) &ce);  if (status != 0)  {    pthread_mutex_unlock (&cache_lock);    sfree (name_copy);    return (-1);  }      /* Check if the entry has been updated in the meantime */  if ((n.time - ce->last_update) < (2 * ce->interval))  {    ce->state = STATE_OKAY;    pthread_mutex_unlock (&cache_lock);    sfree (name_copy);    return (-1);  }  ssnprintf (n.message, sizeof (n.message),      "%s has not been updated for %i seconds.", name,      (int) (n.time - ce->last_update));  pthread_mutex_unlock (&cache_lock);  plugin_dispatch_notification (&n);  return (0);} /* int uc_send_notification */
开发者ID:tabletcorry,项目名称:collectd,代码行数:73,


示例9: uc_update

//.........这里部分代码省略.........	  {	    if (ce->values_raw[i].counter <= 4294967295U)	      diff = (4294967295U - ce->values_raw[i].counter)		+ vl->values[i].counter;	    else	      diff = (18446744073709551615ULL - ce->values_raw[i].counter)		+ vl->values[i].counter;	  }	  else /* counter has NOT wrapped around */	  {	    diff = vl->values[i].counter - ce->values_raw[i].counter;	  }	  ce->values_gauge[i] = ((double) diff)	    / ((double) (vl->time - ce->last_time));	  ce->values_raw[i].counter = vl->values[i].counter;	}	break;      case DS_TYPE_GAUGE:	ce->values_raw[i].gauge = vl->values[i].gauge;	ce->values_gauge[i] = vl->values[i].gauge;	break;      case DS_TYPE_DERIVE:	{	  derive_t diff;	  diff = vl->values[i].derive - ce->values_raw[i].derive;	  ce->values_gauge[i] = ((double) diff)	    / ((double) (vl->time - ce->last_time));	  ce->values_raw[i].derive = vl->values[i].derive;	}	break;      case DS_TYPE_ABSOLUTE:	ce->values_gauge[i] = ((double) vl->values[i].absolute)	  / ((double) (vl->time - ce->last_time));	ce->values_raw[i].absolute = vl->values[i].absolute;	break;      default:	/* This shouldn't happen. */	pthread_mutex_unlock (&cache_lock);	ERROR ("uc_update: Don't know how to handle data source type %i.",	    ds->ds[i].type);	return (-1);    } /* switch (ds->ds[i].type) */    DEBUG ("uc_update: %s: ds[%i] = %lf", name, i, ce->values_gauge[i]);  } /* for (i) */  /* Update the history if it exists. */  if (ce->history != NULL)  {    assert (ce->history_index < ce->history_length);    for (i = 0; i < ce->values_num; i++)    {      size_t hist_idx = (ce->values_num * ce->history_index) + i;      ce->history[hist_idx] = ce->values_gauge[i];    }    assert (ce->history_length > 0);    ce->history_index = (ce->history_index + 1) % ce->history_length;  }  /* Prune invalid gauge data */  uc_check_range (ds, ce);  ce->last_time = vl->time;  ce->last_update = time (NULL);  ce->interval = vl->interval;  pthread_mutex_unlock (&cache_lock);  if (send_okay_notification == 0)    return (0);  /* Do not send okay notifications for uninteresting values, i. e. values for   * which no threshold is configured. */  status = ut_check_interesting (name);  if (status <= 0)    return (0);  /* Initialize the notification */  memset (&n, '/0', sizeof (n));  NOTIFICATION_INIT_VL (&n, vl, ds);  n.severity = NOTIF_OKAY;  n.time = vl->time;  ssnprintf (n.message, sizeof (n.message),      "Received a value for %s. It was missing for %u seconds.",      name, (unsigned int) update_delay);  plugin_dispatch_notification (&n);  return (0);} /* int uc_update */
开发者ID:tabletcorry,项目名称:collectd,代码行数:101,


示例10: notify_email_notification

static int notify_email_notification (const notification_t *n){  smtp_recipient_t recipient;  struct tm timestamp_tm;  char timestamp_str[64];  char severity[32];  char subject[MAXSTRING];  char buf[4096] = "";  int  buf_len = sizeof (buf);  int i;  ssnprintf (severity, sizeof (severity), "%s",      (n->severity == NOTIF_FAILURE) ? "FAILURE"      : ((n->severity == NOTIF_WARNING) ? "WARNING"        : ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN")));  ssnprintf (subject, sizeof (subject),      (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject,      severity, n->host);  localtime_r (&n->time, &timestamp_tm);  strftime (timestamp_str, sizeof (timestamp_str), "%Y-%m-%d %H:%M:%S",      &timestamp_tm);  timestamp_str[sizeof (timestamp_str) - 1] = '/0';  /* Let's make RFC822 message text with /r/n EOLs */  ssnprintf (buf, buf_len,      "MIME-Version: 1.0/r/n"      "Content-Type: text/plain;/r/n"      "Content-Transfer-Encoding: 8bit/r/n"      "Subject: %s/r/n"      "/r/n"      "%s - %[email
C++ ssp_dbg函数代码示例
C++ ssl_write函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。