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

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

# Line 53 | Line 53
53   #include <uvm/uvm.h>
54   #include <unistd.h>
55   #endif
56 + #ifdef HPUX
57 + #include <sys/param.h>
58 + #include <sys/pstat.h>
59 + #include <unistd.h>
60 + #endif
61  
62   sg_swap_stats *sg_get_swap_stats(){
63  
64          static sg_swap_stats swap_stat;
65  
66 + #ifdef HPUX
67 +        struct pst_swapinfo pstat_swapinfo;
68 +        int swapidx = 0;
69 + #endif
70   #ifdef SOLARIS
71          struct anoninfo ai;
72          int pagesize;
# Line 82 | Line 91 | sg_swap_stats *sg_get_swap_stats(){
91          struct uvmexp *uvm;
92   #endif
93  
94 + #ifdef HPUX
95 +        swap_stat.total = 0;
96 +        swap_stat.used = 0;
97 +        swap_stat.free = 0;
98 +
99 +        /* The 128 here is arbitrary, it can be increased at the expense
100 +           of more system calls to pstat(). */
101 +        for (swapidx = 0; swapidx < 128; swapidx++) {
102 +                if (pstat_getswap(&pstat_swapinfo, sizeof(pstat_swapinfo), 1, swapidx) == -1) {
103 +                        break;
104 +                }
105 +
106 +                if (pstat_swapinfo.pss_idx != swapidx) {
107 +                        continue;
108 +                }
109 +
110 +                if ((pstat_swapinfo.pss_flags & SW_ENABLED) != SW_ENABLED) {
111 +                        continue;
112 +                }
113 +
114 +                if ((pstat_swapinfo.pss_flags & SW_BLOCK) == SW_BLOCK) {
115 +                        swap_stat.total += ((long long) pstat_swapinfo.pss_nblksavail) * 1024LL;
116 +                        swap_stat.used += ((long long) pstat_swapinfo.pss_nfpgs) * 1024LL;
117 +                        swap_stat.free = swap_stat.total - swap_stat.used;
118 +                }
119 +                if ((pstat_swapinfo.pss_flags & SW_FS) == SW_FS) {
120 +                        swap_stat.total += ((long long) pstat_swapinfo.pss_limit) * 1024LL;
121 +                        swap_stat.used += ((long long) pstat_swapinfo.pss_allocated) * 1024LL;
122 +                        swap_stat.free = swap_stat.total - swap_stat.used;
123 +                }
124 +        }
125 + #endif
126   #ifdef SOLARIS
127          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
128                  sg_set_error_with_errno(SG_ERROR_SYSCONF, "_SC_PAGESIZE");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines