Copilot commented on code in PR #11670: URL: https://github.com/apache/cloudstack/pull/11670#discussion_r2358022782
########## server/src/main/java/com/cloud/server/StatsCollector.java: ########## @@ -937,12 +937,12 @@ private void getProcFileSystemData(@NotNull ManagementServerHostStatsEntry newEn 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); Review Comment: The command uses nested shell operations with command substitution that could be fragile. Consider adding error handling for cases where `/proc/stat` doesn't exist or `btime` is not found, or break this into separate commands with intermediate validation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org