Skip to content

Commit 4e00da7

Browse files
committed
Show node uptime
1 parent 1a0912a commit 4e00da7

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

src/Node.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ class Node {
77
public $pruMode;
88
public $chain;
99
public $client;
10-
public $ipv4;
11-
public $ipv6;
12-
public $tor;
10+
public $ipv4; // Bool: if ipv4 active
11+
public $ipv6; // Bool: if ipv6 active
12+
public $tor; // Bool: if tor active
1313
public $ipv4Address = 'Unknown';
1414
public $ipv6Address = 'Unknown';
1515
public $torAddress = 'Unknown';
16-
public $toConn;
16+
public $toConn; // Int: total connections of node
1717
public $cTime; // Current node time
18+
public $uptime; // String: uptime of node
1819
public $serivces;
1920
public $proVer;
2021
public $localRelay;
@@ -60,6 +61,7 @@ function __construct() {
6061
$blockchainInfo = $bitcoind->getblockchaininfo();
6162
$miningInfo = $bitcoind->getmininginfo();
6263
$tInfo = $bitcoind->getnettotals();
64+
$uptimeInfo = $bitcoind->uptime();
6365

6466
$this->blockHeight = checkInt($blockchainInfo["blocks"]);
6567
$this->pruMode = checkBool($blockchainInfo["pruned"]);
@@ -91,6 +93,7 @@ function __construct() {
9193
}
9294
}
9395
$this->toConn = checkInt($networkInfo["connections"]);
96+
$this->uptime = timeToString($uptimeInfo);
9497
$this->client = str_replace('/','',htmlspecialchars($networkInfo["subversion"]));
9598
$this->proVer = checkInt($networkInfo["protocolversion"]);
9699
$this->services = getServices($networkInfo["localservices"]);

src/Utility.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ function getDateTime($timestamp){
203203
return $date;
204204
}
205205

206+
function timeToString($time){
207+
$seconds = checkInt($time);
208+
switch (true) {
209+
case $seconds < 60:
210+
return $seconds . " seconds";
211+
case $seconds < 3600:
212+
return round($seconds/60) . " minutes";
213+
case $seconds < 86400:
214+
return round($seconds/3600) . " hours";
215+
default:
216+
return round($seconds/86400) . " days";
217+
}
218+
}
219+
206220
function checkMemPoolLimited($memPoolFee, $relayTxFee){
207221
$result = false;
208222
if($memPoolFee > $relayTxFee){
@@ -469,6 +483,7 @@ function createPeersGeo($peerinfo){
469483

470484
// Check if peer file exists and enabled
471485
if (file_exists('data/geodatapeers.inc')){
486+
print_r("geodatafile exists");
472487
// Loads serialized stored peers from disk
473488
$serializedPeers = file_get_contents('data/geodatapeers.inc');
474489
$arrayPeers = unserialize($serializedPeers);

views/main.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
<?php if(isset($content['node']->services['Network Limited'])){ ?><button type="button" class="btn btn-default btn-xs">Network Limited</button><?php } ?>
7373
<?php if(isset($content['node']->services['None'])){ ?><button type="button" class="btn btn-default btn-xs">None</button><?php } ?>
7474
<?php if(isset($content['node']->services['Unknown'])){ ?><button type="button" class="btn btn-default btn-xs">Unknown</button><?php } ?>
75-
</td></tr>
75+
</td></tr>
76+
<tr><td><i class="fa fa-clock-o fa-fw"></i> Uptime </td><td> <?= $content['node']->uptime ?></td></tr>
7677
<tr><td><i class="fa fa-clock-o fa-fw"></i> Node Time </td><td> <?= $content['node']->cTime ?></td></tr>
7778
<tr><td><i class="fa <?php echo ($content['node']->ipv4 ? "fa-check-square-o green" : "fa-square-o") ?> fa-fw"></i> IPv4 </td><td> <?php echo ($content['node']->ipv4 ? $content['node']->ipv4Address : "No") ?></td></tr>
7879
<tr><td><i class="fa <?php echo ($content['node']->ipv6 ? "fa-check-square-o green" : "fa-square-o") ?> fa-fw"></i> IPv6 </td><td> <?php echo ($content['node']->ipv6 ? $content['node']->ipv6Address : "No") ?></td></tr>
@@ -83,7 +84,7 @@
8384
<tr><td><i class="fa <?php echo (!$content['node']->tLimitSet ? "fa-square-o green" : "fa-check-square-o orange") ?> fa-fw"></i> Traffic Limit Set</td><td> <?php echo ($content['node']->tLimitSet ? "Yes" : "No") ?></td></tr>
8485
<?php if($content['node']->tLimitSet){ ?>
8586
<tr><td><i class="fa <?php echo (!$content['node']->tLimited ? "fa-square-o green" : "fa-warning red") ?> fa-fw"></i> Traffic Limited</td><td> <?php echo ($content['node']->tLimited ? "Yes" : "No") ?> <small>(<?= $content['node']->tUsed ?> / <?= $content['node']->tMax ?> MB - <?= $content['node']->tLimitP ?>%)</small></td></tr>
86-
<tr><td><i class="fa fa-clock-o fa-fw"></i> Time remaining </td><td> <?= $content['node']->tTimeLeft ?> min</td></tr>
87+
<tr><td><i class="fa fa-hourglass-start fa-fw"></i> Time remaining </td><td> <?= $content['node']->tTimeLeft ?> min</td></tr>
8788
<?php } ?>
8889
</table>
8990
</div>

0 commit comments

Comments
 (0)