xmr-node-proxy
xmr-node-proxy copied to clipboard
Added a simple http+json server option for monitoring purposes
it's a little undercooked... but it works.
@Snipa22 did you try this? looks good to me, but im a noob!
Do you have a link to a demo of it in action, or at least some screenshots?
@mike-teehan @Ethorsen hello guys, sorry for the question .. is it required that I install apache and that I insert the file index.html inside the apache folder www ? Or the installation of apache is not necessary and I just place the file index.html inside the path: /home/nodeproxy/xmr-node-proxy/ ? . . EDIT: now I can see the index page, it was a port issue on my cloud server.
But there is a problem:
DataTables warning: table id=displaytable - Ajax error. For more information about this error, please see http://datatables.net/tn/7
@FranzDE if you want us to diagnose networking issues for you, you'll need to post some network info. Maybe a screenshot of the Network tab of Dev Tools after you've loaded the info page. Something.
Also, new branch, please update: https://github.com/mike-teehan/xmr-node-proxy/tree/monitor
@mike-teehan hi Mike, sorry it was my mistake.
do you think it is possible to make the miner remain on the list even when it is disconnected? A "connection" column would be useful, with the words: "1" (or more), "0" (for disconnected ones)
Like this page "proxy-stat.php" that works on "xmrig-proxy":
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Local Proxy Stat</title>
</head>
<body>
<?php
// ---------------------------
// Change PORT for you system:
// -------------------
$url="http://localhost:PORT/workers.json/endpoint";
// Check curl module installed and loaded
if (!extension_loaded('curl')) {
if (!dl('curl.so')) {
echo "<br><h1>CURL module not found!</h1><br>";
exit;
}
}
// Check json module installed and loaded
if (!extension_loaded('json')) {
if (!dl('json.so')) {
echo "<br><h1>JSON module not found!</h1><br>";
exit;
}
}
// get func from: http://php.net/manual/ru/function.json-decode.php
/**
* Clean comments of json content and decode it with json_decode().
* Work like the original php json_decode() function with the same params
*
* @param string $json The json string being decoded
* @param bool $assoc When TRUE, returned objects will be converted into associative arrays.
* @param integer $depth User specified recursion depth. (>=5.3)
* @param integer $options Bitmask of JSON decode options. (>=5.4)
* @return string
*/
function json_clean_decode($json, $assoc = false, $depth = 512, $options = 0) {
// search and remove comments like /* */ and //
$json = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|([\s\t](//).*)#", '', $json);
if(version_compare(phpversion(), '5.4.0', '>=')) {
$json = json_decode($json, $assoc, $depth, $options);
}
elseif(version_compare(phpversion(), '5.3.0', '>=')) {
$json = json_decode($json, $assoc, $depth);
}
else {
$json = json_decode($json, $assoc);
}
return $json;
}
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
// Will dump a beauty json :3
//var_dump(json_decode($result, true));
//$data = json_decode($result,true);
$data = json_clean_decode($result,true);
if (json_last_error() === JSON_ERROR_NONE) {
//do something with $json. It's ready to use
//echo "<br><h1>JSON Decode NOT ERROR</h1><br>";
?>
<table border="1" cellpadding="5">
<thead>
Total:
<tr>
<th>1 min HR</th>
<th>10 min HR</th>
<th>1 hour HR</th>
<th>12 hours HR</th>
<th>24 hours HR</th>
</tr>
</thead>
<tbody>
<?php
foreach( $data['hashrate'] as $hr) { ?>
<tr>
<?php foreach($hr as $key => $wrk) { ?>
<td><?php echo $wrk; ?> </td>
<?php
}
?></tr>
<?php
}
?>
</tbody>
<table border="1" cellpadding="5">
<thead>
Workers:
<tr>
<th>Worker Name</th>
<th>Last IP</th>
<th>Conn count</th>
<th>Accept shares</th>
<th>Upstream Rejected</th>
<th>Invalid shares</th>
<th>Total shares</th>
<th>Timestamp</th>
<th>1 min HR</th>
<th>10 min HR</th>
<th>1 hour HR</th>
<th>12 hours HR</th>
<th>24 hours HR</th>
</tr>
</thead>
<tbody>
<?php
foreach( $data['workers'] as $hr) { ?>
<tr>
<?php foreach($hr as $key => $wrk) { ?>
<td><?php echo $wrk; ?> </td>
<?php
}
?></tr>
<?php
}
} else {
//yep, it's not JSON. Log error or alert someone or do nothing
echo "<br><h1>JSON Decode ERROR</h1><br>";
}
?>
</tbody>
</body>
</html>
Preview:
Hi @mike-teehan @Snipa22 Can you add this feature that xmrigCC have? When the miners disconnect from CCserver, in the index.html(https://github.com/Bendr0id/xmrigCC/blob/master/index.html) it will throw a notification and says that IP or that workerID gone offline. I want to use something like this to notify me when a miner disconnect from XNP by email or notification ( I personally prefer email more reliable). Can you add this feature or help me do that? Thanks a lot for this fork its awesome BTW my miners IDs are in user field not in password field but I can work that. Just want the idea how to make XNP notify me by email when a miner disconnect just like pools like supportxmr.com or other node-js pools thanks
In the mean time of waiting Snipa merging this PR (he is very busy with works now). Anyone wants to try http / json to monitor workerID, you can use MoneroOcean fork here https://github.com/MoneroOcean/xmr-node-proxy
Tested and Worked very well.
@bobbieltd will it notify when a miner disconnects or will it save offline miners(name and IP and etc.)?
Email feature will be added to notify about miner disconnection (waiting for MO), still in discussion. Offline miners will be removed after a period of time ( it is trivial to add a time setting in config.json if you want ). But I guess email notification is still better than keeping dead worker in stats.
@bobbieltd Could you give a little guidance on what steps need to be taken to get output like yours? Thanks in advance.
@phubbard91 You don’t need any guidance. Install MoneroOcean XNP fork and change some parameters in config.json for http.