2018-01-17 12:55:36 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
2018-02-04 03:22:01 +01:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2018-01-17 12:55:36 +01:00
|
|
|
|
2018-04-03 02:03:05 +02:00
|
|
|
#include <RB_INC_SYS_RESOURCE_H
|
2018-08-23 10:09:11 +02:00
|
|
|
#include <RB_INC_UNISTD_H
|
2018-01-17 12:55:36 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
ircd::info::init()
|
2018-04-20 21:41:03 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::info::dump()
|
2018-01-17 12:55:36 +01:00
|
|
|
{
|
|
|
|
// This message flashes information about IRCd itself for this execution.
|
2018-01-21 11:09:13 +01:00
|
|
|
log::info
|
|
|
|
{
|
|
|
|
"%s %ld %s. configured: %s; compiled: %s; executed: %s; %s",
|
|
|
|
BRANDING_VERSION,
|
|
|
|
__cplusplus,
|
|
|
|
__VERSION__,
|
|
|
|
configured,
|
|
|
|
compiled,
|
|
|
|
startup,
|
|
|
|
RB_DEBUG_LEVEL? "(DEBUG MODE)" : ""
|
|
|
|
};
|
2018-01-17 12:55:36 +01:00
|
|
|
|
|
|
|
// This message flashes information about our dependencies which are being
|
|
|
|
// assumed for this execution.
|
2018-01-21 11:09:13 +01:00
|
|
|
log::info
|
|
|
|
{
|
2018-11-02 04:14:00 +01:00
|
|
|
"%s. glibc %s. boost %s. RocksDB %s. SpiderMonkey %s. sodium %s. %s. libmagic %d.",
|
2018-01-21 11:09:13 +01:00
|
|
|
PACKAGE_STRING,
|
2018-11-02 04:14:00 +01:00
|
|
|
glibc_version_str,
|
|
|
|
boost_version_str,
|
|
|
|
db::version_str,
|
2018-07-04 00:48:13 +02:00
|
|
|
js::version(js::ver::IMPLEMENTATION),
|
2018-01-21 11:09:13 +01:00
|
|
|
nacl::version(),
|
2018-02-18 06:26:47 +01:00
|
|
|
openssl::version(),
|
2018-02-19 07:50:37 +01:00
|
|
|
magic::version()
|
2018-01-21 11:09:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// This message flashes posix information about the system and platform IRCd
|
|
|
|
// is running on when ::uname() is available
|
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
"%s %s %s %s %s",
|
|
|
|
utsname.sysname,
|
|
|
|
utsname.nodename,
|
|
|
|
utsname.release,
|
|
|
|
utsname.version,
|
|
|
|
utsname.machine
|
|
|
|
};
|
|
|
|
#endif
|
2018-01-18 06:36:26 +01:00
|
|
|
|
2018-01-21 11:09:13 +01:00
|
|
|
// This message flashes standard information about the system and platform
|
|
|
|
// IRCd is compiled for and running on.
|
|
|
|
log::debug
|
|
|
|
{
|
2018-08-23 10:09:11 +02:00
|
|
|
"page_size=%zu max_align=%zu hw_conc=%zu d_inter=%zu c_inter=%zu",
|
|
|
|
page_size,
|
2018-01-21 11:09:13 +01:00
|
|
|
max_align,
|
|
|
|
hardware_concurrency,
|
|
|
|
destructive_interference,
|
2018-08-23 10:09:11 +02:00
|
|
|
constructive_interference,
|
2018-01-21 11:09:13 +01:00
|
|
|
};
|
2018-04-20 21:37:17 +02:00
|
|
|
|
|
|
|
// This message flashes posix information about the resource limits
|
|
|
|
log::debug
|
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
"AS=%lu DATA=%lu RSS=%lu NOFILE=%lu; RTTIME=%lu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu",
|
2018-04-20 21:37:17 +02:00
|
|
|
rlimit_as,
|
|
|
|
rlimit_data,
|
|
|
|
rlimit_rss,
|
2018-11-02 04:15:12 +01:00
|
|
|
rlimit_nofile,
|
2018-11-15 02:36:15 +01:00
|
|
|
rlimit_rttime,
|
2018-12-19 00:58:15 +01:00
|
|
|
iov_max,
|
|
|
|
aio_max,
|
2018-12-19 00:17:21 +01:00
|
|
|
aio_reqprio_max,
|
2018-04-20 21:37:17 +02:00
|
|
|
};
|
2018-01-17 12:55:36 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::credits)
|
|
|
|
ircd::info::credits
|
2018-02-19 22:32:34 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
"Inspired by the original Internet Relay Chat daemon from Jarkko Oikarinen",
|
|
|
|
" ",
|
|
|
|
"This - is The Construct",
|
|
|
|
" ",
|
|
|
|
"Internet Relay Chat daemon: Matrix Construct",
|
|
|
|
" ",
|
|
|
|
"Copyright (C) 2016-2018 Matrix Construct Developers, Authors & Contributors",
|
|
|
|
"Permission to use, copy, modify, and/or distribute this software for any",
|
|
|
|
"purpose with or without fee is hereby granted, provided that the above",
|
|
|
|
"copyright notice and this permission notice is present in all copies.",
|
|
|
|
" ",
|
|
|
|
nullptr
|
2018-02-19 22:32:34 +01:00
|
|
|
};
|
2018-01-17 12:55:36 +01:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
|
|
|
// Primary information
|
|
|
|
//
|
2018-02-19 23:03:05 +01:00
|
|
|
|
|
|
|
decltype(ircd::info::server_agent)
|
|
|
|
ircd::info::server_agent
|
|
|
|
{
|
|
|
|
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
|
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::user_agent)
|
|
|
|
ircd::info::user_agent
|
2018-04-03 01:50:51 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
|
2018-04-03 01:50:51 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::version)
|
|
|
|
ircd::info::version
|
2018-04-03 01:50:51 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
RB_VERSION
|
2018-04-03 01:50:51 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::name)
|
|
|
|
ircd::info::name
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
PACKAGE_NAME
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
extern "C" const char *const
|
|
|
|
ircd_version
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
RB_VERSION
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
extern "C" const char *const
|
|
|
|
ircd_name
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
PACKAGE_NAME
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
|
|
|
// Third party dependency information
|
|
|
|
//
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
/// Provides tcmalloc version information if tcmalloc is linked in to IRCd.
|
|
|
|
struct ircd::info::tc_version
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
int major{0}, minor{0};
|
|
|
|
char patch[64] {0};
|
|
|
|
std::string version {"unavailable"};
|
|
|
|
}
|
|
|
|
const ircd::info::tc_version;
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
/*
|
|
|
|
const char* tc_version(int* major, int* minor, const char** patch);
|
|
|
|
ircd::tc_version::tc_version()
|
|
|
|
:version{::tc_version(&major, &minor, reinterpret_cast<const char **>(&patch))}
|
|
|
|
{}
|
|
|
|
*/
|
2018-01-21 11:09:13 +01:00
|
|
|
|
2018-11-02 04:14:00 +01:00
|
|
|
decltype(ircd::info::glibc_version)
|
|
|
|
ircd::info::glibc_version
|
2018-06-09 22:42:35 +02:00
|
|
|
{
|
|
|
|
__GNU_LIBRARY__,
|
|
|
|
__GLIBC__,
|
|
|
|
__GLIBC_MINOR__,
|
|
|
|
};
|
|
|
|
|
2018-11-02 04:14:00 +01:00
|
|
|
char ircd_info_glibc_version_str_buf[32];
|
|
|
|
decltype(ircd::info::glibc_version_str)
|
|
|
|
ircd::info::glibc_version_str
|
|
|
|
(
|
|
|
|
ircd_info_glibc_version_str_buf,
|
|
|
|
::snprintf(ircd_info_glibc_version_str_buf, sizeof(ircd_info_glibc_version_str_buf),
|
|
|
|
"%d.%d.%d",
|
|
|
|
glibc_version[0],
|
|
|
|
glibc_version[1],
|
|
|
|
glibc_version[2])
|
|
|
|
);
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
|
|
|
// Host information
|
|
|
|
//
|
2018-11-29 01:53:59 +01:00
|
|
|
|
2018-01-21 11:09:13 +01:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
decltype(ircd::info::utsname)
|
|
|
|
ircd::info::utsname{[]
|
|
|
|
{
|
|
|
|
struct ::utsname utsname;
|
|
|
|
syscall(::uname, &utsname);
|
|
|
|
return utsname;
|
|
|
|
}()};
|
|
|
|
#endif
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
|
|
|
// System information
|
|
|
|
//
|
|
|
|
|
2018-04-03 02:03:05 +02:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
|
|
|
static uint64_t
|
|
|
|
_get_rlimit(const int &resource)
|
|
|
|
{
|
|
|
|
rlimit rlim;
|
2018-04-20 21:37:17 +02:00
|
|
|
ircd::syscall(getrlimit, resource, &rlim);
|
2018-04-03 02:03:05 +02:00
|
|
|
return rlim.rlim_cur;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static uint64_t
|
|
|
|
_get_rlimit(const int &resource)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::rlimit_rttime)
|
|
|
|
ircd::info::rlimit_rttime
|
2018-04-03 02:03:05 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef RLIMIT_RTTIME
|
|
|
|
_get_rlimit(RLIMIT_RTTIME)
|
|
|
|
#endif
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::rlimit_nofile)
|
|
|
|
ircd::info::rlimit_nofile
|
2018-04-03 02:03:05 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef RLIMIT_NOFILE
|
|
|
|
_get_rlimit(RLIMIT_NOFILE)
|
|
|
|
#endif
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::info::rlimit_rss)
|
|
|
|
ircd::info::rlimit_rss
|
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef RLIMIT_RSS
|
2018-04-03 02:03:05 +02:00
|
|
|
_get_rlimit(RLIMIT_RSS)
|
2018-12-19 21:23:38 +01:00
|
|
|
#endif
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::rlimit_data)
|
|
|
|
ircd::info::rlimit_data
|
2018-04-20 21:37:17 +02:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef RLIMIT_DATA
|
|
|
|
_get_rlimit(RLIMIT_DATA)
|
|
|
|
#endif
|
2018-04-20 21:37:17 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::rlimit_as)
|
|
|
|
ircd::info::rlimit_as
|
2018-11-15 02:36:15 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef RLIMIT_AS
|
|
|
|
_get_rlimit(RLIMIT_AS)
|
|
|
|
#endif
|
2018-11-15 02:36:15 +01:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::aio_reqprio_max)
|
|
|
|
ircd::info::aio_reqprio_max
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef _SC_AIO_PRIO_DELTA_MAX
|
|
|
|
size_t(syscall(::sysconf, _SC_AIO_PRIO_DELTA_MAX))
|
|
|
|
#endif
|
2018-01-21 11:09:13 +01:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::aio_max)
|
|
|
|
ircd::info::aio_max
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef _SC_AIO_MAX
|
|
|
|
0 //size_t(syscall(::sysconf, _SC_AIO_MAX))
|
|
|
|
#endif
|
2018-01-21 11:09:13 +01:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::iov_max)
|
|
|
|
ircd::info::iov_max
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef _SC_IOV_MAX
|
|
|
|
size_t(syscall(::sysconf, _SC_IOV_MAX))
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::info::page_size)
|
|
|
|
ircd::info::page_size
|
|
|
|
{
|
|
|
|
#ifdef _SC_PAGESIZE
|
|
|
|
size_t(syscall(::sysconf, _SC_PAGESIZE))
|
2018-01-21 11:09:13 +01:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::info::constructive_interference)
|
|
|
|
ircd::info::constructive_interference
|
|
|
|
{
|
|
|
|
#ifdef __cpp_lib_hardware_interference_size
|
|
|
|
std::hardware_constructive_interference_size
|
|
|
|
#else
|
|
|
|
0
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::destructive_interference)
|
|
|
|
ircd::info::destructive_interference
|
2018-02-19 22:32:34 +01:00
|
|
|
{
|
2018-12-19 21:23:38 +01:00
|
|
|
#ifdef __cpp_lib_hardware_interference_size
|
|
|
|
std::hardware_destructive_interference_size
|
2016-08-16 01:21:01 +02:00
|
|
|
#else
|
2018-12-19 21:23:38 +01:00
|
|
|
0
|
2016-11-29 16:23:38 +01:00
|
|
|
#endif
|
2018-12-19 21:23:38 +01:00
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::hardware_concurrency)
|
|
|
|
ircd::info::hardware_concurrency
|
|
|
|
{
|
|
|
|
std::thread::hardware_concurrency()
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::max_align)
|
|
|
|
ircd::info::max_align
|
|
|
|
{
|
|
|
|
alignof(std::max_align_t)
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
|
|
|
// Build information
|
|
|
|
//
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::startup)
|
|
|
|
ircd::info::startup
|
|
|
|
{
|
|
|
|
ctime(&startup_time)
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::compiled)
|
|
|
|
ircd::info::compiled
|
|
|
|
{
|
|
|
|
__TIMESTAMP__
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::configured)
|
|
|
|
ircd::info::configured
|
|
|
|
{
|
|
|
|
ctime(&configured_time)
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::startup_time)
|
|
|
|
ircd::info::startup_time
|
|
|
|
{
|
|
|
|
std::time(nullptr)
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::configured_time)
|
|
|
|
ircd::info::configured_time
|
|
|
|
{
|
|
|
|
RB_TIME_CONFIGURED
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::commit)
|
|
|
|
ircd::info::commit
|
|
|
|
{
|
|
|
|
RB_VERSION_COMMIT
|
|
|
|
};
|
2016-11-29 16:23:38 +01:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::branch)
|
|
|
|
ircd::info::branch
|
|
|
|
{
|
|
|
|
RB_VERSION_BRANCH
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::tag)
|
|
|
|
ircd::info::tag
|
|
|
|
{
|
|
|
|
RB_VERSION_TAG
|
|
|
|
};
|