ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/libstatgrab/load_stat.c
Revision: 1.4
Committed: Mon May 13 16:43:51 2002 UTC (22 years, 6 months ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.3: +1 -1 lines
Log Message:
Fixed mis-spelling of "load15".

File Contents

# User Rev Content
1 pajs 1.1 #include <stdio.h>
2     #include <stdlib.h>
3     #include "ukcprog.h"
4    
5 tdb 1.2 char *get_load_stats(){
6 pajs 1.1
7     double loadav[3];
8     char *xml_load_out;
9     #ifdef OLDLINUX
10     FILE *f;
11     char *loadavg;
12     char *load_p;
13     #endif
14    
15     #ifdef OLDLINUX
16     if ((f=fopen("/proc/loadavg", "r" ))==NULL) {
17     errf("Failed to open load averages (%m)");
18     return NULL;
19     }
20    
21 pajs 1.3 if((fscanf(f,"%lf %lf %lf", &loadav[0], &loadav[1], &loadav[2])) != 3){
22     errf("Failed to read in sufficent loads");
23     return NULL;
24     }
25 pajs 1.1
26     if ((fclose(f)) != 0) {
27     errf("Failed to close file (%m).");
28     return NULL;
29     }
30     #else
31     if((getloadavg(loadav,3)) == -1){
32     errf("Failed to get load averages (%m)");
33     }
34     #endif
35    
36 tdb 1.4 xml_load_out=strf("<load><load1>%.2lf</load1><load5>%.2lf</load5><load15>%.2lf</load15></load>", loadav[0], loadav[1], loadav[2]);
37 pajs 1.1
38     return xml_load_out;
39     }