ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/os_info.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/os_info.c (file contents):
Revision 1.23 by tdb, Sat Sep 24 13:29:22 2005 UTC vs.
Revision 1.25 by tdb, Sun Oct 3 18:35:58 2010 UTC

# Line 53 | Line 53
53   #include <sys/pstat.h>
54   #include <time.h>
55   #endif
56 + #ifdef AIX
57 + #include <utmp.h>
58 + #include <libperfstat.h>
59 + #endif
60   #ifdef WIN32
61   #include <windows.h>
62   #include "win32.h"
# Line 197 | Line 201 | sg_host_info *sg_get_host_info()
201          char *tmp_name;
202          char tmp[10];
203   #endif
204 + #ifdef AIX
205 +        static perfstat_cpu_total_t cpu_total;
206 +        struct utmp *ut;
207 + #endif
208  
209   #ifndef WIN32 /* Trust windows to be different */
210          if((uname(&os)) < 0){
# Line 324 | Line 332 | sg_host_info *sg_get_host_info()
332          }
333          if((ksp=kstat_lookup(kc, "unix", -1, "system_misc"))==NULL){
334                  sg_set_error(SG_ERROR_KSTAT_LOOKUP, "unix,-1,system_misc");
335 +                kstat_close(kc);
336                  return NULL;
337          }
338          if (kstat_read(kc, ksp, 0) == -1) {
339                  sg_set_error(SG_ERROR_KSTAT_READ, NULL);
340 +                kstat_close(kc);
341                  return NULL;
342          }
343          if((kn=kstat_data_lookup(ksp, "boot_time")) == NULL){
344                  sg_set_error(SG_ERROR_KSTAT_DATA_LOOKUP, "boot_time");
345 +                kstat_close(kc);
346                  return NULL;
347          }
348          boottime=(kn->value.ui32);
# Line 370 | Line 381 | sg_host_info *sg_get_host_info()
381                  return NULL;
382          }
383          general_stat.uptime = (time_t) result;
384 + #endif
385 + #ifdef AIX
386 +        if(perfstat_cpu_total(NULL, &cpu_total, sizeof(cpu_total), 1) != 1) {
387 +                sg_set_error_with_errno(SG_ERROR_SYSCTL, "perfstat_cpu_total");
388 +                return NULL;
389 +        }
390 +        general_stat.platform = cpu_total.description;
391 +
392 +        while( ut = getutent() ) {
393 +                if( ut->ut_type == BOOT_TIME ) {
394 +                        general_stat.uptime = time(NULL) - ut->ut_time;
395 +                        break;
396 +                }
397 +        }
398 +
399   #endif
400  
401          return &general_stat;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines