< prev index next >

src/hotspot/os/posix/os_posix.cpp

Print this page
rev 56978 : 8234397: add OS uptime information to os::print_os_info output

*** 45,54 **** --- 45,55 ---- #include <sys/mman.h> #include <sys/resource.h> #include <sys/utsname.h> #include <time.h> #include <unistd.h> + #include <utmpx.h> // Todo: provide a os::get_max_process_id() or similar. Number of processes // may have been configured, can be read more accurately from proc fs etc. #ifndef MAX_PID #define MAX_PID INT_MAX
*** 375,384 **** --- 376,406 ---- st->print(" Unavailable"); } st->cr(); } + // boot/uptime information; + // unfortunately it does not work on macOS because the utx chain has no entry + // for reboot at least on my test machines + void os::Posix::print_uptime_info(outputStream* st) { + int bootsec = -1; + int currsec = time(NULL); + struct utmpx* ent; + setutxent(); + while ((ent = getutxent())) { + if (!strcmp("system boot", ent->ut_line)) { + bootsec = ent->ut_tv.tv_sec; + break; + } + } + + if (bootsec != -1) { + st->print_cr("OS uptime (in days): %.2lf", (double) (currsec-bootsec)/(60*60*24)); + } + } + + void os::Posix::print_rlimit_info(outputStream* st) { st->print("rlimit:"); struct rlimit rlim; st->print(" STACK ");
< prev index next >