Added "health-print-time" option.

This commit is contained in:
XMRig 2019-11-01 04:08:52 +07:00
parent 1cb4d73fe3
commit 26ed6254dc
11 changed files with 78 additions and 12 deletions

View file

@ -84,11 +84,13 @@ OpenCL backend:
CUDA backend: CUDA backend:
--cuda enable CUDA mining backend --cuda enable CUDA mining backend
--cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so) --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)
--no-nvml disable NVML (NVIDIA Management Library) support
Logging: Logging:
-S, --syslog use system log for output messages -S, --syslog use system log for output messages
-l, --log-file=FILE log all output to a file -l, --log-file=FILE log all output to a file
--print-time=N print hashrate report every N seconds --print-time=N print hashrate report every N seconds
--health-print-time=N print health report every N seconds
--no-color disable colored output --no-color disable colored output
Misc: Misc:

View file

@ -452,6 +452,13 @@ void xmrig::CudaBackend::stop()
void xmrig::CudaBackend::tick(uint64_t ticks) void xmrig::CudaBackend::tick(uint64_t ticks)
{ {
d_ptr->workers.tick(ticks); d_ptr->workers.tick(ticks);
# ifdef XMRIG_FEATURE_NVML
auto seconds = d_ptr->controller->config()->healthPrintTime();
if (seconds && ticks && (ticks % (seconds * 2)) == 0) {
d_ptr->printHealth();
}
# endif
} }

View file

@ -135,7 +135,9 @@ public:
CudaAffinityKey = 1205, CudaAffinityKey = 1205,
CudaMaxUsageKey = 1206, CudaMaxUsageKey = 1206,
CudaKey = 1207, CudaKey = 1207,
CudaLoaderKey = 1208 CudaLoaderKey = 1208,
NvmlKey = 1209,
HealthPrintTimeKey = 1210,
}; };
virtual ~IConfig() = default; virtual ~IConfig() = default;

View file

@ -41,6 +41,9 @@
"cuda": { "cuda": {
"enabled": false, "enabled": false,
"loader": null, "loader": null,
"nvml": true,
"cn/0": false,
"cn-lite/0": false
}, },
"donate-level": 5, "donate-level": 5,
"donate-over-proxy": 1, "donate-over-proxy": 1,
@ -63,6 +66,7 @@
} }
], ],
"print-time": 60, "print-time": 60,
"health-print-time": 60,
"retries": 5, "retries": 5,
"retry-pause": 5, "retry-pause": 5,
"syslog": false, "syslog": false,

View file

@ -494,7 +494,8 @@ void xmrig::Miner::onTimer(const Timer *)
d_ptr->maxHashrate[d_ptr->algorithm] = std::max(d_ptr->maxHashrate[d_ptr->algorithm], maxHashrate); d_ptr->maxHashrate[d_ptr->algorithm] = std::max(d_ptr->maxHashrate[d_ptr->algorithm], maxHashrate);
if ((d_ptr->ticks % (d_ptr->controller->config()->printTime() * 2)) == 0) { auto seconds = d_ptr->controller->config()->printTime();
if (seconds && (d_ptr->ticks % (seconds * 2)) == 0) {
printHashrate(false); printHashrate(false);
} }

View file

@ -70,6 +70,11 @@ static const char *kCuda = "cuda";
#endif #endif
#if defined(XMRIG_FEATURE_NVML)
static const char *kHealthPrintTime = "health-print-time";
#endif
class ConfigPrivate class ConfigPrivate
{ {
public: public:
@ -86,6 +91,10 @@ public:
# ifdef XMRIG_FEATURE_CUDA # ifdef XMRIG_FEATURE_CUDA
CudaConfig cuda; CudaConfig cuda;
# endif # endif
# if defined(XMRIG_FEATURE_NVML)
uint32_t healthPrintTime = 60;
# endif
}; };
} }
@ -133,6 +142,14 @@ const xmrig::RxConfig &xmrig::Config::rx() const
#endif #endif
#if defined(XMRIG_FEATURE_NVML)
uint32_t xmrig::Config::healthPrintTime() const
{
return d_ptr->healthPrintTime;
}
#endif
bool xmrig::Config::isShouldSave() const bool xmrig::Config::isShouldSave() const
{ {
if (!isAutoSave()) { if (!isAutoSave()) {
@ -177,6 +194,10 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
d_ptr->cuda.read(reader.getValue(kCuda)); d_ptr->cuda.read(reader.getValue(kCuda));
# endif # endif
# ifdef XMRIG_FEATURE_NVML
d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime);
# endif
return true; return true;
} }
@ -213,14 +234,17 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator); doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator);
# endif # endif
doc.AddMember("donate-level", m_pools.donateLevel(), allocator); doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator); doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
doc.AddMember("log-file", m_logFile.toJSON(), allocator); doc.AddMember("log-file", m_logFile.toJSON(), allocator);
doc.AddMember("pools", m_pools.toJSON(doc), allocator); doc.AddMember("pools", m_pools.toJSON(doc), allocator);
doc.AddMember("print-time", printTime(), allocator); doc.AddMember("print-time", printTime(), allocator);
doc.AddMember("retries", m_pools.retries(), allocator); # if defined(XMRIG_FEATURE_NVML)
doc.AddMember("retry-pause", m_pools.retryPause(), allocator); doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator);
doc.AddMember("syslog", isSyslog(), allocator); # endif
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator); doc.AddMember("retries", m_pools.retries(), allocator);
doc.AddMember("watch", m_watch, allocator); doc.AddMember("retry-pause", m_pools.retryPause(), allocator);
doc.AddMember("syslog", isSyslog(), allocator);
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
doc.AddMember("watch", m_watch, allocator);
} }

