Traffic statistics on VPS overview and proper error-catching for RAM and Disk statistics

feature/node-rewrite
Sven Slootweg 13 years ago
parent 23a7d117c0
commit c63b008055

@ -29,7 +29,7 @@ if(!empty($router->uParameters[2]))
}
}
$sPageContents = Templater::InlineRender("vps.overview", $locale->strings, array(
$sVariables = array(
'id' => $sContainer->sId,
'server-location' => $sContainer->sNode->sPhysicalLocation,
'operating-system' => $sContainer->sTemplate->sName,
@ -39,14 +39,50 @@ $sPageContents = Templater::InlineRender("vps.overview", $locale->strings, array
'total-traffic-limit' => "{$sContainer->sTotalTrafficLimit} bytes",
'bandwidth-limit' => "100mbit",
'status' => $sContainer->sStatusText,
'disk-used' => number_format($sContainer->sDiskUsed / 1024, 2),
'disk-total' => number_format($sContainer->sDiskTotal / 1024, 2),
'disk-percentage' => number_format(($sContainer->sDiskUsed / $sContainer->sDiskTotal) * 100, 2),
'disk-unit' => "GB",
'ram-used' => $sContainer->sRamUsed,
'ram-total' => $sContainer->sRamTotal,
'ram-percentage' => ($sContainer->sRamUsed / $sContainer->sRamTotal) * 100,
'ram-unit' => "MB"
'traffic-used' => number_format(($sContainer->sIncomingTrafficUsed + $sContainer->sOutgoingTrafficUsed) / 1024 / 1024 / 1024, 2),
'traffic-total' => number_format(($sContainer->sIncomingTrafficLimit + $sContainer->sOutgoingTrafficLimit) / 1024 / 1024 / 1024, 0),
'traffic-percentage' => number_format(($sContainer->sIncomingTrafficUsed + $sContainer->sOutgoingTrafficUsed) / ($sContainer->sIncomingTrafficLimit + $sContainer->sOutgoingTrafficLimit), 2),
'traffic-unit' => "GB"
);
));
try
{
$sVariables = array_merge($sVariables, array(
'disk-used' => number_format($sContainer->sDiskUsed / 1024, 2),
'disk-total' => number_format($sContainer->sDiskTotal / 1024, 2),
'disk-percentage' => number_format(($sContainer->sDiskUsed / $sContainer->sDiskTotal) * 100, 2),
'disk-unit' => "GB"
));
}
catch (SshExitException $e)
{
$sVariables = array_merge($sVariables, array(
'disk-used' => 0,
'disk-total' => 0,
'disk-percentage' => 0,
'disk-unit' => "GB"
));
}
try
{
$sVariables = array_merge($sVariables, array(
'ram-used' => $sContainer->sRamUsed,
'ram-total' => $sContainer->sRamTotal,
'ram-percentage' => ($sContainer->sRamUsed / $sContainer->sRamTotal) * 100,
'ram-unit' => "MB"
));
}
catch (SshExitException $e)
{
$sVariables = array_merge($sVariables, array(
'ram-used' => 0,
'ram-total' => 0,
'ram-percentage' => 0,
'ram-unit' => "MB"
));
}
$sPageContents = Templater::InlineRender("vps.overview", $locale->strings, $sVariables);
?>

@ -19,8 +19,8 @@
<div class="quota-item last">
<h3>Traffic</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: 8%;"></div>
<div class="quota-bar-label">80/1000GB</div>
<div class="quota-bar-inner" style="width: <%?traffic-percentage>%;"></div>
<div class="quota-bar-label"><%?traffic-used>/<%?traffic-total><%?traffic-unit></div>
</div>
</div>
<div class="clear"></div>
@ -68,11 +68,11 @@
</tr>
<tr>
<th>IPv4 Addresses</th>
<td>98.142.213.226, 204.12.235.84</td>
<td></td>
</tr>
<tr>
<th>IPv6 Addresses</th>
<td>2607:f7a0:1:1::24:6</td>
<td></td>
</tr>
<tr>
<th>Guaranteed RAM</th>

Loading…
Cancel
Save