Added per worker statistics in console.

This commit is contained in:
XMRig
2017-09-26 14:19:55 +03:00
parent 49592903ec
commit eb5cdbb3e7
9 changed files with 61 additions and 8 deletions

View File

@@ -206,8 +206,11 @@ else()
add_definitions(/DXMRIG_NO_GOOGLE_BREAKPAD)
endif()
find_package(MHD)
if (WITH_HTTPD AND MHD_FOUND)
if (WITH_HTTPD)
find_package(MHD)
endif()
if (MHD_FOUND)
include_directories(${MHD_INCLUDE_DIRS})
set(HTTPD_SOURCES src/api/Httpd.h src/api/Httpd.cpp)

View File

@@ -160,6 +160,11 @@ void App::onConsoleCommand(char command)
m_proxy->toggleDebug();
break;
case 'w':
case 'W':
m_proxy->printWorkers();
break;
case 3:
LOG_WARN("Ctrl+C received, exiting");
close();
@@ -194,7 +199,8 @@ void App::onSignal(uv_signal_t *handle, int signum)
break;
default:
break;
LOG_WARN("signal %d received, ignore", signum);
return;
}
m_self->close();

View File

@@ -35,6 +35,7 @@
void App::background()
{
signal(SIGPIPE, SIG_IGN);
if (!m_options->background()) {
return;

View File

@@ -134,14 +134,17 @@ void DonateStrategy::onClose(Client *client, int failures)
void DonateStrategy::onJobReceived(Client *client, const Job &job)
{
if (!isActive()) {
m_active = true;
m_listener->onActive(client);
}
m_listener->onJob(client, job);
}
void DonateStrategy::onLoginSuccess(Client *client)
{
m_active = true;
m_listener->onActive(client);
}

View File

@@ -111,7 +111,6 @@ void Miner::send(char *data)
LOG_DEBUG("[%s] send (%d bytes): \"%s\"", m_ip, strlen(data), data);
if (m_state != ReadyState || uv_is_writable(reinterpret_cast<uv_stream_t*>(&m_socket)) == 0) {
LOG_ERR("NOT WRITABLE");
free(data);
return;
}

View File

@@ -128,6 +128,12 @@ void Proxy::printHashrate()
}
void Proxy::printWorkers()
{
m_workers->printWorkers();
}
void Proxy::toggleDebug()
{
m_debug->toggle();
@@ -165,8 +171,8 @@ void Proxy::gc()
void Proxy::print()
{
LOG_INFO(Options::i()->colors() ? "\x1B[01;36m%03.1f KH/s\x1B[0m, shares: \x1B[01;37m%" PRIu64 "\x1B[0m/%s%" PRIu64 "\x1B[0m +%" PRIu64 ", upstreams: \x1B[01;37m%" PRIu64 "\x1B[0m, miners: \x1B[01;37m%" PRIu64 "\x1B[0m (max \x1B[01;37m%" PRIu64 "\x1B[0m) +%u/-%u"
: "%03.1f KH/s, shares: %" PRIu64 "/%s%" PRIu64 " +%" PRIu64 ", upstreams: %" PRIu64 ", miners: %" PRIu64 " (max %" PRIu64 " +%u/-%u",
LOG_INFO(Options::i()->colors() ? "\x1B[01;36m%03.1f KH/s\x1B[0m, shares: \x1B[01;37m%" PRIu64 "\x1B[0m/%s%" PRIu64 "\x1B[0m +%" PRIu64 ", upstreams: \x1B[01;37m%u\x1B[0m, miners: \x1B[01;37m%" PRIu64 "\x1B[0m (max \x1B[01;37m%" PRIu64 "\x1B[0m) +%u/-%u"
: "%03.1f KH/s, shares: %" PRIu64 "/%s%" PRIu64 " +%" PRIu64 ", upstreams: %u, miners: %" PRIu64 " (max %" PRIu64 " +%u/-%u",
m_stats.hashrate(60), m_stats.data().accepted, Options::i()->colors() ? (m_stats.data().rejected ? "\x1B[31m" : "\x1B[01;37m") : "", m_stats.data().rejected,
Counters::accepted, m_splitter->activeUpstreams(), Counters::miners(), Counters::maxMiners(), Counters::added(), Counters::removed());

View File

@@ -53,6 +53,7 @@ public:
void connect();
void printConnections();
void printHashrate();
void printWorkers();
void toggleDebug();
# ifdef APP_DEVEL

View File

@@ -22,7 +22,12 @@
*/
#include <inttypes.h>
#include "api/Api.h"
#include "log/Log.h"
#include "Options.h"
#include "proxy/events/AcceptEvent.h"
#include "proxy/events/CloseEvent.h"
#include "proxy/events/LoginEvent.h"
@@ -42,6 +47,34 @@ Workers::~Workers()
}
void Workers::printWorkers()
{
char workerName[24];
size_t size = 0;
Log::i()->text(Options::i()->colors() ? "\x1B[01;37m%-23s | %-15s | %-5s | %-8s | %-3s | %10s |" : "%-23s | %-15s | %-5s | %-8s | %-3s | %10s |",
"WORKER NAME", "LAST IP", "COUNT", "ACCEPTED", "REJ", "10 MIN");
for (const Worker &worker : m_workers) {
const char *name = worker.name();
size = strlen(name);
if (size > sizeof(workerName) - 1) {
memcpy(workerName, name, 6);
memcpy(workerName + 6, "...", 3);
memcpy(workerName + 9, name + size - sizeof(workerName) + 10, sizeof(workerName) - 10);
workerName[sizeof(workerName) - 1] = '\0';
}
else {
strncpy(workerName, name, sizeof(workerName) - 1);
}
Log::i()->text("%-23s | %-15s | %5" PRIu64 " | %8" PRIu64 " | %3" PRIu64 " | %5.1f KH/s |",
workerName, worker.ip(), worker.connections(), worker.accepted(), worker.rejected(), worker.hashrate(600));
}
}
void Workers::tick(uint64_t ticks)
{
if ((ticks % 4) != 0) {

View File

@@ -46,6 +46,7 @@ public:
Workers();
~Workers();
void printWorkers();
void tick(uint64_t ticks);
protected: