library: loadavg change to procps_loadavg

This commit is contained in:
Craig Small 2015-07-01 21:47:30 +10:00
parent 9830fdf0ae
commit c3e85cef73
5 changed files with 20 additions and 11 deletions

View File

@ -1,7 +1,6 @@
LIBPROCPS_0 {
global:
closeproc;
cpuinfo;
dev_to_tty;
escape_command;
escape_str;
@ -34,7 +33,6 @@ global:
kb_swap_free;
kb_swap_total;
kb_swap_used;
loadavg;
look_up_our_self;
lookup_wchan;
meminfo;
@ -52,6 +50,7 @@ global:
procps_cpu_count;
procps_hertz_get;
procps_linux_version;
procps_loadavg;
procps_meminfo_new;
procps_meminfo_read;
procps_meminfo_ref;

View File

@ -162,9 +162,20 @@ static void init_libproc(void){
page_bytes = sysconf(_SC_PAGESIZE);
}
/***********************************************************************/
PROCPS_EXPORT int loadavg(double *restrict av1, double *restrict av5, double *restrict av15)
/*
* procps_loadavg:
* @av1: location to store 1 minute load average
* @av5: location to store 5 minute load average
* @av15: location to store 15 minute load average
*
* Find the 1,5 and 15 minute load average of the system
*
* Returns: 0 on success <0 on error
*/
PROCPS_EXPORT int procps_loadavg(
double *restrict av1,
double *restrict av5,
double *restrict av15)
{
double avg_1=0, avg_5=0, avg_15=0;
char *savelocale;
@ -174,7 +185,7 @@ PROCPS_EXPORT int loadavg(double *restrict av1, double *restrict av5, double *re
savelocale = strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
if (sscanf(buf, "%lf %lf %lf", &avg_1, &avg_5, &avg_15) < 3) {
retval = -ERANGE;
retval = -ERANGE;
}
setlocale(LC_NUMERIC, savelocale);
free(savelocale);

View File

@ -11,7 +11,7 @@ extern long page_bytes; /* this architecture's bytes per page */
extern int uptime (double *uptime_secs, double *idle_secs);
extern unsigned long getbtime(void);
int loadavg(double *av1, double *av5, double *av15);
int procps_loadavg(double *av1, double *av5, double *av15);
long procps_hertz_get(void);
long procps_cpu_count(void);

View File

@ -131,7 +131,7 @@ PROCPS_EXPORT char *procps_uptime_sprint(void)
pos += sprintf(upbuf + pos, "%d min, ", uphours, upminutes);
users = count_users();
loadavg(&av1, &av5, &av15);
procps_loadavg(&av1, &av5, &av15);
pos += sprintf(upbuf + pos, "%2d user%s, load average: %.2f, %.2f, %.2f",
users, users == 1 ? "" : "s",

View File

@ -24,8 +24,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "proc/version.h"
#include "proc/sysinfo.h"
#include <proc/sysinfo.h>
#include "c.h"
#include "fileutils.h"
#include "nls.h"
@ -167,7 +166,7 @@ int main(int argc, char **argv)
if (scale_fact < max_scale)
scale_fact *= 2.0; /* help it drift back up. */
loadavg(&av[0], &av[1], &av[2]);
procps_loadavg(&av[0], &av[1], &av[2]);
do {
lines = av[0] * scale_fact;