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


C++ set_mod_record函数代码示例

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


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

示例1: read_rpi_stats

static void read_rpi_stats(struct module *mod, char *parameter)
{
	FILE *fp;
	char buf[64];
	memset(buf, 0, sizeof(buf));
	struct stats_rpi st_rpi;
	memset(&st_rpi, 0, sizeof(struct stats_rpi));

	if ((fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r")) == NULL) {
		return;
	}

	int cpu_temp;

	fscanf(fp, "%d", &cpu_temp);
    
    if (cpu_temp == 85*1000 || cpu_temp < 1) {
        return;
    }

	st_rpi.cpu_temp = cpu_temp;

	int pos = sprintf(buf, "%u",
			/* the store order is not same as read procedure */
			st_rpi.cpu_temp);
	buf[pos] = '\0';
	set_mod_record(mod, buf);
	fclose(fp);
	return;
}
开发者ID:cloudcache,项目名称:tsar,代码行数:30,代码来源:mod_rpi.c

示例2: read_tcprt_stats

static void
read_tcprt_stats(struct module *mod)
{
    char    buf[LEN_4096];
    struct  stats_tcprt st_tcprt;

    memset(buf, 0, LEN_4096);
    memset(&st_tcprt, 0, sizeof(struct stats_tcprt));

    st_tcprt.avg_bytes = get_value(file_avg_bytes);
    st_tcprt.avg_bytes81 = get_value(file_avg_bytes81);
    st_tcprt.avg_rt = get_value(file_avg_rt);
    st_tcprt.avg_rt81 = get_value(file_avg_rt81);
    st_tcprt.avg_drop = get_value(file_avg_drop);
    st_tcprt.avg_drop81 = get_value(file_avg_drop81);
    st_tcprt.avg_server_time = get_value(file_avg_server_time);
    st_tcprt.avg_server_time81 = get_value(file_avg_server_time81);
    st_tcprt.avg_fail = get_value(file_avg_fail);

    int pos = sprintf(buf, "%u,%u,%u,%u,%u,%u,%u,%u,%u",
            st_tcprt.avg_bytes,
            st_tcprt.avg_bytes81,
            st_tcprt.avg_drop,
            st_tcprt.avg_drop81,
            st_tcprt.avg_rt,
            st_tcprt.avg_rt81,
            st_tcprt.avg_server_time,
            st_tcprt.avg_server_time81,
            st_tcprt.avg_fail);

    buf[pos] = '\0';
    set_mod_record(mod, buf);
}
开发者ID:chobits,项目名称:tsar,代码行数:33,代码来源:mod_tcprt.c

示例3: read_swift_stats

void
read_swift_stats(struct module *mod, char *parameter)
{
    int    retry = 0, pos = 0;
    char   buf[LEN_1024];

    memset(&stats, 0, sizeof(stats));
    mgrport = atoi(parameter);
    if (!mgrport) {
        mgrport = 81;
    }
    while (read_swift_stat("info") < 0 && retry < RETRY_NUM) {
        retry++;
    }
    retry = 0;
    while (read_swift_stat("counters") < 0 && retry < RETRY_NUM) {
        retry++;
    }
    pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld",
            stats.requests,
            stats.total_svc_time,
            stats.hits,
            stats.b_hit,
            stats.objs,
            stats.bytes_in,
            stats.bytes_out,
            stats.t_cpu,
            stats.s_cpu
             );
    buf[pos] = '\0';
    // fprintf(stderr, "buf: %s\n", buf);
    set_mod_record(mod, buf);
}
开发者ID:chen--oRanGe,项目名称:tsar,代码行数:33,代码来源:mod_swift.c

示例4: read_traffic_stats

/*
 * collect traffic infomation
 */
