mirror of
https://github.com/matrix-construct/construct
synced 2024-06-16 08:58:20 +02:00
ircd::info: Add sysinfo; gather ram and swap totals on init.
This commit is contained in:
parent
f438718ddf
commit
59ee170817
|
@ -936,6 +936,7 @@ RB_CHK_SYSHEADER(gnu/lib-names.h, [GNU_LIB_NAMES_H])
|
|||
|
||||
dnl linux platform
|
||||
RB_CHK_SYSHEADER(sys/auxv.h, [SYS_AUXV_H])
|
||||
RB_CHK_SYSHEADER(sys/sysinfo.h, [SYS_SYSINFO_H])
|
||||
RB_CHK_SYSHEADER(sys/eventfd.h, [SYS_EVENTFD_H])
|
||||
RB_CHK_SYSHEADER(sys/inotify.h, [SYS_INOTIFY_H])
|
||||
RB_CHK_SYSHEADER(sys/sysmacros.h, [SYS_SYSMACROS_H])
|
||||
|
|
|
@ -44,12 +44,14 @@ namespace ircd::info
|
|||
extern const string_view compiled;
|
||||
extern const string_view startup;
|
||||
|
||||
// System information
|
||||
// System configuration / information
|
||||
extern const size_t page_size;
|
||||
extern const size_t iov_max;
|
||||
extern const size_t aio_max;
|
||||
extern const size_t aio_reqprio_max;
|
||||
extern const size_t clk_tck;
|
||||
extern const size_t total_ram;
|
||||
extern const size_t total_swap;
|
||||
|
||||
// Resource limitations
|
||||
extern const size_t rlimit_as;
|
||||
|
|
51
ircd/info.cc
51
ircd/info.cc
|
@ -8,9 +8,10 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#include <RB_INC_SYS_RESOURCE_H
|
||||
#include <RB_INC_UNISTD_H
|
||||
#include <RB_INC_CPUID_H
|
||||
#include <RB_INC_SYS_SYSINFO_H
|
||||
#include <RB_INC_SYS_RESOURCE_H
|
||||
#include <RB_INC_GNU_LIBC_VERSION_H
|
||||
|
||||
namespace ircd::info
|
||||
|
@ -433,14 +434,17 @@ ircd::info::dump_sys_info()
|
|||
|
||||
// Additional detected system parameters
|
||||
#ifdef RB_DEBUG
|
||||
char buf[2][48];
|
||||
log::logf
|
||||
{
|
||||
log::star, log::DEBUG,
|
||||
"page_size=%zu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu",
|
||||
"page_size=%zu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu ram=%s swap=%s",
|
||||
page_size,
|
||||
iov_max,
|
||||
aio_max,
|
||||
aio_reqprio_max,
|
||||
pretty(buf[0], iec(total_ram)),
|
||||
pretty(buf[1], iec(total_swap)),
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
@ -509,7 +513,7 @@ ircd::info::kernel_version
|
|||
};
|
||||
|
||||
//
|
||||
// System information
|
||||
// Resource limits
|
||||
//
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
|
@ -576,6 +580,10 @@ ircd::info::rlimit_as
|
|||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// System configuration
|
||||
//
|
||||
|
||||
#ifdef _SC_CLK_TCK
|
||||
decltype(ircd::info::clk_tck)
|
||||
ircd::info::clk_tck
|
||||
|
@ -622,6 +630,43 @@ ircd::info::page_size
|
|||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// System information
|
||||
//
|
||||
|
||||
namespace ircd::info
|
||||
{
|
||||
#ifdef HAVE_SYS_SYSINFO_H
|
||||
extern struct ::sysinfo sysinfo;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_SYSINFO_H
|
||||
decltype(ircd::info::sysinfo)
|
||||
ircd::info::sysinfo{[]
|
||||
{
|
||||
struct ::sysinfo ret;
|
||||
syscall(::sysinfo, &ret);
|
||||
return ret;
|
||||
}()};
|
||||
#endif
|
||||
|
||||
decltype(ircd::info::total_ram)
|
||||
ircd::info::total_ram
|
||||
{
|
||||
#ifdef HAVE_SYS_SYSINFO_H
|
||||
sysinfo.totalram
|
||||
#endif
|
||||
};
|
||||
|
||||
decltype(ircd::info::total_swap)
|
||||
ircd::info::total_swap
|
||||
{
|
||||
#ifdef HAVE_SYS_SYSINFO_H
|
||||
sysinfo.totalswap
|
||||
#endif
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Userspace / Library
|
||||
|
|
Loading…
Reference in a new issue