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

Comparing projects/libstatgrab/src/libstatgrab/cpu_stats.c (file contents):
Revision 1.24 by ats, Sun Jul 18 21:30:11 2004 UTC vs.
Revision 1.25 by tdb, Mon Nov 1 18:30:17 2004 UTC

# Line 50 | Line 50
50   #include <sys/sysctl.h>
51   #include <sys/dkstat.h>
52   #endif
53 + #ifdef HPUX
54 + #include <sys/param.h>
55 + #include <sys/pstat.h>
56 + #include <sys/dk.h>
57 + #endif
58  
59   static sg_cpu_stats cpu_now;
60   static int cpu_now_uninit=1;
61  
62   sg_cpu_stats *sg_get_cpu_stats(){
63  
64 + #ifdef HPUX
65 +        struct pst_dynamic pstat_dynamic;
66 +        int i;
67 + #endif
68   #ifdef SOLARIS
69          kstat_ctl_t *kc;
70          kstat_t *ksp;
# Line 81 | Line 90 | sg_cpu_stats *sg_get_cpu_stats(){
90          cpu_now.iowait=0;
91          cpu_now.kernel=0;
92          cpu_now.idle=0;
93 <        /* Not stored in linux or freebsd */
93 >        /* Not stored in linux, freebsd, or hpux */
94          cpu_now.swap=0;
95          cpu_now.total=0;
96          /* Not stored in solaris */
97          cpu_now.nice=0;
98  
99 + #ifdef HPUX
100 +        if (pstat_getdynamic(&pstat_dynamic, sizeof(pstat_dynamic), 1, 0) == -1) {
101 +                sg_set_error_with_errno(SG_ERROR_PSTAT, "pstat_dynamic");
102 +                return NULL;
103 +        }
104 +        cpu_now.user   = pstat_dynamic.psd_cpu_time[CP_USER];
105 +        cpu_now.iowait = pstat_dynamic.psd_cpu_time[CP_WAIT];
106 +        cpu_now.kernel = pstat_dynamic.psd_cpu_time[CP_SSYS] + pstat_dynamic.psd_cpu_time[CP_SYS];
107 +        cpu_now.idle   = pstat_dynamic.psd_cpu_time[CP_IDLE];
108 +        cpu_now.nice   = pstat_dynamic.psd_cpu_time[CP_NICE];
109 +        for (i = 0; i < PST_MAX_CPUSTATES; i++) {
110 +                cpu_now.total += pstat_dynamic.psd_cpu_time[i];
111 +        }
112 + #endif
113   #ifdef SOLARIS
114          if ((kc = kstat_open()) == NULL) {
115                  sg_set_error(SG_ERROR_KSTAT_OPEN, NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines