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

Diff of /monit/process/sysdep.c

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

revision 1.2 by hauk, Thu Aug 29 22:51:45 2002 UTC revision 1.3 by rory, Wed Sep 11 01:53:34 2002 UTC
# Line 62  Line 62 
62  #include <sys/param.h>  #include <sys/param.h>
63  #include <sys/proc.h>  #include <sys/proc.h>
64  #include <sys/resource.h>  #include <sys/resource.h>
65    #include <sys/resourcevar.h>
66    #include <sys/lock.h>
67    #include <sys/user.h>
68    #include <vm/vm.h>
69  #include <vm/vm_object.h>  #include <vm/vm_object.h>
70    #include <vm/pmap.h>
71    #include <machine/pmap.h>
72    #include <machine/vmparam.h>
73  #include <vm/vm_map.h>  #include <vm/vm_map.h>
74  #include <sys/vmmeter.h>  #include <sys/vmmeter.h>
75  #include <sys/sysctl.h>  #include <sys/sysctl.h>
 #include <vm/vm.h>  
76  #endif  #endif
77    
78  #ifdef LINUX  #ifdef LINUX
# Line 284  int get_process_info_sysdep(ProcInfo_T p Line 290  int get_process_info_sysdep(ProcInfo_T p
290  #ifdef FREEBSD  #ifdef FREEBSD
291    
292  #define pagetok(size) ((size) << pageshift)  #define pagetok(size) ((size) << pageshift)
293    #define tv2sec(tv) (((u_int64_t) tv.tv_sec * 1000000) + (u_int64_t) tv.tv_usec)
294    
295  static int pageshift;  static int pageshift;
296  static long mem_kbyte_max;  static long mem_kbyte_max;
# Line 294  static long mem_kbyte_max; Line 301  static long mem_kbyte_max;
301    
302  static kvm_t * kvm_handle;  static kvm_t * kvm_handle;
303    
304    static void calcru(struct proc *p, struct timeval *up, struct timeval *sp,
305                       struct timeval *ip)
306    {
307      quad_t totusec;
308      u_quad_t u, st, ut, it, tot;
309    #if (__FreeBSD_version < 300003)
310      long sec, usec;
311    #endif
312      
313      st = p->p_sticks;
314      ut = p->p_uticks;
315      it = p->p_iticks;
316      
317      tot = st + ut + it;
318      if (tot == 0)
319        {
320          st = 1;
321          tot = 1;
322        }
323      
324    #if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
325      totusec = (u_quad_t) p->p_runtime;
326    #else
327      sec = p->p_rtime.tv_usec;
328      usec = p->p_rtime.tv_usec;
329      
330      totusec = (quad_t)sec * 1000000 + usec;
331    #endif
332      
333      if(totusec < 0)
334        {
335          fprintf (stderr, "calcru: negative time: %ld usec\n",
336                   (long)totusec);
337          totusec = 0;
338        }
339      
340      u = totusec;
341      st = (u * st) / tot;
342      sp->tv_sec = st / 1000000;
343      sp->tv_usec = st % 1000000;
344      ut = (u * ut) / tot;
345      up->tv_sec = ut / 1000000;
346      up->tv_usec = ut % 1000000;
347      
348      if(ip != NULL)
349        {
350          it = (u * it) / tot;
351          ip->tv_sec = it / 1000000;
352          ip->tv_usec = it % 1000000;
353        }
354    }
355    
356  int init_process_info_sysdep(void) {  int init_process_info_sysdep(void) {
357    
358    register int pagesize;    register int pagesize;
359    struct vmmeter vmm;    struct vmmeter vmm;
360    
361    kvm_handle = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]);    struct nlist nlst [] = {
362        { "_bufspace"},
363        { "_cnt" },
364        { 0 }
365      };
366    
367    
368      kvm_handle = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
369    
370    if ( kvm_handle == NULL ) {    if ( kvm_handle == NULL ) {
371    
# Line 332  int init_process_info_sysdep(void) { Line 398  int init_process_info_sysdep(void) {
398    
399    }    }
400    
401    mem_kbyte_max= vmm.v_kernel_pages +    mem_kbyte_max= vmm.v_pageout_free_min +
402      vmm.v_free_count + vmm.v_wire_count +      vmm.v_free_count + vmm.v_wire_count +
403      vmm.v_active_count + vmm.v_inactive_count;      vmm.v_active_count + vmm.v_inactive_count;
404    
# Line 353  int get_process_info_sysdep(ProcInfo_T p Line 419  int get_process_info_sysdep(ProcInfo_T p
419    long stat_cutime;    long stat_cutime;
420    long stat_cstime;    long stat_cstime;
421    
   u_int64_t stat_rss;  
422    u_int64_t rss_lim;    u_int64_t rss_lim;
423    
424    int count;    int count;
# Line 370  int get_process_info_sysdep(ProcInfo_T p Line 435  int get_process_info_sysdep(ProcInfo_T p
435    
436    /* ----------------------------- CPU TIMING ----------------------------*/    /* ----------------------------- CPU TIMING ----------------------------*/
437    /* Got it from libgtop/sysdep/freebsd/proctime.c */    /* Got it from libgtop/sysdep/freebsd/proctime.c */
438      
439    if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&    if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
440        kvm_uread (kvm_handle, &(pinfo [0]).kp_proc,        kvm_uread (kvm_handle, &(pinfo [0]).kp_proc,
441                   (unsigned long) &u_addr->u_stats,                   (unsigned long) &u_addr->u_stats,
# Line 420  int get_process_info_sysdep(ProcInfo_T p Line 485  int get_process_info_sysdep(ProcInfo_T p
485    
486    }    }
487    
488    rss_rlim = (u_int64_t)    rss_lim = (u_int64_t)
489      (plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);      (plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);
490    
491    vms = &pinfo [0].kp_eproc.e_vm;    vms = &pinfo [0].kp_eproc.e_vm;

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