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

C++ rrd_get_error函数代码示例

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

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



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

示例1: malloc

char     *printtimelast(
    long argc,
    const char **args)
{
    time_t    last;
    struct tm tm_last;
    char     *buf;

    if (argc == 2) {
        buf = malloc(255);
        if (buf == NULL) {
            return stralloc("[ERROR: allocating strftime buffer]");
        };
        /* not raising argc in step with args - 1 since the last argument
           will be used below for strftime  */

        last = rrd_last(argc, (char **) args - 1);
        if (rrd_test_error()) {
            const size_t len = strlen(rrd_get_error()) + DS_NAM_SIZE;
            char *err = malloc(len);
            snprintf(err, len, "[ERROR: %s]", rrd_get_error());
            rrd_clear_error();
            return err;
        }
        tm_last = *localtime(&last);
        strftime(buf, 254, args[1], &tm_last);
        return buf;
    }
    return stralloc("[ERROR: expected <RRD::TIME::LAST file.rrd strftime-format>]");
}
开发者ID:Distrotech,项目名称:rrdtool,代码行数:30,代码来源:rrd_cgi.c


示例2: printtimelast

char* printtimelast(long argc, const char **args) {
  time_t last;
  struct tm tm_last;
  char *buf;
  if ( argc == 2 ) {
    buf = malloc(255);
    if (buf == NULL){	
	return stralloc("[ERROR: allocating strftime buffer]");
    };
    last = rrd_last(argc+1, (char **) args-1); 
    if (rrd_test_error()) {
      char *err = malloc((strlen(rrd_get_error())+DS_NAM_SIZE)*sizeof(char));
      sprintf(err, "[ERROR: %s]",rrd_get_error());
      rrd_clear_error();
      return err;
    }
    tm_last = *localtime(&last);
    strftime(buf,254,args[1],&tm_last);
    return buf;
  }
  if ( argc < 2 ) {
    return stralloc("[ERROR: too few arguments for RRD::TIME::LAST]");
  }
  return stralloc("[ERROR: not enough arguments for RRD::TIME::LAST]");
}
开发者ID:nickmbailey,项目名称:python26-rrdtool-rpm,代码行数:25,代码来源:rrd_cgi.c


示例3: calfree

char     *drawgraph(
    long argc,
    const char **args)
{
    int       i, xsize, ysize;
    double    ymin, ymax;

    for (i = 0; i < argc; i++)
        if (strcmp(args[i], "--imginfo") == 0 || strcmp(args[i], "-g") == 0)
            break;
    if (i == argc) {
        args[argc++] = "--imginfo";
        args[argc++] = "<IMG SRC=\"./%s\" WIDTH=\"%lu\" HEIGHT=\"%lu\">";
    }
    calfree();
    if (rrd_graph
        (argc + 1, (char **) args - 1, &calcpr, &xsize, &ysize, NULL, &ymin,
         &ymax) != -1) {
        return stralloc(calcpr[0]);
    } else {
        if (rrd_test_error()) {
            const size_t len = strlen(rrd_get_error()) + DS_NAM_SIZE;
            char *err = malloc(len);
            snprintf(err, len, "[ERROR: %s]", rrd_get_error());
            rrd_clear_error();
            return err;
        }
    }
    return NULL;
}
开发者ID:Distrotech,项目名称:rrdtool,代码行数:30,代码来源:rrd_cgi.c


示例4: create_rrd

int create_rrd(char* file)
{
	struct stat st;
	if (file)
	{
		
		if (stat(file, &st))
		{   /* stats fails*/
			if (errno != ENOENT)
			{ /* error occurred */
				perror(file);
				return -1;
			}
		}
    /*  file exists  */
		create_args[3] = file;
		if (rrd_create(CREATE_ARGS, create_args))
		{
			fprintf(stderr, "unable to create file: %s\n", file);
			fprintf(stderr, "%s\n", rrd_get_error());
			rrd_clear_error();
			return -1;
		}
		printf("file %s created\n", file);
	}
	return 0;
}
开发者ID:pepito987,项目名称:sgr,代码行数:27,代码来源:rrdstats.c


示例5: update_rrd

int update_rrd(char* file, long int last_up, data_t* dt)
{
	if ( dt )
	{
		char data[256];
		update_params[1] = file;
		sprintf(data, "%ld:%u:%u:%u:%u:%u:%u",
				last_up,
				dt->bytes,
				dt->ip_v4_bytes,
				dt->not_ip_bytes,
				dt->tcp_bytes,
				dt->udp_bytes,
				dt->other_bytes);
		update_params[2] = data;
		if (rrd_update(3, update_params))
		{
			fprintf(stderr, "rrd update failed: %s\n", rrd_get_error());
			rrd_clear_error();
		}
		else
				printf("%s updated!\n", file);
		bzero(dt, sizeof(data_t));
	}
	else
	    fprintf(stderr, "\nerror\n");
	return 0;
}
开发者ID:pepito987,项目名称:sgr,代码行数:28,代码来源:rrdstats.c


示例6: rrd_common_call

static int rrd_common_call (lua_State *L, const char *cmd,
			    RRD_FUNCTION rrd_function) {
  char **argv;
  int argc = lua_gettop(L) + 1;

  if(ntop->getGlobals()->isShutdown()) return(CONST_LUA_PARAM_ERROR);

  ntop->rrdLock(__FILE__, __LINE__);
  rrd_clear_error();
  argv = make_argv(cmd, L);
  reset_rrd_state();
  rrd_function(argc, argv);
  free(argv);
  if(rrd_test_error()) {
    char *err =  rrd_get_error();

    if(err != NULL) {
      /*
	IMPORTANT

	It is important to unlock now as if luaL_error is called the
	function returns and no unlock will take place
      */
      ntop->rrdUnlock(__FILE__, __LINE__);
      luaL_error(L, err);
    }
  }

  ntop->rrdUnlock(__FILE__, __LINE__);

  return 0;
}
开发者ID:ctcble,项目名称:ntopng,代码行数:32,代码来源:Lua.cpp


示例7: temperhum_rrd_update

void temperhum_rrd_update(char *fname, time_t tv_sec, struct sht1x_readings readings) {
	char update[4096];
	char buf[512];
	const char *args[1];

	args[0] = update;
	snprintf(update, 4096, "%llu", (unsigned long long)tv_sec);

	if (isnan(readings.temperature_celsius))
		strcat(update, ":U");
	else {
		snprintf(buf, 512, ":%.2f", readings.temperature_celsius);
		strcat(update, buf);
	}

	if (isnan(readings.relative_humidity))
		strcat(update, ":U");
	else {
		snprintf(buf, 512, ":%.2f", readings.relative_humidity);
		strcat(update, buf);
	}

	if (isnan(readings.dew_point))
		strcat(update, ":U");
	else {
		snprintf(buf, 512, ":%.2f", readings.dew_point);
		strcat(update, buf);
	}

	rrd_clear_error();
	if (rrd_update_r(fname, "tc:rh:dp", 1, args) != 0)
		fprintf(stderr, "%s: (%s) %s\n", fname, args[0], rrd_get_error());
}
开发者ID:alex-w,项目名称:temperhum,代码行数:33,代码来源:temperhum.c


示例8: rrdtool_create_command

void
rrdtool_create_command (const char *name, const char *what)
{
  // rrd_create needs the time of the first entry, so it
  // called at the time of the first update; therefore, we
  // need to backup the original rrd entry -- in order not 
  // overwrite the update command contained in rrd.cmd  
  rrd_struct temp_rrd = rrd;

  if (RRD_DEBUG)
    fprintf (fp_stderr, "rrdtool: create(%s,%s)\n", name, what);
#ifdef RRD_TREE
  sprintf (temp_rrd.file, "%s/%s", rrd.conf.path, name, what);
  struct stat fbuf;
  if (!((stat (temp_rrd.file, &fbuf) == 0) && S_ISDIR (fbuf.st_mode)))
    {
      mkdir (temp_rrd.file, 0775);
      if (debug > 1)
	fprintf (fp_stderr, "RRDtool database path <%s> created\n",
		 temp_rrd.file);
    }
  sprintf (temp_rrd.file, "%s/%s/%s.rrd", rrd.conf.path, name, what);
#else
  sprintf (temp_rrd.file, "%s/%s.%s.rrd", rrd.conf.path, name, what);
#endif

  rrd.time_update = (unsigned long) current_time.tv_sec;

  if (stat (temp_rrd.file, &temp_rrd.fbuf) == 0)
    {
      if (debug > 1)
	fprintf (fp_stderr, "rrdtool: skip create <%s> ... already existent\n",
		 temp_rrd.file);
      return;			/* already called ? */
    }


  /* MTRG-like behavior for on-line usage */
  sprintf (temp_rrd.cmd,
        "create %s --step %lu --start %ld DS:%s:GAUGE:%lu:U:U %s %s %s %s",
        temp_rrd.file, (unsigned long) (GLOBALS.Max_Time_Step / 1000000),
        (long) rrd.time_update - 10, name, (unsigned long) (GLOBALS.Max_Time_Step / 500000),
	   RRA_DAILY, RRA_WEEKLY, RRA_MONTHLY, RRA_YEARLY);
  if (debug > 1)
    fprintf (fp_stderr, "rrdtool: rrd_create('%s')\n", temp_rrd.cmd);

  optind = 0;
  opterr = 0;
  rrdtool_str2argv (temp_rrd.cmd);
  rrd_create (rrd.argc, rrd.argv);

  if (rrd_test_error ())
    {
      fprintf (fp_stderr, "rrdtool: create command:\n%s\n", temp_rrd.cmd);
      fprintf (fp_stderr, "rrdtool: create error!\n%s\n", rrd_get_error ());
      if (temp_rrd.fatal)
	exit (1);
      rrd_clear_error ();
    }
}
开发者ID:paivaspol,项目名称:tstat,代码行数:60,代码来源:rrd.c


