xmrig/src/Summary.cpp

191 lines
6.8 KiB
C++
Raw Normal View History

2017-06-07 22:16:45 +00:00
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
2017-06-07 22:16:45 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2017-07-18 19:38:38 +00:00
#include <inttypes.h>
2017-11-17 09:59:46 +00:00
#include <stdio.h>
2017-06-07 22:16:45 +00:00
#include <uv.h>
2018-04-20 11:54:58 +00:00
#include "common/log/Log.h"
#include "common/net/Pool.h"
#include "core/Config.h"
#include "core/Controller.h"
2017-06-07 22:16:45 +00:00
#include "Cpu.h"
2017-06-09 22:20:54 +00:00
#include "Mem.h"
2017-06-07 22:51:24 +00:00
#include "Summary.h"
2017-06-07 22:16:45 +00:00
#include "version.h"
static void print_versions(xmrig::Config *config)
2017-06-07 22:16:45 +00:00
{
char buf[16] = { 0 };
2017-06-07 22:16:45 +00:00
2017-06-14 17:37:59 +00:00
# if defined(__clang__)
snprintf(buf, 16, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
# elif defined(__GNUC__)
2017-06-07 22:16:45 +00:00
snprintf(buf, 16, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
2017-06-13 03:31:25 +00:00
# elif defined(_MSC_VER)
snprintf(buf, 16, " MSVC/%d", MSVC_VERSION);
2017-06-07 22:16:45 +00:00
# endif
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" libuv/%s%s")
: " * %-13s%s/%s libuv/%s%s",
"VERSIONS", APP_NAME, APP_VERSION, uv_version_string(), buf);
2017-06-07 22:16:45 +00:00
}
static void print_memory(xmrig::Config *config) {
2018-04-15 04:08:47 +00:00
# ifdef _WIN32
if (config->isColors()) {
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s",
"HUGE PAGES", Mem::isHugepagesAvailable() ? "\x1B[1;32mavailable" : "\x1B[01;31munavailable");
2017-06-09 22:20:54 +00:00
}
else {
Log::i()->text(" * %-13s%s", "HUGE PAGES", Mem::isHugepagesAvailable() ? "available" : "unavailable");
2017-06-09 22:20:54 +00:00
}
2018-04-15 04:08:47 +00:00
# endif
2017-06-09 22:20:54 +00:00
}
static void print_cpu(xmrig::Config *config)
2017-06-07 22:16:45 +00:00
{
if (config->isColors()) {
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s (%d) %sx64 %sAES-NI",
"CPU",
2017-06-20 10:04:38 +00:00
Cpu::brand(),
Cpu::sockets(),
Cpu::isX64() ? "\x1B[1;32m" : "\x1B[1;31m-",
Cpu::hasAES() ? "\x1B[1;32m" : "\x1B[1;31m-");
2017-06-07 22:16:45 +00:00
# ifndef XMRIG_NO_LIBCPUID
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%.1f MB/%.1f MB", "CPU L2/L3", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
2017-06-07 22:16:45 +00:00
# endif
}
else {
Log::i()->text(" * %-13s%s (%d) %sx64 %sAES-NI", "CPU", Cpu::brand(), Cpu::sockets(), Cpu::isX64() ? "" : "-", Cpu::hasAES() ? "" : "-");
2017-06-07 22:16:45 +00:00
# ifndef XMRIG_NO_LIBCPUID
Log::i()->text(" * %-13s%.1f MB/%.1f MB", "CPU L2/L3", Cpu::l2() / 1024.0, Cpu::l3() / 1024.0);
2017-06-07 22:16:45 +00:00
# endif
}
}
static void print_threads(xmrig::Config *config)
2017-06-08 23:47:46 +00:00
{
2018-04-19 04:54:11 +00:00
if (config->threadsMode() != xmrig::Config::Advanced) {
char buf[32] = { 0 };
2018-04-19 04:54:11 +00:00
if (config->affinity() != -1L) {
snprintf(buf, sizeof buf, ", affinity=0x%" PRIX64, config->affinity());
2018-04-19 04:54:11 +00:00
}
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, av=%d, %sdonate=%d%%") WHITE_BOLD("%s")
: " * %-13s%d, %s, av=%d, %sdonate=%d%%%s",
"THREADS",
2018-04-19 04:54:11 +00:00
config->threadsCount(),
2018-04-25 07:48:32 +00:00
config->algorithm().name(),
2018-04-19 04:54:11 +00:00
config->algoVariant(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[1;31m" : "",
2018-04-19 04:54:11 +00:00
config->donateLevel(),
buf);
2017-06-08 23:47:46 +00:00
}
else {
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %s, %sdonate=%d%%")
: " * %-13s%d, %s, %sdonate=%d%%",
"THREADS",
2018-04-19 04:54:11 +00:00
config->threadsCount(),
2018-04-25 07:48:32 +00:00
config->algorithm().name(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[1;31m" : "",
2018-04-19 04:54:11 +00:00
config->donateLevel());
2017-06-08 23:47:46 +00:00
}
2017-06-16 08:32:34 +00:00
}
static void print_pools(xmrig::Config *config)
2017-06-16 08:32:34 +00:00
{
2018-04-10 23:09:34 +00:00
const std::vector<Pool> &pools = config->pools();
2017-06-16 08:32:34 +00:00
2017-06-26 18:13:05 +00:00
for (size_t i = 0; i < pools.size(); ++i) {
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") CYAN_BOLD("%s") " variant " WHITE_BOLD("%s")
: " * POOL #%-7d%s variant %s",
2017-06-26 18:13:05 +00:00
i + 1,
pools[i].url(),
pools[i].algorithm().variantName()
2018-04-10 23:09:34 +00:00
);
2017-06-08 23:47:46 +00:00
}
2017-06-16 08:32:34 +00:00
2017-06-26 18:13:05 +00:00
# ifdef APP_DEBUG
2018-09-15 13:48:57 +00:00
LOG_NOTICE("POOLS --------------------------------------------------------------------");
for (const Pool &pool : pools) {
pool.print();
2017-06-26 18:13:05 +00:00
}
2018-09-15 13:48:57 +00:00
LOG_NOTICE("--------------------------------------------------------------------------");
2017-06-26 18:13:05 +00:00
# endif
2017-06-08 23:47:46 +00:00
}
2017-09-02 12:50:27 +00:00
#ifndef XMRIG_NO_API
static void print_api(xmrig::Config *config)
2017-09-02 12:50:27 +00:00
{
2018-03-31 10:51:33 +00:00
const int port = config->apiPort();
if (port == 0) {
2017-09-02 12:50:27 +00:00
return;
}
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d")
: " * %-13s%s:%d",
"API BIND", config->isApiIPv6() ? "[::]" : "0.0.0.0", port);
2017-09-02 12:50:27 +00:00
}
#endif
static void print_commands(xmrig::Config *config)
2017-07-23 07:04:23 +00:00
{
if (config->isColors()) {
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BOLD("h") WHITE_BOLD("ashrate, ")
MAGENTA_BOLD("p") WHITE_BOLD("ause, ")
MAGENTA_BOLD("r") WHITE_BOLD("esume"));
2017-07-23 07:04:23 +00:00
}
else {
Log::i()->text(" * COMMANDS 'h' hashrate, 'p' pause, 'r' resume");
2017-07-23 07:04:23 +00:00
}
}
void Summary::print(xmrig::Controller *controller)
2017-06-07 22:16:45 +00:00
{
print_versions(controller->config());
print_memory(controller->config());
print_cpu(controller->config());
print_threads(controller->config());
print_pools(controller->config());
2017-09-02 12:50:27 +00:00
# ifndef XMRIG_NO_API
print_api(controller->config());
2017-09-02 12:50:27 +00:00
# endif
print_commands(controller->config());
2017-06-07 22:16:45 +00:00
}