Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous reported uptime when minutes is 0 #92

Open
masonr opened this issue Jul 5, 2024 · 0 comments
Open

Erroneous reported uptime when minutes is 0 #92

masonr opened this issue Jul 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@masonr
Copy link
Owner

masonr commented Jul 5, 2024

As reported by lukast__ at LowEndSpirit:

I just had a YABS with a weird uptime when the system is up X days, 0 hours and Y minutes:

# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
#              Yet-Another-Bench-Script              #
#                     v2024-06-09                    #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #

Fri Jul  5 07:15:24 PM CEST 2024

Basic System Information:
---------------------------------
Uptime     : 2 days, 37 hours, 0 minutes
Processor  : AMD EPYC 9754 128-Core Processor
CPU cores  : 6 @ 2595.124 MHz
AES-NI     : ✔ Enabled
VM-x/AMD-V : ✔ Enabled
RAM        : 15.6 GiB
Swap       : 1024.0 MiB
Disk       : 314.9 GiB
Distro     : Debian GNU/Linux 12 (bookworm)
Kernel     : 6.1.0-22-amd64
VM Type    : KVM
IPv4/IPv6  : ✔ Online / ✔ Online

The real uptime is "19:15:28 up 2 days, 37 min, 2 users, load average: 2.11, 1.46, 1.17", so it seems YABS is parsing it incorrectly. An easy fix would be to replace line 215 with:

UPTIME=$(uptime | awk -F'( |,|:)+' '{d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6; if ($9~/^min/) m=$8; else {h=$8;m=$9}} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')

But is there any reason you're not simply using uptime --pretty?

@masonr masonr added the bug Something isn't working label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant