Re: uptime and w utilities lie about real uptime

2001-09-20 Thread Leo Bicknell


It's rounding to minutes when it shouldn't, uptime only displays
seconds for very short uptimes, and then always rounds to minutes.
Your patch causes it to truncate, which is probably the right
thing to do, the alternative would be:

if (uptime > 60) uptime += 30;

That way it won't start rounding until a full minute has passed, 
allowing the first 60 seconds to be displayed properly.  This has
less of a chance of breaking things depending on the rounding,
but I would hope ther are none of those.

-- 
Leo Bicknell - [EMAIL PROTECTED]
Systems Engineer - Internetworking Engineer - CCIE 3440
Read TMBG List - [EMAIL PROTECTED], www.tmbg.org

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: bin/30680: uptime and w utilities lie about real uptime

2001-09-20 Thread David Malone

On Thu, Sep 20, 2001 at 03:21:08PM +0400, Vladimir B.Grebenschikov wrote:
> why utility increases uptime on 30 seconds ??
> Is any real reasons for it ?

It adds 30 because it wants to round the number of minutes to the
nearest minute, instead of rounding down. Unfortunately this isn't
a sensible thing to do if you are also going to display the number
of seconds.

David.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: uptime and w utilities lie about real uptime

2001-09-20 Thread Vladimir B. Grebenschikov

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:  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, [EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: uptime and w utilities lie about real uptime

2001-09-20 Thread Michael Sinz

"Vladimir B.Grebenschikov" wrote:
> 
> >Submitter-Id:  current-users
> >Originator:Vladimir B. Grebenschikov
> >Organization:  TSB "Russian Express"
> >Confidential:  no
> >Synopsis:  uptime and w utilities lie about real uptime
> >Severity:  non-critical
> >Priority:  low
> >Category:  bin
> >Class: sw-bug
> >Release:   FreeBSD 5.0-CURRENT i386
> >Environment:
> System: FreeBSD vbook.express.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Sep 19 
>20:26:25 MSD 2001 [EMAIL PROTECTED]:/usr/src.local/sys/i386/compile/VBOOK i386
> 
> >Description:
> 
> Just after very fast boot uptimealways shows more than 30 sec.
> 
> looking to src/usr/bin/w/w.c:
> 
> 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)

-- 
Michael Sinz  Worldgate Communications  [EMAIL PROTECTED]
A master's secrets are only as good as
the master's ability to explain them to others.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



uptime and w utilities lie about real uptime

2001-09-20 Thread Vladimir B . Grebenschikov


>Submitter-Id:  current-users
>Originator:Vladimir B. Grebenschikov
>Organization:  TSB "Russian Express"
>Confidential:  no 
>Synopsis:      uptime and w utilities lie about real uptime
>Severity:  non-critical
>Priority:  low
>Category:  bin
>Class: sw-bug
>Release:   FreeBSD 5.0-CURRENT i386
>Environment:
System: FreeBSD vbook.express.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Sep 19 
20:26:25 MSD 2001 [EMAIL PROTECTED]:/usr/src.local/sys/i386/compile/VBOOK i386

>Description:

Just after very fast boot uptimealways shows more than 30 sec.

looking to src/usr/bin/w/w.c:

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 ?

>How-To-Repeat:
Boot and run uptime
>Fix:

--- src/usr.bin/w.c.origThu Sep 20 15:20:01 2001
+++ src/usr.bin/w.c Thu Sep 20 15:20:11 2001
@@ -450,7 +450,6 @@
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;

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message