本文整理汇总了C++中set_mod_record函数的典型用法代码示例。如果您正苦于以下问题:C++ set_mod_record函数的具体用法?C++ set_mod_record怎么用?C++ set_mod_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_mod_record函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: read_lvs
/*
*******************************************************
* Read swapping statistics from ip_vs_stat
*******************************************************
*/
static void
read_lvs(struct module *mod)
{
st_lvs.stat = 0;
st_lvs.conns = 0;
st_lvs.pktin = 0;
st_lvs.pktout = 0;
st_lvs.bytin = 0;
st_lvs.bytout = 0;
int i = 0, pos=0;
char buf[512];
char tmp[5][16];
FILE *fp;
char line[MAX_LINE_LEN];
if ((fp = fopen(LVS_STATS, "r")) != NULL) {
st_lvs.stat = 1;
while (fgets(line, MAX_LINE_LEN, fp) != NULL) {
i++;
if (i < 3) {
continue;
}
if (!strncmp(line, "CPU", 3)) {
/* CPU 0: 5462458943 44712664864 54084995692 8542115117674 41738811918899 */
int k = 0;
k = strcspn(line, ":");
sscanf(line + k + 1, "%s %s %s %s %s", tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]);
st_lvs.conns += strtoll(tmp[0], NULL, 10);
st_lvs.pktin += strtoll(tmp[1], NULL, 10);
st_lvs.pktout += strtoll(tmp[2], NULL, 10);
st_lvs.bytin += strtoll(tmp[3], NULL, 10);
st_lvs.bytout += strtoll(tmp[4], NULL, 10);
} else {
/* 218EEA1A 1B3BA96D 0 163142140FA1F 0 */
sscanf(line, "%s %s %s %s %s", tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]);
st_lvs.conns += strtoll(tmp[0], NULL ,16);
st_lvs.pktin += strtoll(tmp[1], NULL, 16);
st_lvs.pktout += strtoll(tmp[2], NULL, 16);
st_lvs.bytin += strtoll(tmp[3], NULL, 16);
st_lvs.bytout += strtoll(tmp[4], NULL, 16);
break;
}
}
if (fclose(fp) < 0) {
return;
}
}
if (st_lvs.stat == 1) {
pos = sprintf(buf, LVS_STORE_FMT(DATA_SPLIT), st_lvs.stat, st_lvs.conns, st_lvs.pktin, st_lvs.pktout, st_lvs.bytin, st_lvs.bytout);
} else {
return;
}
buf[pos] = '\0';
set_mod_record(mod, buf);
return;
}
开发者ID:0xmalloc,项目名称:tsar,代码行数:62,代码来源:mod_lvs.c
示例17: read_pernic_stats
/*
* collect pernic infomation
*/
static void
read_pernic_stats(struct module *mod)
{
int pos = 0, nics = 0;
FILE *fp;
char line[LEN_10240] = {0};
char buf[LEN_10240] = {0};
struct stats_pernic st_pernic;
memset(buf, 0, LEN_10240);
memset(&st_pernic, 0, sizeof(struct stats_pernic));
if ((fp = fopen(NET_DEV, "r")) == NULL) {
return;
}
while (fgets(line, LEN_10240, fp) != NULL) {
memset(&st_pernic, 0, sizeof(st_pernic));
if (!strstr(line, ":")) {
continue;
}
sscanf(line, "%*[^a-z]%[^:]:%llu %llu %*u %*u %*u %*u %*u %*u "
"%llu %llu %*u %*u %*u %*u %*u %*u",
st_pernic.name,
&st_pernic.bytein,
&st_pernic.pktin,
&st_pernic.byteout,
&st_pernic.pktout);
/* if nic not used, skip it */
if (st_pernic.bytein == 0) {
continue;
}
pos += snprintf(buf + pos, LEN_10240 - pos, "%s=%lld,%lld,%lld,%lld" ITEM_SPLIT,
st_pernic.name,
st_pernic.bytein,
st_pernic.byteout,
st_pernic.pktin,
st_pernic.pktout);
if (strlen(buf) == LEN_10240 - 1) {
fclose(fp);
return;
}
nics++;
if (nics > MAX_NICS) {
break;
}
}
set_mod_record(mod, buf);
fclose(fp);
return;
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:tsar,代码行数:57,代码来源:mod_pernic.c
示例18: read_squid_stat
void
read_squid_stat(struct module *mod, char *parameter)
{
int i, pos = 0;
char buf[LEN_4096] = {0};
char itemname[LEN_4096] = {0};
live_squid_nr = 0;
count_squid_nr();
if (squid_nr == 0) {
if (atoi(parameter) != 0) {
port_list[0] = atoi(parameter);
squid_nr = 1;
} else {
port_list[0] = 3128;
squid_nr = 1;
}
}
memset(s_st_squid, 0, STATS_SQUID_SIZE * MAXSQUID);
/*get the live squid number*/
for (i = 0; i < squid_nr; i++) {
int retry = 0;
/* read on each port and retry to get squidclient for 3 times*/
while (__read_squid_stat(port_list[i], i) < 0 && retry < RETRY_NUM) {
retry++;
}
if (retry == RETRY_NUM) {
continue;
}
s_st_squid[i].usable = TRUE;
live_squid_nr++;
}
/* traverse the port list */
for (i = 0; i < squid_nr; i++) {
if (!s_st_squid[i].usable) {
continue;
}
/* generate the item name */
int n = sprintf(itemname, "port%d", port_list[i]);
itemname[n] = '\0';
/* print log to buffer */
pos += store_single_port(buf + pos, itemname, i);
/* print a seperate char */
pos += sprintf(buf + pos, ITEM_SPLIT);
}
if (pos && squid_nr == live_squid_nr) {
buf[pos] = '\0';
set_mod_record(mod, buf);
}
}
开发者ID:4Second2None,项目名称:tsar,代码行数:53,代码来源:mod_squid.c
示例19: read_tcp_stats
void
read_tcp_stats(struct module *mod)
{
int sw = FALSE;
FILE *fp;
char line[LEN_1024];
char buf[LEN_1024];
struct stats_tcp st_tcp;
memset(buf, 0, LEN_1024);
memset(&st_tcp, 0, sizeof(struct stats_tcp));
if ((fp = fopen(NET_SNMP, "r")) == NULL) {
return;
}
while (fgets(line, LEN_1024, fp) != NULL) {
if (!strncmp(line, "Tcp:", 4)) {
if (sw) {
sscanf(line + 4, "%*u %*u %*u %*d %llu %llu "
"%llu %llu %*u %llu %llu %llu %llu %llu",
&st_tcp.ActiveOpens,
&st_tcp.PassiveOpens,
&st_tcp.AttemptFails,
&st_tcp.EstabResets,
&st_tcp.InSegs,
&st_tcp.OutSegs,
&st_tcp.RetransSegs,
&st_tcp.InErrs,
&st_tcp.OutRsts);
break;
} else {
sw = TRUE;
}
}
}
fclose(fp);
int pos = sprintf(buf, "%lld,%lld,%lld,%lld,%lld",
st_tcp.ActiveOpens,
st_tcp.PassiveOpens,
st_tcp.InSegs,
st_tcp.OutSegs,
st_tcp.RetransSegs);
buf[pos] = '\0';
set_mod_record(mod, buf);
}
开发者ID:4Second2None,项目名称:tsar,代码行数:48,代码来源:mod_tcp.c
示例20: read_stat_load
void
read_stat_load(struct module *mod)
{
int load_tmp[3];
FILE *fp;
char buf[LEN_4096];
struct stats_load st_load;
memset(buf, 0, LEN_4096);
memset(&st_load, 0, sizeof(struct stats_load));
if ((fp = fopen(LOADAVG, "r")) == NULL) {
return;
}
/* Read load averages and queue length */
if (fscanf(fp, "%d.%d %d.%d %d.%d %ld/%d %*d\n",
&load_tmp[0], &st_load.load_avg_1,
&load_tmp[1], &st_load.load_avg_5,
&load_tmp[2], &st_load.load_avg_15,
&st_load.nr_running,
&st_load.nr_threads) != 8)
{
fclose(fp);
return;
}
st_load.load_avg_1 += load_tmp[0] * 100;
st_load.load_avg_5 += load_tmp[1] * 100;
st_load.load_avg_15 += load_tmp[2] * 100;
if (st_load.nr_running) {
/* Do not take current process into account */
st_load.nr_running--;
}
int pos = sprintf(buf , "%u,%u,%u,%lu,%u",
st_load.load_avg_1,
st_load.load_avg_5,
st_load.load_avg_15,
st_load.nr_running,
st_load.nr_threads);
buf[pos] = '\0';
set_mod_record(mod, buf);
fclose(fp);
}
开发者ID:0xmalloc,项目名称:tsar,代码行数:44,代码来源:mod_load.c
注:本文中的set_mod_record函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论