示例9: RRD_update

static int
RRD_update( char *rrd, const char *sum, const char *num, unsigned int process_time )
{
    char *argv[3];
    int   argc = 3;
    char val[128];

    /* If we are a host RRD, we "sum" over only one host. */
    if (num)
        sprintf(val, "%d:%s:%s", process_time, sum, num);
    else
        sprintf(val, "%d:%s", process_time, sum);

    argv[0] = "dummy";
    argv[1] = rrd;
    argv[2] = val;

    pthread_mutex_lock( &rrd_mutex );
    optind=0;
    opterr=0;
    rrd_clear_error();
    rrd_update(argc, argv);
    if(rrd_test_error())
    {
        err_msg("RRD_update (%s): %s", rrd, rrd_get_error());
        pthread_mutex_unlock( &rrd_mutex );
        return 0;
    }
    /* debug_msg("Updated rrd %s with value %s", rrd, val); */
    pthread_mutex_unlock( &rrd_mutex );
    return 0;
}
开发者ID:yhsong-linux,项目名称:ganglia,代码行数:32,代码来源:rrd_helpers.c


示例10: stats_update

/**
 * \brief Update RRD stats file
 *
 * \param[in] stats Stats data
 * \param[in] templ RRD template
 */
void stats_update(stats_data *stats, std::string templ)
{
	std::vector<std::string> argv;

	/* Set RRD file */
	argv.push_back("update");
	argv.push_back(stats->file);

	/* Set template */
	argv.push_back("--template");
	argv.push_back(templ);

	/* Add counters */
	argv.push_back(stats_counters_to_string(stats->last, stats->fields));

	/* Create C style argv */
	const char **c_argv = new const char*[argv.size()];
	for (u_int16_t i = 0; i < argv.size(); ++i) {
		c_argv[i] = argv[i].c_str();
	}

	/* Update database */
	if (rrd_update(argv.size(), (char **) c_argv)) {
		MSG_ERROR(msg_module, "RRD Insert Error: %s", rrd_get_error());
		rrd_clear_error();
	}

	delete c_argv;
}
开发者ID:VisBlank,项目名称:ipfixcol,代码行数:35,代码来源:stats.cpp


示例11: srrd_create

static int srrd_create(const char *filename, /* {{{ */
                       unsigned long pdp_step, time_t last_up, int argc,
                       const char **argv) {
  int status;
  char *filename_copy;

  if ((filename == NULL) || (argv == NULL))
    return -EINVAL;

  /* Some versions of librrd don't have the `const' qualifier for the first
   * argument, so we have to copy the pointer here to avoid warnings. It sucks,
   * but what else can we do? :(  -octo */
  filename_copy = strdup(filename);
  if (filename_copy == NULL) {
    ERROR("srrd_create: strdup failed.");
    return -ENOMEM;
  }

  optind = 0; /* bug in librrd? */
  rrd_clear_error();

  status = rrd_create_r(filename_copy, pdp_step, last_up, argc, (void *)argv);

  if (status != 0) {
    P_WARNING("srrd_create: rrd_create_r (%s) failed: %s", filename,
              rrd_get_error());
  }

  sfree(filename_copy);

  return status;
} /* }}} int srrd_create */
开发者ID:BrandonArp,项目名称:collectd,代码行数:32,代码来源:utils_rrdcreate.c


示例12: sprintf

/** 
 * @brief  创建RRD数据库
 * @param   rrd_file     rrd数据库路径
 * @param   summary 标志位是否summary
 * @param   step    步长
 * @return  成功返回0,失败返回-1
 */
