Skip to content

Commit

Permalink
update to svn
Browse files Browse the repository at this point in the history
  • Loading branch information
kongjian committed Dec 25, 2014
1 parent 181507d commit adf1f92
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
8 changes: 6 additions & 2 deletions modules/mod_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ set_cpu_record(struct module *mod, double st_array[],
U_64 pre_total, cur_total;
pre_total = cur_total = 0;

for (i = 0; i < mod->n_col - 1; i++) {
for (i = 0; i < 9; i++) {
if(cur_array[i] < pre_array[i]){
for(j = 0; j < 9; j++)
st_array[j] = -1;
Expand All @@ -109,8 +109,12 @@ set_cpu_record(struct module *mod, double st_array[],
}

/* no tick changes, or tick overflows */
if (cur_total <= pre_total)
if (cur_total <= pre_total) {
for(j = 0; j < 9; j++)
st_array[j] = -1;
return;
}

/* set st record */
for (i = 0; i < 9; i++) {
/* st_array[5] is util, calculate it late */
Expand Down
7 changes: 5 additions & 2 deletions modules/mod_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ static void
set_io_record(struct module *mod, double st_array[],
U_64 pre_array[], U_64 cur_array[], int inter)
{
int i;
int i, j;
for(i = 0; i < 11; i++){
if(cur_array[i] < pre_array[i]){
pre_array[i] = cur_array[i];
for(j = 0; j < 11; j++){
st_array[j] = -1;
}
return;
}
}
unsigned long long rd_ios = cur_array[0] - pre_array[0];
Expand Down
6 changes: 6 additions & 0 deletions modules/mod_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ static void
set_mem_record(struct module *mod, double st_array[],
U_64 pre_array[], U_64 cur_array[], int inter)
{
int i;
if ((cur_array[4] - cur_array[0] -cur_array[2] -cur_array[3]) < 0) {
for (i = 0; i < 6; i++)
st_array[i] = -1;
return;
}
st_array[0] = cur_array[0]<<10;
st_array[1] = (cur_array[4] - cur_array[0] -cur_array[2] -cur_array[3])<<10;
st_array[2] = cur_array[2]<<10;
Expand Down
6 changes: 1 addition & 5 deletions modules/mod_nginx_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ static int nginxcmp(const void *a, const void *b)
struct stats_nginx_domain *pa = (struct stats_nginx_domain *)a, *pb = (struct stats_nginx_domain *)b;
return strcmp(pa->domain, pb->domain);
}
static int nginxcmp2(const void *a, const void *b)
{
struct stats_nginx_domain *pa = (struct stats_nginx_domain *)a, *pb = (struct stats_nginx_domain *)b;
return (pa->nreq < pb->nreq);
}

struct hostinfo {
char *host;
int port;
Expand Down
3 changes: 3 additions & 0 deletions modules/mod_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ set_part_record(struct module *mod, double st_array[], U_64 pre_array[], U_64 cu
if(nonroot_total != 0) {
st_array[3]= (used * 100.0) / nonroot_total + ((used * 100) % nonroot_total != 0);
}
if (st_array[3] > 100) {
st_array[3] = 100;
}
}

static struct mod_info part_info[] = {
Expand Down
7 changes: 5 additions & 2 deletions modules/mod_traffic.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct stats_traffic {
static void
read_traffic_stats(struct module *mod)
{
int len = 0;
int len = 0, num = 0;
FILE *fp;
char *p = NULL;
char line[LEN_4096] = {0};
Expand Down Expand Up @@ -49,6 +49,7 @@ read_traffic_stats(struct module *mod)
&cur_st.byteout,
&cur_st.pktout);

num++;
total_st.bytein += cur_st.bytein;
total_st.byteout += cur_st.byteout;
total_st.pktin += cur_st.pktin;
Expand All @@ -62,7 +63,9 @@ read_traffic_stats(struct module *mod)
total_st.pktin,
total_st.pktout);
buf[len] = '\0';
set_mod_record(mod, buf);
if(num > 0) {
set_mod_record(mod, buf);
}
fclose(fp);
}

Expand Down
4 changes: 2 additions & 2 deletions src/output_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ running_check(int check_type)
/* check file update time */
stat(filename, &statbuf);
time(&nowtime);
if (nowtime - statbuf.st_ctime > 300) {
do_debug(LOG_FATAL, "/var/log/tsar.data is far away from now, last time is %s", ctime(&statbuf.st_ctime));
if (nowtime - statbuf.st_mtime > 300) {
do_debug(LOG_FATAL, "/var/log/tsar.data is far away from now, now time is %d, last time is %d", nowtime, statbuf.st_mtime);
}
/* get file len */
memset(&line[0], 0, LEN_40960);
Expand Down

0 comments on commit adf1f92

Please sign in to comment.