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

View File

@ -452,6 +452,13 @@ void xmrig::CudaBackend::stop()
void xmrig::CudaBackend::tick(uint64_t 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,
CudaMaxUsageKey = 1206,
CudaKey = 1207,
CudaLoaderKey = 1208
CudaLoaderKey = 1208,
NvmlKey = 1209,
HealthPrintTimeKey = 1210,
};
virtual ~IConfig() = default;

View File

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

View File

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

View File

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

View File

@ -107,6 +107,10 @@ static const option options[] = {
# ifdef XMRIG_FEATURE_CUDA
{ "cuda", 0, nullptr, IConfig::CudaKey },
{ "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
{ 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-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n";
# endif
# ifdef XMRIG_FEATURE_NVML
u += " --no-nvml disable NVML (NVIDIA Management Library) support\n";
# endif
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 += " --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 += "\nMisc:\n";