static void
read_traffic_stats(struct module *mod)
{
    int                   len = 0, num = 0;
    FILE                 *fp;
    char                 *p = NULL;
    char                  line[LEN_4096] = {0};
    char                  buf[LEN_4096] = {0};
    struct stats_traffic  total_st, cur_st;

    memset(buf, 0, LEN_4096);
    memset(&total_st, 0, sizeof(struct stats_traffic));
    memset(&cur_st, 0, sizeof(struct stats_traffic));

    if ((fp = fopen(NET_DEV, "r")) == NULL) {
        return;
    }

    memset(&total_st, 0, sizeof(cur_st));

    while (fgets(line, LEN_4096, fp) != NULL) {
        if (strstr(line, "eth") || strstr(line, "em") || strstr(line, "venet")) {
            memset(&cur_st, 0, sizeof(cur_st));
            p = strchr(line, ':');
            sscanf(p + 1, "%llu %llu %llu %llu %*u %*u %*u %*u "
                    "%llu %llu %llu %llu %*u %*u %*u %*u",
                    &cur_st.bytein,
                    &cur_st.pktin,
		    &cur_st.pkterrin,
		    &cur_st.pktdrpin,
                    &cur_st.byteout,
		    &cur_st.pktout,
		    &cur_st.pkterrout,
                    &cur_st.pktdrpout);

            num++;
            total_st.bytein    += cur_st.bytein;
            total_st.byteout   += cur_st.byteout;
            total_st.pktin     += cur_st.pktin;
            total_st.pktout    += cur_st.pktout;
            total_st.pkterrin  += cur_st.pkterrin;
            total_st.pktdrpin  += cur_st.pktdrpin;
            total_st.pkterrout += cur_st.pkterrout;
            total_st.pktdrpout += cur_st.pktdrpout;
        }
    }

    len = sprintf(buf, "%lld,%lld,%lld,%lld,%lld,%lld",
            total_st.bytein,
            total_st.byteout,
            total_st.pktin,
            total_st.pktout,
            total_st.pkterrin + total_st.pkterrout,
            total_st.pktdrpin + total_st.pktdrpout);
    buf[len] = '\0';
    if(num > 0) {
        set_mod_record(mod, buf);
    }
    fclose(fp);
}
开发者ID:Alibaba-boonya,项目名称:tsar,代码行数:63,代码来源:mod_traffic.c

示例5: read_swift_tcmalloc_stats

void
read_swift_tcmalloc_stats(struct module *mod, char *parameter)
{
    int    retry = 0 , pos = 0;
    char   buf[LEN_10240];
    memset(&stats, 0, sizeof(stats));
    mgrport = atoi(parameter);
    if (!mgrport) {
        mgrport = 82;
    }
    while (read_swift_tcmalloc_stat() < 0 && retry < RETRY_NUM) {
        retry++;
    }

    pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld",
            stats.uba,
            stats.phf,
            stats.ccf,
            stats.trcf,
            stats.thcf,
            stats.mm,
            stats.amu,
            stats.brto,
            stats.vasu,
            stats.siu,
            stats.thiu,
            stats.tps
             );
    buf[pos] = '\0';
    set_mod_record(mod, buf);
}
开发者ID:CopyOfalibaba,项目名称:tsar,代码行数:31,代码来源:mod_swift_tcmalloc.c

示例6: read_swift_stats

static void
read_swift_stats(struct module *mod, char *parameter)
{
    int    retry = 0, pos = 0;
    char   buf[LEN_4096];

    memset(&stats, 0, sizeof(stats));
    mgrport = atoi(parameter);
    if (!mgrport) {
        mgrport = 82;
    }
    retry = 0;
    while (read_swift_stat("counters") < 0 && retry < RETRY_NUM) {
        retry++;
    }
    pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld",
             stats.c_act,
             stats.c_conn,
             stats.s_act,
             stats.s_conn,
             stats.s_wait
               );

    buf[pos] = '\0';
    set_mod_record(mod, buf);
}
开发者ID:0xmalloc,项目名称:tsar,代码行数:26,代码来源:mod_swift_conn.c

示例7: print_cgblkio_stats

void
print_cgblkio_stats(struct module *mod)
{
    int    pos = 0, i = 0;
    char   buf[LEN_4096];
    /*set n group's data to buf*/
    for(i = 0; i < n_group; i++){
        pos += snprintf(buf + pos, LEN_4096, "%s=%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu",
                blkio_groups[i].group_name,
                blkio_groups[i].rd_merges,
                blkio_groups[i].wr_merges,
                blkio_groups[i].rd_ios,
                blkio_groups[i].wr_ios,
                blkio_groups[i].rd_secs,
                blkio_groups[i].wr_secs,
                blkio_groups[i].qusize,
                blkio_groups[i].wait,
                blkio_groups[i].svctm);
        if(pos >= LEN_4096)
            break;
        pos += snprintf(buf + pos, LEN_4096, ITEM_SPLIT);
        if(pos >= LEN_4096)
            break;
    }
    /*notice tsar to store my mult item data*/
    set_mod_record(mod, buf);
}
开发者ID:4Second2None,项目名称:tsar,代码行数:27,代码来源:mod_cgblkio.c

示例8: read_swift_store_stats

