/[monit]/monit/process/sysdep_HPUX.c
ViewVC logotype

Diff of /monit/process/sysdep_HPUX.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by martinp, Tue Feb 11 21:27:40 2003 UTC revision 1.3 by chopp, Fri Jun 6 09:31:17 2003 UTC
# Line 63  Line 63 
63  #include "process.h"  #include "process.h"
64  #include "sysdep.h"  #include "sysdep.h"
65    
66    #define NPROCS 10000
67    static struct pst_status psall[NPROCS];
68    
69    static int page_size;
70    
71  /**  /**
72   *  System dependent resource gathering code for HP/UX.   *  System dependent resource gathering code for HP/UX.
73   *   *
# Line 74  Line 79 
79   *  @file   *  @file
80   */   */
81    
82    /*
83     * Helpful guide for implematation:
84     * "SunOS to HP-UX 9.05 Porting Guide" at
85     *    http://www.interex.org/tech/9000/Tech/sun_hpux_port/portguide.html
86     */
87    
88  int init_process_info_sysdep(void) {  int init_process_info_sysdep(void) {
89    struct pst_dynamic psd;    struct pst_dynamic psd;
90      struct pst_static pst;
91    
92    if (pstat_getdynamic(&psd,sizeof(psd),(size_t)1,0)!=-1) {    if (pstat_getdynamic(&psd,sizeof(psd),(size_t)1,0)!=-1) {
93    
# Line 87  int init_process_info_sysdep(void) { Line 99  int init_process_info_sysdep(void) {
99    
100    }    }
101    
102      if (pstat_getstatic(&pst, sizeof(pst), (size_t) 1, 0) != -1) {
103    
104        mem_kbyte_max=(long)(((double) pst.physical_memory) *
105                            ((double) pst.page_size) / 1024.0);
106        page_size=pst.page_size;
107    
108      } else {
109    
110        return FALSE;
111    
112      }
113    
114    return TRUE;    return TRUE;
115  }  }
116    
# Line 107  int get_process_info_sysdep(ProcInfo_T p Line 131  int get_process_info_sysdep(ProcInfo_T p
131    
132    p->cputime_prev = p->cputime;    p->cputime_prev = p->cputime;
133    p->cputime =  ( ps.pst_utime + ps.pst_stime ) * 10 / HZ;    p->cputime =  ( ps.pst_utime + ps.pst_stime ) * 10 / HZ;
134      p->mem_kbyte   = (long)(((double)ps.pst_rssize)/1024.0 * page_size);
135      p->mem_percent = (((double)p->mem_kbyte) * 1000.0 / ((double)mem_kbyte_max));
136    
137    if ( include_children ) {    if ( include_children ) {
138    
139      p->cputime += ( ps.pst_child_utime.pst_sec + ps.pst_child_stime.pst_sec ) * 10 / HZ;      p->cputime += ( ps.pst_child_utime.pst_sec + ps.pst_child_stime.pst_sec )
140          * 10 / HZ;
141    
142    }    }
143    
# Line 134  int get_process_info_sysdep(ProcInfo_T p Line 161  int get_process_info_sysdep(ProcInfo_T p
161    
162  }  }
163    
164  /*  /**
165   * getloadavg (ave, n)   * This routine returns 'na' double precision floats containing
166   *   * the load averages in 'a'; at most 3 values will be returned.
167   * This routine returns 'n' double precision floats containing   * @param loadv destination of the load averages
168   * the load averages in 'ave'; at most 3 values will be returned.   * @param nelem number of averages
169   *   * @return: 0 if successful, -1 if failed (and all load averages are 0).
  * Return value: 0 if successful, -1 if failed (and all load  
  * averages are returned as 0).  
170   */   */
171    int getloadavg_sysdep (double *a, int na) {
   
 int getloadavg (double *a, int na) {  
172        
173    struct pst_dynamic psd;    struct pst_dynamic psd;
174                    
# Line 174  int getloadavg (double *a, int na) { Line 197  int getloadavg (double *a, int na) {
197    
198    return TRUE;    return TRUE;
199  }  }
200    
201    /**
202     * Read all processes of the proc files system to initilize
203     * the process tree (sysdep version... but should work for
204     * all procfs based unices)
205     * @param reference  reference of ProcessTree
206     * @return treesize>0 if succeeded otherwise =0.
207     */
208    int initprocesstree_sysdep(ProcessTree_T ** reference) {
209    
210      int treesize;
211      int i;
212    
213      ProcessTree_T *  pt;
214    
215      ASSERT(reference);
216    
217      /* Gather process data */
218    
219      if ((treesize=pstat_getproc(psall,(size_t) NPROCS* sizeof(pst_status),(size_t) NPROCS, 0))==-1) {
220    
221        return 0;
222    
223      }
224    
225      /* Allocate the tree */
226    
227      pt = xcalloc(sizeof(ProcessTree_T), treesize);
228      memset( pt, 0, sizeof(ProcessTree_T)*globbuf.gl_pathc );
229    
230      /* Inspect data */
231    
232      for (i = 0; i < tree_size; pp++, i++) {
233    
234        pt[i]->pid = psall[i]->pst_pid;
235        pt[i]->ppid = psall[i]->pst_ppid;
236        p->mem_kbyte   = (long)(((double)psall[i]->pst_rssize)/1024.0 * page_size);
237        
238      }
239    
240      /* Return results */
241    
242      * reference = pt;
243    
244      return treesize;
245    
246    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26