This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new 9167cd3b722 server: use /prod/stat to get uptime instead of the uptime
command (#11670)
9167cd3b722 is described below
commit 9167cd3b72253cb509b19804f3e740b90b41a7af
Author: Vishesh <[email protected]>
AuthorDate: Fri Sep 19 17:38:12 2025 +0530
server: use /prod/stat to get uptime instead of the uptime command (#11670)
---
server/src/main/java/com/cloud/server/StatsCollector.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java
b/server/src/main/java/com/cloud/server/StatsCollector.java
index a32dac398a8..4e1e78f1610 100644
--- a/server/src/main/java/com/cloud/server/StatsCollector.java
+++ b/server/src/main/java/com/cloud/server/StatsCollector.java
@@ -937,12 +937,12 @@ public class StatsCollector extends ManagerBase
implements ComponentMethodInterc
logger.info(String.format("used memory from /proc: %d",
newEntry.getSystemMemoryUsed()));
}
try {
- 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);
Date date = formatter.parse(bootTime);
newEntry.setSystemBootTime(date);
} catch (ParseException e) {
- logger.error("can not retrieve system uptime");
+ logger.error("can not retrieve system uptime", e);
}
String maxuse = Script.runSimpleBashScript(String.format("ps -o
vsz= %d", newEntry.getPid()));
newEntry.setSystemMemoryVirtualSize(Long.parseLong(maxuse) * 1024);