void
read_swift_store_stats(struct module *mod, char *parameter)
{
    int    retry = 0, pos = 0;
    char   buf[LEN_1024];
    memset(&stats, 0, sizeof(stats));
    mgrport = atoi(parameter);
    if (!mgrport) {
        mgrport = 81;
    }
    while (read_swift_store_stat() < 0 && retry < RETRY_NUM) {
        retry++;
    }
    pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld",
            stats.objs,
            stats.mobj,
            stats.dobj,
            stats.size,
            stats.ram,
            stats.disk,
            stats.m_hit,
            stats.coss,
            stats.tcoss
             );
    buf[pos] = '\0';
    set_mod_record(mod, buf);
}
开发者ID:CodeSummer,项目名称:tsar,代码行数:27,代码来源:mod_swift_store.c

示例9: read_swift_code_stats

void
read_swift_code_stats(struct module *mod, char *parameter)
{
    int    retry = 0, pos = 0;
    char   buf[LEN_1024];
    memset(&stats, 0, sizeof(stats));
    mgrport = atoi(parameter);
    if(!mgrport){
        mgrport = 81;
    }
    while (read_swift_code_stat() < 0 && retry < RETRY_NUM) {
        retry++;
    }
    pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld,%lld",
            stats.code200,
            stats.code206,
            stats.code301,
            stats.code302,
            stats.code304,
            stats.code400,
            stats.code403,
            stats.code404,
            stats.code500,
            stats.code502,
            stats.code503,
            stats.code504,
            stats.codeother
             );
    buf[pos] = '\0';
    set_mod_record(mod, buf);
}
开发者ID:chen--oRanGe,项目名称:tsar,代码行数:31,代码来源:mod_swift_code.c

示例10: read_haproxy

/*
 *******************************************************
 * Read swapping statistics from haproxy.stat & 80 port
 *******************************************************
 */
static void
read_haproxy(struct module *mod)
{
    int i, pos=0;
    char buf[512];

    memset(&st_haproxy, 0, sizeof(struct stats_haproxy));
    for (i = 0;i < RETRY;i++) {
        if (get_http_status() == 0 && access(HAPROXY, 0) == 0) {
            st_haproxy.stat = 1;
            break;
        }
    }
    if (st_haproxy.stat == 1 && get_haproxy_detail() == 0) {
        if (DEBUG) {
            printf("get right.\n");
        }

    } else {
        if (DEBUG) {
            printf("get wrong.\n");
        }
    }
    if (st_haproxy.stat == 1) {
        pos = sprintf(buf, HAPROXY_STORE_FMT(DATA_SPLIT), st_haproxy.stat, st_haproxy.uptime,
                      st_haproxy.conns, st_haproxy.qps, st_haproxy.hit, st_haproxy.rt);
    }
    buf[pos] = '\0';
    set_mod_record(mod, buf);
    return;
}
开发者ID:haiger,项目名称:tsar,代码行数:36,代码来源:mod_haproxy.c

示例11: print_partition_stats

void
print_partition_stats(struct module *mod)
{
    int pos = 0;
    char buf[LEN_4096];
    memset(buf, 0, LEN_4096);
    unsigned int p;

    for (p = 0; p < n_partitions; p++) {
        pos += sprintf(buf + pos, "%s=%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%d",
                partition[p].name,
                new_blkio[p].rd_ios,
                new_blkio[p].rd_merges,
                new_blkio[p].rd_sectors,
                new_blkio[p].rd_ticks,
                new_blkio[p].wr_ios,
                new_blkio[p].wr_merges,
                new_blkio[p].wr_sectors,
                new_blkio[p].wr_ticks,
                new_blkio[p].ticks,
                new_blkio[p].aveq,
                pos);
        pos += sprintf(buf + pos, ITEM_SPLIT);
    }
    if (pos) {
        buf[pos] = '\0';
        set_mod_record(mod, buf);
    }
    rewind(iofp);
    if (NULL != iofp) {
        fclose(iofp);
        iofp =NULL;
    }
    return;
}
开发者ID:nksosoon,项目名称:tsar,代码行数:35,代码来源:mod_io.c

示例12: read_swift_domain_stats

static void read_swift_domain_stats(struct module *mod, char *parameter)
{
    int    retry = 0, pos = 0;
    char   buf[LEN_1024];
    int    i;

    memset(&swift_domain_stats, 0, sizeof(swift_domain_stats));

    swift_domain_init(parameter);

    while (read_swift_code_stat() < 0 && retry < RETRY_NUM) {
        retry++;
    }

    for (i = 0; i < stats_count; i ++) {
        pos += sprintf(buf + pos, "%s=%lld,%lld,%lld",
                swift_domain[i],
                swift_domain_stats[i][0],
                swift_domain_stats[i][1],
                swift_domain_stats[i][2]);
        pos += sprintf(buf + pos, ITEM_SPLIT);
    }
    buf[pos] = '\0';
    set_mod_record(mod, buf);

    swift_domian_free();
}
开发者ID:GrassrootsWorkers,项目名称:tsar,代码行数:27,代码来源:mod_swift_domain.c