int c_rrd_handler::RRD_create(const char *rrd_file, bool summary, unsigned int step)
{
    /* Warning: RRD_create will overwrite a RRD if it already exists */
    int  argc = 0;
    const char *argv[128] = {NULL};
    const char *data_source_type = "GAUGE";
    int  heartbeat = 30;
    char sstep[16] = {'\0'};
    char sstart[64] = {'\0'};
    char ssum[64] = {'\0'};
    char snum[64] = {'\0'};

    /* Our heartbeat is twice the step interval. */
    heartbeat = 2 * step;


    argv[argc++] = "dummy";
    argv[argc++] = rrd_file;
    argv[argc++] = "--step";
    sprintf(sstep, "%u", step);
    argv[argc++] = sstep;
    argv[argc++] = "--start";
    sprintf(sstart, "%lu", time(NULL) - 1);
    argv[argc++] = sstart;
    sprintf(ssum, "DS:sum:%s:%d:U:U", data_source_type, heartbeat);
    argv[argc++] = ssum;

    if(summary)
    {
        sprintf(snum, "DS:num:%s:%d:U:U", data_source_type, heartbeat);
        argv[argc++] = snum;
    }

    if (g_is_switch_rrd)
    {
        GEN_SWITCH_RRA(argc, argv);
    }
    else
    {
        GEN_SERVER_RRA(argc, argv);
    }

    optind = 0;
    optopt = 0;
    opterr = 0;
    optarg = NULL;
    rrd_clear_error();

    rrd_create(argc, (char**)argv);

    if(rrd_test_error())
    {
        ERROR_LOG("RRD_create error: %s", rrd_get_error());
        return -1;
    }

    DEBUG_LOG("CREATE RRD[%s]", rrd_file);
    return 0;
}
开发者ID:Zhanyin,项目名称:taomee,代码行数:66,代码来源:c_rrd_handler.cpp


示例13: throwException

JNIEXPORT jobject JNICALL Java_gnu_rrd_RRDJNI_graph
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char        **argv2;
  char        **calcpr;
  char*       info;
  const char* fn;
  int         asize = 0;
  int         i, j, xsize,  ysize;
  double      ymin, ymax;
  jcharArray  graph;
  jclass      RRDGraphClass;
  jmethodID   RRDGraphMethodInit;
  jmethodID   RRDGraphMethodSetElement;
  jobject     graphObj = NULL;
  jobject     o;

  o  = (*env)->GetObjectArrayElement(env, argv, 0);  
  fn = (*env)->GetStringUTFChars(env, (jstring)o, NULL);
  if (strcmp(fn,"-")==0) {
    throwException(env, "gnu/rrd/RRDException", "output to stdout is not supported.");
    return;
  }
  
  RRDGraphClass      = (*env)->FindClass(env, "gnu/rrd/RRDGraph");
  RRDGraphMethodInit = (*env)->GetMethodID(env, RRDGraphClass, "<init>",
					   "(Ljava/lang/String;Ljava/lang/String;IIDD)V");
    
  calcpr = NULL;
  argv2  = initArgs(env, argv, "graph");
  if (rrd_graph((*env)->GetArrayLength(env, argv)+1, argv2, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax) != -1 ) {
    
    if (calcpr) {
      for(i = 0; calcpr[i]; i++) asize = asize + strlen(calcpr[i]) + 1;
      if((info = (char*)malloc(asize+1))==NULL) {
	throwException(env, "gnu/rrd/RRDException", "unable to allocate memory for graph information.");
	freeArgs(env, argv, argv2);
	free(calcpr);
        return;
      } else {
	for(i = 0; calcpr[i]; i++){
	  if (i>0) info = strcat(strcat(info, "\n"), calcpr[i]);
	  else     info = strcat(info, calcpr[i]);
          free(calcpr[i]);
        } 
      }
      free(calcpr);
    }
    graphObj = (*env)->NewObject(env, RRDGraphClass, RRDGraphMethodInit,
				 (jstring)(*env)->GetObjectArrayElement(env, argv, 0),
				 (jstring)(*env)->NewStringUTF(env, info),
				 (jint)xsize, (jint)ysize, (jdouble)ymin, (jdouble)ymax);
  }
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());

  return graphObj;
}
开发者ID:caseylucas,项目名称:rrdtool-java,代码行数:58,代码来源:RRDJNI.c


示例14: rrd_error

