Hatena::ブログ(Diary)

Kernel Design Note このページをアンテナに追加 RSSフィード

2012-04-25

[][]os::print_os_info(outputStream* st)

-

//Linux版(jdk7/hotspot/src/os/linux/vm/os_linux.cpp)
void os::print_os_info(outputStream* st) {
  st->print("OS:");

  // Try to identify popular distros.
  // Most Linux distributions have /etc/XXX-release file, which contains
  // the OS version string. Some have more than one /etc/XXX-release file
  // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
  // so the order is important.
  if (!_print_ascii_file("/etc/mandrake-release", st) &&
      !_print_ascii_file("/etc/sun-release", st) &&
      !_print_ascii_file("/etc/redhat-release", st) &&
      !_print_ascii_file("/etc/SuSE-release", st) &&
      !_print_ascii_file("/etc/turbolinux-release", st) &&
      !_print_ascii_file("/etc/gentoo-release", st) &&
      !_print_ascii_file("/etc/debian_version", st) &&
      !_print_ascii_file("/etc/ltib-release", st) &&
      !_print_ascii_file("/etc/angstrom-version", st)) {
      st->print("Linux");
  }
  st->cr();

  // kernel
  st->print("uname:");
  struct utsname name;
  uname(&name);
  st->print(name.sysname); st->print(" ");
  st->print(name.release); st->print(" ");
  st->print(name.version); st->print(" ");
  st->print(name.machine);
  st->cr();

  // Print warning if unsafe chroot environment detected
  if (unsafe_chroot_detected) {
    st->print("WARNING!! ");
    st->print_cr(unstable_chroot_error);
  }

  // libc, pthread
  st->print("libc:");
  st->print(os::Linux::glibc_version()); st->print(" ");
  st->print(os::Linux::libpthread_version()); st->print(" ");
  if (os::Linux::is_LinuxThreads()) {
     st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
  }
  st->cr();

  // rlimit
  st->print("rlimit:");
  struct rlimit rlim;

  st->print(" STACK ");
  getrlimit(RLIMIT_STACK, &rlim);
  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
  else st->print("%uk", rlim.rlim_cur >> 10);

  st->print(", CORE ");
  getrlimit(RLIMIT_CORE, &rlim);
  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
  else st->print("%uk", rlim.rlim_cur >> 10);

  st->print(", NPROC ");
  getrlimit(RLIMIT_NPROC, &rlim);
  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
  else st->print("%d", rlim.rlim_cur);

  st->print(", NOFILE ");
  getrlimit(RLIMIT_NOFILE, &rlim);
  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
  else st->print("%d", rlim.rlim_cur);

  st->print(", AS ");
  getrlimit(RLIMIT_AS, &rlim);
  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
  else st->print("%uk", rlim.rlim_cur >> 10);
  st->cr();

  // load average
  st->print("load average:");
  double loadavg[3];
  os::loadavg(loadavg, 3);
  st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
  st->cr();

  // meminfo
  st->print("\n/proc/meminfo:\n");
  _print_ascii_file("/proc/meminfo", st);
  st->cr();
}
トラックバック - http://d.hatena.ne.jp/hira1978/20120425/1335316588