Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Sep 2001 15:52:40 +0400
From:      "Vladimir B. Grebenschikov" <vova@express.ru>
To:        Michael Sinz <msinz@wgate.com>
Cc:        FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
Subject:   Re: uptime and w utilities lie about real uptime
Message-ID:  <15273.55432.957586.417711@vbook.express.ru>
In-Reply-To: <402390ae04246407d1@[192.168.1.4]>
References:  <400de87e0423b007d1@[192.168.1.4]> <402390ae04246407d1@[192.168.1.4]>

next in thread | previous in thread | raw e-mail | index | archive | help
Michael Sinz writes:

 > >         if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
 > >             boottime.tv_sec != 0) {
 > >                 uptime = now - boottime.tv_sec;
 > >                 uptime += 30;
 > > ====================== ^^^^^
 > >                 days = uptime / 86400;
 > >                 uptime %= 86400;
 > >                 hrs = uptime / 3600;
 > >                 uptime %= 3600;
 > >                 mins = uptime / 60;
 > >                 secs = uptime % 60;
 > >                 (void)printf(" up");
 > > 
 > > why utility increases uptime on 30 seconds ??
 > > Is any real reasons for it ?
 > 
 > >From my reading of this, it seems to want to round the uptime to
 > the nearest minute -- afterall, w and uptime both only show the uptime
 > in minutes (well, days, hours, and minutes)

not exactly right:

...
DUMMYNET initialized (010124)
Waiting 2 seconds for SCSI devices to settle
SMP: AP CPU #1 Launched!
Mounting root from ufs:/dev/da0s2a
da0 at ahc0 bus 0 target 12 lun 0
da0: <IBM DNES-309170W SA30> Fixed Direct Access SCSI-3 device 
da0: 80.000MB/s transfers (40.000MHz, offset 31, 16bit), Tagged Queueing Enabled
da0: 8748MB (17916240 512 byte sectors: 255H 63S/T 1115C)
Enter full pathname of shell or RETURN for /bin/sh: 
# mount -a
# uptime
 3:12PM  up 42 secs, 3 users, load averages: 0.21, 0.05, 0.02
# 

42sec instead of more realistic 12sec
looking into w.c more:

                if (days > 0)
                        (void)printf(" %d day%s,", days, days > 1 ? "s" : "");
                if (hrs > 0 && mins > 0)
                        (void)printf(" %2d:%02d,", hrs, mins);
                else if (hrs > 0)
                        (void)printf(" %d hr%s,", hrs, hrs > 1 ? "s" : "");
                else if (mins > 0)
                        (void)printf(" %d min%s,", mins, mins > 1 ? "s" : "");
                else
                        (void)printf(" %d sec%s,", secs, secs > 1 ? "s" : "");
        }

--
TSB Russian Express, Moscow
Vladimir B. Grebenschikov, vova@express.ru

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15273.55432.957586.417711>