Subject: top & uptime
To: None <current-users@netbsd.org>
From: Zafer Aydogan <zafer@gmx.org>
List: current-users
Date: 01/24/2005 11:22:41
Hello Mailing List,

Top currently shows only the time but not the uptime of the machine. I'd
appreciate to see the uptime in top. Unfortunately I'm not a coder, but
maybe something like this would work:

*
     * Print how long system has been up.
     * (Found by looking getting "boottime" from the kernel)
     */
    mib[0] = CTL_KERN;
    mib[1] = KERN_BOOTTIME;
    bt_size = sizeof(boottime);
    if (sysctl(mib, 2, &boottime, &bt_size, NULL, 0) != -1 &&
        boottime.tv_sec != 0) {
        si->boottime = boottime;
    } else {
        si->boottime.tv_sec = -1;
    }

Best Regards, Zafer.