Skip to content

Commit

Permalink
Fixed calculating the ovrall load stats
Browse files Browse the repository at this point in the history
Correlate the summed used processing time with the number of summed processes, not total processes.

(cherry picked from commit bf2e51c)
  • Loading branch information
bogdan-iancu committed Feb 5, 2019
1 parent 9849664 commit 3354d87
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions pt_load.c
Expand Up @@ -239,17 +239,19 @@ unsigned int pt_get_rt_load(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 )
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 ) {
SUM_UP_LOAD( usec_now, n, ST, 1);
summed_procs++;
}

return (used*100/(ST_WINDOW_TIME*counted_processes));
return (used*100/(ST_WINDOW_TIME*summed_procs));
}


Expand All @@ -258,17 +260,19 @@ unsigned int pt_get_1m_load(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 )
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 ) {
SUM_UP_LOAD( usec_now, n, LT, LT_1m_RATIO);
summed_procs++;
}

return (used*100/(LT_WINDOW_TIME*counted_processes*LT_1m_RATIO));
return (used*100/(LT_WINDOW_TIME*summed_procs*LT_1m_RATIO));
}


Expand All @@ -277,17 +281,19 @@ unsigned int pt_get_10m_load(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 )
if ( (pt[n].flags&(OSS_FORK_NO_LOAD|OSS_FORK_IS_EXTRA))==0 ) {
SUM_UP_LOAD( usec_now, n, LT, 1);
summed_procs++;
}

return (used*100/(LT_WINDOW_TIME*counted_processes));
return (used*100/(LT_WINDOW_TIME*summed_procs));
}


Expand All @@ -296,17 +302,19 @@ unsigned int pt_get_rt_loadall(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 )
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 ) {
SUM_UP_LOAD( usec_now, n, ST, 1);
summed_procs++;
}

return (used*100/(ST_WINDOW_TIME*counted_processes));
return (used*100/(ST_WINDOW_TIME*summed_procs));
}


Expand All @@ -315,17 +323,19 @@ unsigned int pt_get_1m_loadall(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 )
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 ) {
SUM_UP_LOAD( usec_now, n, LT, LT_1m_RATIO);
summed_procs++;
}

return (used*100/(LT_WINDOW_TIME*counted_processes*LT_1m_RATIO));
return (used*100/(LT_WINDOW_TIME*summed_procs*LT_1m_RATIO));
}


Expand All @@ -334,17 +344,19 @@ unsigned int pt_get_10m_loadall(int _)
utime_t usec_now;
struct timeval tv;
int idx_old, idx_new, idx_start, i; /* used inside the macro */
int n;
int n, summed_procs=0;
unsigned long long used = 0;

gettimeofday( &tv, NULL);
usec_now = ((utime_t)(tv.tv_sec)) * 1000000 + tv.tv_usec;

for( n=0 ; n<counted_processes; n++)
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 )
if ( (pt[n].flags&OSS_FORK_NO_LOAD)==0 ) {
SUM_UP_LOAD( usec_now, n, LT, 1);
summed_procs++;
}

return (used*100/(LT_WINDOW_TIME*counted_processes));
return (used*100/(LT_WINDOW_TIME*summed_procs));
}


Expand Down

0 comments on commit 3354d87

Please sign in to comment.