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

Diff of /monit/process/sysdep_SOLARIS.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 48  Line 48 
48  #include <time.h>  #include <time.h>
49  #endif  #endif
50    
51    #ifdef HAVE_SYS_LOADAVG_H
52    #include <sys/loadavg.h>
53    #endif
54    
55  #ifdef HAVE_STRING_H  #ifdef HAVE_STRING_H
56  #include <string.h>  #include <string.h>
57  #endif  #endif
58    
59  #include <stdio.h>  #include <stdio.h>
60  #include <procfs.h>  #include <procfs.h>
61    #include <glob.h>
62    
63  #include "process.h"  #include "process.h"
64  #include "sysdep.h"  #include "sysdep.h"
65    
66  /**  /**
67   *  System dependent resource gathering code for SOLARIS.   *  System dependent resource gathering code for Solaris.
68   *   *
69   *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>   *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>
70   *  @author Christian Hopp <chopp@iei.tu-clausthal.de>   *  @author Christian Hopp <chopp@iei.tu-clausthal.de>
# Line 73  Line 78 
78  int init_process_info_sysdep(void) {  int init_process_info_sysdep(void) {
79    
80    num_cpus= sysconf( _SC_NPROCESSORS_ONLN);    num_cpus= sysconf( _SC_NPROCESSORS_ONLN);
81      mem_kbyte_max=(long)(((double)sysconf(_SC_PHYS_PAGES)) *
82                            ((double)sysconf(_SC_PAGESIZE)) / 1024.0);
83    
84    return (getuid()==0);    return (getuid()==0);
85    
# Line 103  int get_process_info_sysdep(ProcInfo_T p Line 110  int get_process_info_sysdep(ProcInfo_T p
110    
111    }    }
112    
113      p->ppid = pstatus->pr_ppid;
114    
115    if ( p->status_flag != PROCESS_ZOMBIE ) {    if ( p->status_flag != PROCESS_ZOMBIE ) {
116      /* We can't access /proc/$pid/status of a zombie */      /* We can't access /proc/$pid/status of a zombie */
# Line 146  int get_process_info_sysdep(ProcInfo_T p Line 154  int get_process_info_sysdep(ProcInfo_T p
154    return TRUE;    return TRUE;
155    
156  }  }
157    
158    
159    /**
160     * Read all processes of the proc files system to initilize
161     * the process tree (sysdep version... but should work for
162     * all procfs based unices)
163     * @param reference  reference of ProcessTree
164     * @return treesize>=0 if succeeded otherwise <0.
165     */
166    int initprocesstree_sysdep(ProcessTree_T ** reference) {
167    
168      int      pid;
169      int      i;
170      int      treesize;
171    
172      ProcessTree_T *  pt;
173    
174      glob_t   globbuf;
175    
176      ASSERT(reference);
177    
178      /* Find all processes in the /proc directory */
179    
180      if (glob("/proc/[0-9]*",  NULL , NULL, &globbuf) != 0 ) {
181    
182        return 0;
183    
184      }
185    
186      treesize = globbuf.gl_pathc;
187    
188      /* Allocate the tree */
189    
190      pt = xcalloc(sizeof(ProcessTree_T), treesize);
191      memset( pt, 0, sizeof(ProcessTree_T)*globbuf.gl_pathc );
192    
193      /* Insert data from /proc directory */
194    
195      for ( i = 0; i < treesize; i ++ ) {
196    
197        pid=atoi(globbuf.gl_pathv[i]+strlen("/proc/"));
198        
199        if (! getdatafromproc(pid, &pt[i] )) {
200    
201          continue;
202    
203        }
204    
205      }
206      
207      * reference = pt;
208    
209      /* Free globbing buffer */
210    
211      globfree(&globbuf);
212    
213      return treesize;
214    
215    }
216    
217    /**
218     * This routine returns 'nelem' double precision floats containing
219     * the load averages in 'loadv'; at most 3 values will be returned.
220     * @param loadv destination of the load averages
221     * @param nelem number of averages
222     * @return: 0 if successful, -1 if failed (and all load averages are 0).
223     */
224    int getloadavg_sysdep (double *loadv, int nelem) {
225    
226      return getloadavg(loadv, nelem);
227    
228    }

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