示例13: read_vmstat_swap

/*
 *********************************************
 * Read swapping statistics from /proc/vmstat.
 *********************************************
 */
static void read_vmstat_swap(struct module *mod)
{
	FILE *fp;
	char line[4096], buf[LEN_4096];
	memset(buf, 0, LEN_4096);
	struct stats_swap st_swap;
	memset(&st_swap, 0, sizeof(struct stats_swap));
	if ((fp = fopen(VMSTAT, "r")) == NULL) {
		return ;
	}

	while (fgets(line, LEN_4096, fp) != NULL) {

		if (!strncmp(line, "pswpin ", 7)) {
			/* Read number of swap pages brought in */
			sscanf(line + 7, "%lu", &st_swap.pswpin);
		}
		else if (!strncmp(line, "pswpout ", 8)) {
			/* Read number of swap pages brought out */
			sscanf(line + 8, "%lu", &st_swap.pswpout);
		}
	}
	fclose(fp);
	int pos = sprintf(buf, "%ld,%ld", st_swap.pswpin, st_swap.pswpout);
	buf[pos] = '\0';
	set_mod_record(mod, buf);
	return;
}
开发者ID:2005wind,项目名称:tsar,代码行数:33,代码来源:mod_swap.c

示例14: print_cgmem_stats

void
print_cgmem_stats(struct module *mod)
{
    int    pos = 0, i = 0;
    char   buf[LEN_4096];

    /*set n group's data to buf*/
    for (i = 0; i < n_group; i++) {
        pos += snprintf(buf + pos, LEN_4096, "%s=%lu,%lu,%lu,%lu,%lu,%lu",
                cgmem_groups[i].group_name,
                cgmem_groups[i].cache + cgmem_groups[i].rss,
                cgmem_groups[i].swap,
                cgmem_groups[i].inanon,
                cgmem_groups[i].acanon,
                cgmem_groups[i].infile,
                cgmem_groups[i].acfile);
        if (pos >= LEN_4096) {
            break;
        }
        pos += snprintf(buf + pos, LEN_4096, ITEM_SPLIT);
        if (pos >= LEN_4096) {
            break;
        }
    }
    /*notice tsar to store my mult item data*/
    set_mod_record(mod, buf);
}
开发者ID:atixing,项目名称:tsar,代码行数:27,代码来源:mod_cgmem.c

示例15: read_cpu_stats

static void
read_cpu_stats(struct module *mod)
{
    int               pos = 0;
    char              line[LEN_4096];
    char              buf[LEN_4096];
    char              cpuname[16];
    FILE             *fp;
    struct stats_cpu  st_cpu;

    memset(buf, 0, LEN_4096);
    memset(&st_cpu, 0, sizeof(struct stats_cpu));
    if ((fp = fopen(STAT, "r")) == NULL) {
        return;
    }
    while (fgets(line, LEN_4096, fp) != NULL) {
        if (!strncmp(line, "cpu", 3)) {
            /*
             * Read the number of jiffies spent in the different modes
             * (user, nice, etc.) among all proc. CPU usage is not reduced
             * to one processor to avoid rounding problems.
             */
            sscanf(line,"%4s", cpuname);
            if(strcmp(cpuname,"cpu") == 0)
                continue;
            sscanf(line+5, "%llu %llu %llu %llu %llu %llu %llu %llu %llu",
                    &st_cpu.cpu_user,
                    &st_cpu.cpu_nice,
                    &st_cpu.cpu_sys,
                    &st_cpu.cpu_idle,
                    &st_cpu.cpu_iowait,
                    &st_cpu.cpu_hardirq,
                    &st_cpu.cpu_softirq,
                    &st_cpu.cpu_steal,
                    &st_cpu.cpu_guest);

            pos += sprintf(buf + pos, "%s=%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu",
                    /* the store order is not same as read procedure */
                    cpuname,
                    st_cpu.cpu_user,
                    st_cpu.cpu_sys,
                    st_cpu.cpu_iowait,
                    st_cpu.cpu_hardirq,
                    st_cpu.cpu_softirq,
                    st_cpu.cpu_idle,
                    st_cpu.cpu_nice,
                    st_cpu.cpu_steal,
                    st_cpu.cpu_guest);
            pos += sprintf(buf + pos, ITEM_SPLIT);
        }
    }
    if (pos) {
        buf[pos] = '\0';
        set_mod_record(mod, buf);
    }
    fclose(fp);
    return;
}
开发者ID:atixing,项目名称:tsar,代码行数:58,代码来源:mod_ncpu.c


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