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


C++ rrd_clear_error函数代码示例

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


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

示例1: 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

示例2: 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

示例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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: rrdc_flush_if_daemon

/* convenience function; if there is a daemon specified, or if we can
 * detect one from the environment, then flush the file.  Otherwise, no-op
 */
int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename) /* {{{ */
{
  int status = 0;

  rrdc_connect(opt_daemon);

  if (rrdc_is_connected(opt_daemon))
  {
    rrd_clear_error();
    status = rrdc_flush (filename);

    if (status != 0 && !rrd_test_error())
    {
      if (status > 0)
      {
        rrd_set_error("rrdc_flush (%s) failed: %s",
                      filename, rrd_strerror(status));
      }
      else if (status < 0)
      {
        rrd_set_error("rrdc_flush (%s) failed with status %i.",
                      filename, status);
      }
    }
  } /* if (rrdc_is_connected(..)) */

  return status;
} /* }}} int rrdc_flush_if_daemon */
开发者ID:BOBYou,项目名称:ntopng,代码行数:31,代码来源:rrd_client.c

示例9: 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

示例10: 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

示例11: rrd_clear_error

static void throwException
(JNIEnv *env, char *exception, char *msg) {
  int rc = (*env)->ThrowNew(env, (*env)->FindClass(env, exception), msg);
  if(rc < 0)  /* couldn't find exception class */
    (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/Exception"), msg);
  rrd_clear_error();
}
开发者ID:caseylucas,项目名称:rrdtool-java,代码行数:7,代码来源:RRDJNI.c

示例12: main

int main(int argc, char *argv[])
{
    char *rrdargs[] = {
        "rrdgraph",
        "bbgen.png",
        "-s", "e - 48d",
        "--title", "bbgen runtime last 48 days",
        "-w576",
        "-v", "Seconds",
        "-a", "PNG",
        "DEF:rt=bbgen.rrd:runtime:AVERAGE",
        "AREA:rt#00CCCC:Run Time",
        "COMMENT: Timestamp",
        NULL
    };
    char **calcpr=NULL;

    int pcount, result, xsize, ysize;
    double ymin, ymax;

    for (pcount = 0; (rrdargs[pcount]); pcount++);
    rrd_clear_error();
#ifdef RRDTOOL12
    result = rrd_graph(pcount, rrdargs, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax);
#else
    result = rrd_graph(pcount, rrdargs, &calcpr, &xsize, &ysize);
#endif

    return 0;
}
开发者ID:tjyang,项目名称:abmon,代码行数:30,代码来源:test-rrd.c

示例13: 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

示例14: reset_rrd_state

void reset_rrd_state(
    )
{
    optind = 0;
    opterr = 0;
    rrd_clear_error();
}
开发者ID:Distrotech,项目名称:rrdtool,代码行数:7,代码来源:main.c

示例15: 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


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