Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/src/main/java/com/cloud/server/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yyyy-MM-dd HH:mm:ss is correct I think.

yyyy-MM-dd hh:mm:ss seems wrong, did it work in the past ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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);
Expand Down
Loading