Date: Thu, 9 Sep 1999 10:11:03 -0500 From: Dan Nelson <dnelson@emsphone.com> To: Jason Welsh <jawelsh@cisco.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: proc and uptime on freebsd Message-ID: <19990909101103.A56366@dan.emsphone.com> In-Reply-To: <37D7B8F6.1FA8EC1A@cisco.com> References: <37D7B8F6.1FA8EC1A@cisco.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990909101103.A56366>
