Added manual (e key) health reports.

This commit is contained in:
XMRig 2019-11-01 00:09:28 +07:00
parent f110b5000b
commit 1cb4d73fe3
9 changed files with 89 additions and 26 deletions

View file

@ -98,29 +98,12 @@ int xmrig::App::exec()
void xmrig::App::onConsoleCommand(char command)
{
switch (command) {
case 'h':
case 'H':
m_controller->miner()->printHashrate(true);
break;
case 'p':
case 'P':
m_controller->miner()->setEnabled(false);
break;
case 'r':
case 'R':
m_controller->miner()->setEnabled(true);
break;
case 3:
if (command == 3) {
LOG_WARN("Ctrl+C received, exiting");
close();
break;
default:
break;
}
else {
m_controller->miner()->execCommand(command);
}
}

View file

@ -126,9 +126,9 @@ static void print_threads(Config *config)
static void print_commands(Config *)
{
if (Log::colors) {
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BOLD("h") WHITE_BOLD("ashrate, ")
MAGENTA_BOLD("p") WHITE_BOLD("ause, ")
MAGENTA_BOLD("r") WHITE_BOLD("esume"));
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG(WHITE_BOLD_S "h") WHITE_BOLD("ashrate, ")
MAGENTA_BG(WHITE_BOLD_S "p") WHITE_BOLD("ause, ")
MAGENTA_BG(WHITE_BOLD_S "r") WHITE_BOLD("esume"));
}
else {
Log::print(" * COMMANDS 'h' hashrate, 'p' pause, 'r' resume");

View file

@ -53,6 +53,7 @@ public:
virtual const Hashrate *hashrate() const = 0;
virtual const String &profileName() const = 0;
virtual const String &type() const = 0;
virtual void execCommand(char command) = 0;
virtual void prepare(const Job &nextJob) = 0;
virtual void printHashrate(bool details) = 0;
virtual void setJob(const Job &job) = 0;

View file

@ -50,6 +50,8 @@ public:
~CpuBackend() override;
protected:
inline void execCommand(char) override {}
bool isEnabled() const override;
bool isEnabled(const Algorithm &algorithm) const override;
const Hashrate *hashrate() const override;

View file

@ -165,8 +165,11 @@ public:
if (NvmlLib::init(cuda.nvmlLoader())) {
NvmlLib::assign(devices);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s"), kNvmlLabel,
NvmlLib::version(), NvmlLib::driverVersion());
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s") " press " MAGENTA_BG(WHITE_BOLD_S "e") " for health report",
kNvmlLabel,
NvmlLib::version(),
NvmlLib::driverVersion()
);
}
else {
printDisabled(kLabel, RED_S " (failed to load NVML)");
@ -230,6 +233,38 @@ public:
}
# ifdef XMRIG_FEATURE_NVML
void printHealth()
{
for (const auto &device : devices) {
const auto health = NvmlLib::health(device.nvmlDevice());
std::string clocks;
if (health.clock && health.memClock) {
clocks += " " + std::to_string(health.clock) + "/" + std::to_string(health.memClock) + " MHz";
}
std::string fans;
if (!health.fanSpeed.empty()) {
for (uint32_t i = 0; i < health.fanSpeed.size(); ++i) {
fans += " fan" + std::to_string(i) + ":" CYAN_BOLD_S + std::to_string(health.fanSpeed[i]) + "%" CLEAR;
}
}
LOG_INFO(CYAN_BOLD("#%u") YELLOW(" %s") MAGENTA_BOLD("%4uW") CSI "1;%um %2uC" CLEAR WHITE_BOLD("%s") "%s",
device.index(),
device.topology().toString().data(),
health.power,
health.temperature < 60 ? 32 : (health.temperature > 85 ? 31 : 33),
health.temperature,
clocks.c_str(),
fans.c_str()
);
}
}
# endif
Algorithm algo;
Controller *controller;
CudaLaunchStatus status;
@ -300,6 +335,16 @@ const xmrig::String &xmrig::CudaBackend::type() const
}
void xmrig::CudaBackend::execCommand(char command)
{
# ifdef XMRIG_FEATURE_NVML
if (command == 'e' || command == 'E') {
d_ptr->printHealth();
}
# endif
}
void xmrig::CudaBackend::prepare(const Job &)
{
}

View file

@ -56,6 +56,7 @@ protected:
const Hashrate *hashrate() const override;
const String &profileName() const override;
const String &type() const override;
void execCommand(char command) override;
void prepare(const Job &nextJob) override;
void printHashrate(bool details) override;
void setJob(const Job &job) override;

View file

@ -51,6 +51,8 @@ public:
~OclBackend() override;
protected:
inline void execCommand(char) override {}
bool isEnabled() const override;
bool isEnabled(const Algorithm &algorithm) const override;
const Hashrate *hashrate() const override;

View file

@ -328,6 +328,34 @@ xmrig::Job xmrig::Miner::job() const
}
void xmrig::Miner::execCommand(char command)
{
switch (command) {
case 'h':
case 'H':
printHashrate(true);
break;
case 'p':
case 'P':
setEnabled(false);
break;
case 'r':
case 'R':
setEnabled(true);
break;
default:
break;
}
for (auto backend : d_ptr->backends) {
backend->execCommand(command);
}
}
void xmrig::Miner::pause()
{
d_ptr->active = false;

View file

@ -59,6 +59,7 @@ public:
const Algorithms &algorithms() const;
const std::vector<IBackend *> &backends() const;
Job job() const;
void execCommand(char command);
void pause();
void printHashrate(bool details);
void setEnabled(bool enabled);