View file

@ -67,6 +67,10 @@ public:
const RxConfig &rx() const; const RxConfig &rx() const;
# endif # endif
# if defined(XMRIG_FEATURE_NVML)
uint32_t healthPrintTime() const;
# endif
bool isShouldSave() const; bool isShouldSave() const;
bool read(const IJsonReader &reader, const char *fileName) override; bool read(const IJsonReader &reader, const char *fileName) override;
void getJSON(rapidjson::Document &doc) const override; void getJSON(rapidjson::Document &doc) const override;

View file

@ -193,6 +193,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
return set(doc, kCuda, "loader", arg); return set(doc, kCuda, "loader", arg);
# endif # endif
# ifdef XMRIG_FEATURE_NVML
case IConfig::NvmlKey: /* --no-nvml */
return set(doc, kCuda, "nvml", false);
case IConfig::HealthPrintTimeKey: /* --health-print-time */
return set(doc, "health-print-time", static_cast<uint64_t>(strtol(arg, nullptr, 10)));
# endif
default: default:
break; break;
} }

View file

@ -75,6 +75,9 @@ R"===(
"cuda": { "cuda": {
"enabled": false, "enabled": false,
"loader": null, "loader": null,
"nvml": true,
"cn/0": false,
"cn-lite/0": false
}, },
"donate-level": 5, "donate-level": 5,
"donate-over-proxy": 1, "donate-over-proxy": 1,
@ -97,6 +100,7 @@ R"===(
} }
], ],
"print-time": 60, "print-time": 60,
"health-print-time": 60,
"retries": 5, "retries": 5,
"retry-pause": 5, "retry-pause": 5,
"syslog": false, "syslog": false,

View file

@ -107,6 +107,10 @@ static const option options[] = {
# ifdef XMRIG_FEATURE_CUDA # ifdef XMRIG_FEATURE_CUDA
{ "cuda", 0, nullptr, IConfig::CudaKey }, { "cuda", 0, nullptr, IConfig::CudaKey },
{ "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey }, { "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey },
# endif
# ifdef XMRIG_FEATURE_NVML
{ "no-nvml", 0, nullptr, IConfig::NvmlKey },
{ "health-print-time", 1, nullptr, IConfig::HealthPrintTimeKey },
# endif # endif
{ nullptr, 0, nullptr, 0 } { nullptr, 0, nullptr, 0 }
}; };

View file

@ -113,6 +113,9 @@ static inline const std::string &usage()
u += " --cuda enable CUDA mining backend\n"; u += " --cuda enable CUDA mining backend\n";
u += " --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n"; u += " --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n";
# endif # endif
# ifdef XMRIG_FEATURE_NVML
u += " --no-nvml disable NVML (NVIDIA Management Library) support\n";
# endif
u += "\nLogging:\n"; u += "\nLogging:\n";
@ -122,6 +125,9 @@ static inline const std::string &usage()
u += " -l, --log-file=FILE log all output to a file\n"; u += " -l, --log-file=FILE log all output to a file\n";
u += " --print-time=N print hashrate report every N seconds\n"; u += " --print-time=N print hashrate report every N seconds\n";
# ifdef XMRIG_FEATURE_NVML
u += " --health-print-time=N print health report every N seconds\n";
# endif
u += " --no-color disable colored output\n"; u += " --no-color disable colored output\n";
u += "\nMisc:\n"; u += "\nMisc:\n";