summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2009-06-23 02:12:09 +0000
committerDimitri Sokolyuk <demon@dim13.org>2009-06-23 02:12:09 +0000
commit1efdae6693a269769922f27b4de2d3d1f2c5bbea (patch)
tree4c08f167eb45fae21c617beed14bb315ce9a414e
parentff395d75011b35e6e706ccca73f48d87ab0afdb5 (diff)
add nonlinear scaling
-rw-r--r--lavg/Makefile1
-rw-r--r--lavg/lavg.c10
2 files changed, 7 insertions, 4 deletions
diff --git a/lavg/Makefile b/lavg/Makefile
index 97cf984..d9fe06e 100644
--- a/lavg/Makefile
+++ b/lavg/Makefile
@@ -2,6 +2,7 @@
PROG= lavg
CFLAGS+= -Wall
+LDFLAGS+= -lm
NOMAN=
BINDIR= /var/www/cgi-bin
diff --git a/lavg/lavg.c b/lavg/lavg.c
index ca4513e..0887d9c 100644
--- a/lavg/lavg.c
+++ b/lavg/lavg.c
@@ -22,6 +22,7 @@ static const char rcsid[] = "$Id$";
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -57,10 +58,11 @@ ncpu(void)
int
main(void)
{
- double avg[3];
- int threshold, i, n;
+ double avg[3], threshold;
+ int i, n, cpu;
- threshold = ncpu();
+ cpu = ncpu();
+ threshold = log(cpu) + 1;
printf("Content-Type: text/html\n\n<html>\n");
@@ -74,7 +76,7 @@ main(void)
printf("<head>\n<title>load %.2f %s</title>\n</head>\n",
avg[0], status[n].name);
- printf("<body>\ncpu number: %d<br>\nload averages:", threshold);
+ printf("<body>\ncpu number: %d<br>\nload averages:", cpu);
for (i = 0; i < 3; i++) {
if (i > 0)
printf(",");