static void rrd_error(char* fun){
  dfsch_object_t* c = dfsch_make_condition(RRD_ERROR_TYPE);
  dfsch_condition_put_field_cstr(c, "message", 
                                 dfsch_make_string_cstr(rrd_get_error()));
  dfsch_condition_put_field_cstr(c, "function", 
                                 dfsch_make_string_cstr(fun));  
  pthread_mutex_unlock(&rrd_lock);
  dfsch_signal(c);
}
开发者ID:adh,项目名称:dfsch,代码行数:9,代码来源:rrd_mod.c


示例15: initArgs

JNIEXPORT void JNICALL Java_gnu_rrd_RRDJNI_dump
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char **argv2;
    
  argv2 = initArgs(env, argv, "dump");
  rrd_dump((*env)->GetArrayLength(env, argv)+1, argv2);
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());
}
开发者ID:caseylucas,项目名称:rrdtool-java,代码行数:10,代码来源:RRDJNI.c


示例16: includefile

char* includefile(long argc, const char **args){
  char *buffer;
  if (argc >= 1) {
      const char* filename = args[0];
      readfile(filename, &buffer, 0);
      if (rrd_test_error()) {
	  	char *err = malloc((strlen(rrd_get_error())+DS_NAM_SIZE));
	  sprintf(err, "[ERROR: %s]",rrd_get_error());
	  rrd_clear_error();
	  return err;
      } else {
       return buffer;
      }
  }
  else
  {
      return stralloc("[ERROR: No Inclue file defined]");
  }
}
开发者ID:nickmbailey,项目名称:python26-rrdtool-rpm,代码行数:19,代码来源:rrd_cgi.c


示例17: ngx_http_rrd_show_graph

/*
 *  Handles the GET requests by getting RRD to graph and sending the result
 * as an HTTP response.
 */
static ngx_int_t ngx_http_rrd_show_graph(ngx_http_request_t *r)
{
    ngx_log_t* log = r->connection->log;
    ngx_http_rrd_loc_conf_t *rrd_conf;
    rrd_conf = ngx_http_get_module_loc_conf(r, ngx_http_rrd_module);

    /* Prepare args for rrdgraph */
    int rrd_argc = -1;
    char** rrd_arg = ngx_http_rrd_create_graph_arg(&rrd_argc, r,
                                                   rrd_conf->db_name_cstyle);
    if (NULL == rrd_arg) {
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
    }
    rrd_clear_error();
    rrd_info_t* const rrd_graph_info = rrd_graph_v(rrd_argc, rrd_arg);
    ngx_log_debug(NGX_LOG_DEBUG_HTTP, log, 0,
                  "rrd_graph (%s, %s, %s, %s) returned %p.",
                  rrd_arg[0], rrd_arg[1], rrd_arg[2], rrd_arg[3],
                  rrd_graph_info);
    if (NULL == rrd_graph_info) {
        ngx_http_rrd_free_graph_arg(r->pool, rrd_argc, rrd_arg);
        return ngx_http_rrd_outprintf(r, NGX_HTTP_INTERNAL_SERVER_ERROR,
                            "Error graphing DB %s: %s", rrd_conf->db_name_cstyle,
                            rrd_get_error());
    }
    rrd_info_t* it;
    u_char* image_data = NULL;
    size_t image_size = 0;
    for(it = rrd_graph_info; NULL == image_data && it != NULL; it = it->next) {
        if (it->key != NULL
            && ngx_strncmp(it->key, "image", sizeof("image")) == 0) {
            image_data = it->value.u_blo.ptr;
            image_size = it->value.u_blo.size;
        }
    }
    if (NULL == image_data) {
        ngx_http_rrd_free_graph_arg(r->pool, rrd_argc, rrd_arg);
        rrd_info_free(rrd_graph_info);
        return ngx_http_rrd_outprintf(r, NGX_HTTP_INTERNAL_SERVER_ERROR,
                            "No image returned graphing DB %s.",
                            rrd_conf->db_name_cstyle);
    }
    ngx_chain_t* out_chain = ngx_http_rrd_get_picture_outchain(r->pool,
                                                      image_data, image_size);
    if (NULL == out_chain) {
        ngx_http_rrd_free_graph_arg(r->pool, rrd_argc, rrd_arg);
        rrd_info_free(rrd_graph_info);
        return ngx_http_rrd_outprintf(r, NGX_HTTP_INTERNAL_SERVER_ERROR,
                            "Problem returning image for DB %s.",
                            rrd_conf->db_name_cstyle);
    }
    ngx_http_rrd_free_graph_arg(r->pool, rrd_argc, rrd_arg);
    rrd_info_free(rrd_graph_info);
    return ngx_http_rrd_png_file_200(r, out_chain);
}
开发者ID:abonavita,项目名称:rrd-nginx-module,代码行数:59,代码来源:ngx_http_rrd_module.c


示例18: srrd_create

/* #endif HAVE_THREADSAFE_LIBRRD */

#else /* !HAVE_THREADSAFE_LIBRRD */
static int srrd_create (const char *filename, /* {{{ */
                        unsigned long pdp_step, time_t last_up,
                        int argc, const char **argv)
{
    int status;

    int new_argc;
    char **new_argv;

    char pdp_step_str[16];
    char last_up_str[16];

    new_argc = 6 + argc;
    new_argv = (char **) malloc ((new_argc + 1) * sizeof (char *));
    if (new_argv == NULL)
    {
        ERROR ("rrdtool plugin: malloc failed.");
        return (-1);
    }

    if (last_up == 0)
        last_up = time (NULL) - 10;

    ssnprintf (pdp_step_str, sizeof (pdp_step_str), "%lu", pdp_step);
    ssnprintf (last_up_str, sizeof (last_up_str), "%u", (unsigned int) last_up);

    new_argv[0] = "create";
    new_argv[1] = (void *) filename;
    new_argv[2] = "-s";
    new_argv[3] = pdp_step_str;
    new_argv[4] = "-b";
    new_argv[5] = last_up_str;

    memcpy (new_argv + 6, argv, argc * sizeof (char *));
    new_argv[new_argc] = NULL;

    pthread_mutex_lock (&librrd_lock);
    optind = 0; /* bug in librrd? */
    rrd_clear_error ();

    status = rrd_create (new_argc, new_argv);
    pthread_mutex_unlock (&librrd_lock);

    if (status != 0)
    {
        WARNING ("rrdtool plugin: rrd_create (%s) failed: %s",
                 filename, rrd_get_error ());
    }

    sfree (new_argv);

    return (status);
} /* }}} int srrd_create */
开发者ID:xchenum,项目名称:collectd,代码行数:56,代码来源:utils_rrdcreate.c


示例19: rrdc_connect

int rrdc_connect (const char *addr) /* {{{ */
{
  int status = 0;

  if (addr == NULL) {
    addr = getenv (ENV_RRDCACHED_ADDRESS);
  }

  if (addr == NULL || strcmp(addr,"") == 0 ) {
    addr = NULL;
    return 0;   
  }

  pthread_mutex_lock(&lock);

  if (sd >= 0 && sd_path != NULL && strcmp(addr, sd_path) == 0)
  {
    /* connection to the same daemon; use cached connection */
    pthread_mutex_unlock (&lock);
    return (0);
  }
  else
  {
    close_connection();
  }

  rrd_clear_error ();
  if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
    status = rrdc_connect_unix (addr + strlen ("unix:"));
  else if (addr[0] == '/')
    status = rrdc_connect_unix (addr);
  else
    status = rrdc_connect_network(addr);

  if (status == 0 && sd >= 0)
    sd_path = strdup(addr);
  else
  {
    char *err = rrd_test_error () ? rrd_get_error () : "Internal error";
    /* err points the string that gets written to by rrd_set_error(), thus we
     * cannot pass it to that function */
    err = strdup (err);
    rrd_set_error("Unable to connect to rrdcached: %s",
                  (status < 0)
                  ? (err ? err : "Internal error")
                  : rrd_strerror (status));
    if (err != NULL)
      free (err);
  }

  pthread_mutex_unlock (&lock);
  return (status);
} /* }}} int rrdc_connect */
开发者ID:BOBYou,项目名称:ntopng,代码行数:53,代码来源:rrd_client.c


示例20: strdup

char *rrdError() {
	char *err = NULL;
	if (rrd_test_error()) {
		// RRD error is local for thread so other gorutine can call some RRD
		// function in the same thread before we use C.GoString. So we need to
		// copy current error before return from C to Go. It need to be freed
		// after C.GoString in Go code.
		err = strdup(rrd_get_error());
		if (err == NULL) {
			abort();
		}
	}
	return err;
}
开发者ID:AlexanderThaller,项目名称:rrd,代码行数:14,代码来源:rrdfunc.c



注:本文中的rrd_get_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rrd_set_error函数代码示例发布时间:2022-05-30
下一篇:
C++ rrd_clear_error函数代码示例发布时间: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