From owner-freebsd-questions Thu Sep 9 8:11:24 1999 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 603F915C97 for ; Thu, 9 Sep 1999 08:11:18 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id KAA56895; Thu, 9 Sep 1999 10:11:03 -0500 (CDT) (envelope-from dan) Date: Thu, 9 Sep 1999 10:11:03 -0500 From: Dan Nelson To: Jason Welsh Cc: freebsd-questions@FreeBSD.ORG Subject: Re: proc and uptime on freebsd Message-ID: <19990909101103.A56366@dan.emsphone.com> References: <37D7B8F6.1FA8EC1A@cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre1i In-Reply-To: <37D7B8F6.1FA8EC1A@cisco.com> X-OS: FreeBSD 4.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Sep 09), Jason Welsh said: > im trying to help someone port an uptime daemon to Freebsd (since I > cant find any).. and hes asking about where to find system uptime in > /proc i know in linux, its easy, its just /proc/uptime but /proc > seems to be a totally different animal on freebsd. is there a file > that keeps uptime in /proc?? An uptime daemon? you mean rwhod? Rwhod calculates uptime by subtracting getboottime() from the current time. See /usr/src/usr.sbin/rwhod/rwhod.c for the real code. time_t getboottime(void) { int mib[2]; size_t size; struct timeval tm; mib[0] = CTL_KERN; mib[1] = KERN_BOOTTIME; size = sizeof(tm); if (sysctl(mib, 2, &tm, &size, NULL, 0) == -1) { syslog(LOG_ERR, "cannot get boottime: %m"); exit(1); } return tm.tv_sec; } -- Dan Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message