当前位置: 首页>>代码示例>>C++>>正文


C++ rrd_get_error函数代码示例

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


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


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