use /prod/stat to get uptime instead of the uptime command#11670
use /prod/stat to get uptime instead of the uptime command#11670weizhouapache merged 1 commit intoapache:4.20from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes compatibility issues with the uptime command on certain Linux distributions (specifically openSUSE) by replacing the uptime -s command with a more portable alternative that reads from /proc/stat to get the system boot time.
- Replaces
uptime -scommand with/proc/statparsing approach for better OS compatibility - Improves error logging by including the exception details
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
5ec8ade to
4be35a7
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@blueorangutan package |
|
@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #11670 +/- ##
=========================================
Coverage 16.17% 16.17%
- Complexity 13297 13298 +1
=========================================
Files 5656 5656
Lines 498151 498151
Branches 60441 60441
=========================================
+ Hits 80588 80589 +1
+ Misses 408591 408589 -2
- Partials 8972 8973 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15077 |
weizhouapache
left a comment
There was a problem hiding this comment.
code lgtm
tested on ubuntu 24 and rocky8, got same results as uptime -s
| String bootTime = Script.runSimpleBashScript("uptime -s"); | ||
| SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.ENGLISH); | ||
| String bootTime = Script.runSimpleBashScript("date -d @$(grep btime /proc/stat | awk '{print $2}') '+%Y-%m-%d %H:%M:%S'"); | ||
| SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); |
There was a problem hiding this comment.
yyyy-MM-dd HH:mm:ss is correct I think.
yyyy-MM-dd hh:mm:ss seems wrong, did it work in the past ?
There was a problem hiding this comment.
I tested locally and the old one seems to work fine as well. But as per java docs, it should be HH instead of hh.
|
@blueorangutan test |
|
@vishesh92 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
vladimirpetrov
left a comment
There was a problem hiding this comment.
LGTM based on manual testing.
shwstppr
left a comment
There was a problem hiding this comment.
code lgtm, checked command on local
|
Merging based on approvals and manual testing |
|
[SF] Trillian test result (tid-14383)
|
|
[SF] Trillian test result (tid-14382)
|
Description
This PR removes the usage of uptime command which fails on certain OS like open SUSE with the below error.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?