monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FreeBSD - HELP!


From: Christian Hopp
Subject: Re: FreeBSD - HELP!
Date: Tue, 10 Sep 2002 15:35:25 +0200 (CEST)

On Mon, 9 Sep 2002 address@hidden wrote:

> Not quite yet, however I believe if I get it fixed for one of the compile
> errors, it will be fixed for all. I'm going to work more on it tomorrow.
> Now, back to Monday Night Football.

The season has started this weekend, or?

Unfortunately here is another missing code part.  Its down there in
the mail.  The function culcru is used in part where the cpu time is
gathered.

I hope it helps...

Christian


---SNIP---
/* Found in libgtop-1.0.13/sysdeps/freebsd/proctime.c */

/* Taken from /usr/src/sys/kern/kern_resource.c */

/*
 * Transform the running time and tick information in proc p into user,
 * system, and interrupt time usage.
 */

static void calcru(struct proc *p, struct timeval *up, struct timeval *sp,
                   struct timeval *ip)
{
  quad_t totusec;
  u_quad_t u, st, ut, it, tot;
#if (__FreeBSD_version < 300003)
  long sec, usec;
#endif
  struct timeval tv;

  st = p->p_sticks;
  ut = p->p_uticks;
  it = p->p_iticks;

  tot = st + ut + it;
  if (tot == 0) {
    st = 1;
    tot = 1;
  }

#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)

  /* This was changed from a `struct timeval' into a `u_int64_t'
   * on FreeBSD 3.0 and renamed p_rtime -> p_runtime.
   */

  totusec = (u_quad_t) p->p_runtime;
#else
  sec = p->p_rtime.tv_sec;
  usec = p->p_rtime.tv_usec;

  totusec = (quad_t)sec * 1000000 + usec;
#endif

  if(totusec < 0) {
    /* XXX no %qd in kernel.  Truncate. */
    fprintf (stderr, "calcru: negative time: %ld usec\n",
             (long)totusec);
    totusec = 0;
  }


  u = totusec;
  st = (u * st) / tot;
  sp->tv_sec = st / 1000000;
  sp->tv_usec = st % 1000000;
  ut = (u * ut) / tot;
  up->tv_sec = ut / 1000000;
  up->tv_usec = ut % 1000000;

  if(ip != NULL) {
    it = (u * it) / tot;
    ip->tv_sec = it / 1000000;
    ip->tv_usec = it % 1000000;
  }
}
---SNAP---




-- 
Christian Hopp                                email: address@hidden
Institut für Elektrische Informationstechnik             fon: +49-5323-72-2113
Technische Universität Clausthal                         fax: +49-5323-72-3197
  pgpkey: https://www.iei.tu-clausthal.de/pgp-keys/chopp.key.asc  (2001-11-22)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]