mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-25 00:50:29 +00:00
Display bandwidth use total per day, week, month from vnstat.
Signed-off-by: D9ping <D9ping@users.noreply.github.com>
This commit is contained in:
parent
1ac167bf29
commit
d6d89df024
3 changed files with 132 additions and 1 deletions
120
includes/vnstat.php
Normal file
120
includes/vnstat.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
include_once( 'includes/status_messages.php' );
|
||||
|
||||
|
||||
/**
|
||||
* Generate html output for tab with vnstat traffic amount information.
|
||||
*/
|
||||
function DisplayVnstat()
|
||||
{
|
||||
$status = new StatusMessages();
|
||||
exec('vnstat -m ', $stdoutvnstatmonthly, $exitcodemonthly);
|
||||
if ($exitcodemonthly !== 0) {
|
||||
$status->addMessage(sprinf(_('Getting vnstat %s information failed.'), _('daily')), 'error');
|
||||
}
|
||||
|
||||
exec('vnstat -w ', $stdoutvnstatweekly, $exitcodeweekly);
|
||||
if ($exitcodeweekly !== 0) {
|
||||
$status->addMessage(sprinf(_('Getting vnstat %s information failed.'), _('weekly')), 'error');
|
||||
}
|
||||
|
||||
exec('vnstat -d ', $stdoutvnstatdaily, $exitcodedaily);
|
||||
if ($exitcodedaily !== 0) {
|
||||
$status->addMessage(sprinf(_('Getting vnstat %s information failed.'), _('monthly')),
|
||||
'error');
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading"><i class="fa fa-bar-chart fa-fw"></i> <?php echo _("Bandwidth monitoring"); ?></div>
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p><?php $status->showMessages(); ?></p>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active tabtrafficdaily"><a href="#daily" aria-controls="daily" role="tab" data-toggle="tab"><?php echo _("Daily"); ?></a></li>
|
||||
<li role="presentation" class="tabtrafficweekly"><a href="#weekly" aria-controls="weekly" role="tab" data-toggle="tab"><?php echo _("Weekly"); ?></a></li>
|
||||
<li role="presentation" class="tabtrafficmonthly"><a href="#monthly" aria-controls="monthly" role="tab" data-toggle="tab"><?php echo _("Monthly"); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tabcontenttraffic tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="daily">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<h4>Daily traffic amount</h4>
|
||||
<?php
|
||||
foreach ($stdoutvnstatdaily as &$linedaily) {
|
||||
if (empty($linedaily)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo ' <code>' , str_replace(' ', ' ', htmlentities($linedaily, ENT_QUOTES)) ,
|
||||
'</code><br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div role="tabpanel" class="tab-pane" id="weekly">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<h4><?php echo _("Weekly traffic amount"); ?></h4>
|
||||
<?php
|
||||
foreach ($stdoutvnstatweekly as &$lineweekly) {
|
||||
if (empty($lineweekly)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo ' <code>' , str_replace(' ', ' ', htmlentities($lineweekly, ENT_QUOTES)) ,
|
||||
'</code><br />', PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div role="tabpanel" class="tab-pane" id="monthly">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<h4><?php echo _("Monthly traffic amount"); ?></h4>
|
||||
<?php
|
||||
foreach ($stdoutvnstatmonthly as &$linemonthly) {
|
||||
if (empty($linemonthly)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo ' <code>' , str_replace(' ', ' ', htmlentities($linemonthly, ENT_QUOTES)) ,
|
||||
'</code><br />' , PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /.tabcontenttraffic -->
|
||||
|
||||
</div><!-- /.panel-default -->
|
||||
</div><!-- /.col-md-6 -->
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.panel-body -->
|
||||
|
||||
</div><!-- /.panel-primary -->
|
||||
<div class="panel-footer"><?php echo _("Information provided by vnstat"); ?></div>
|
||||
</div><!-- /.panel-primary -->
|
||||
</div><!-- /.col-lg-12 -->
|
||||
</div><!-- /.row -->
|
||||
<?php
|
||||
}
|
||||
|
11
index.php
11
index.php
|
@ -33,6 +33,7 @@ include_once( 'includes/system.php' );
|
|||
include_once( 'includes/configure_client.php' );
|
||||
include_once( 'includes/networking.php' );
|
||||
include_once( 'includes/themes.php' );
|
||||
include_once( 'includes/vnstat.php' );
|
||||
|
||||
$output = $return = 0;
|
||||
$page = $_GET['page'];
|
||||
|
@ -155,6 +156,13 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
|
|||
<a href="index.php?page=theme_conf"><i class="fa fa-wrench fa-fw"></i> <?php echo _("Change Theme"); ?></a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php //if ( RASPI_VNSTAT_ENABLED ) :
|
||||
?>
|
||||
<li>
|
||||
<a href="index.php?page=vnstat"><i class="fa fa-bar-chart fa-fw"></i> <?php echo _("Bandwidth"); ?></a>
|
||||
</li>
|
||||
<?php //endif;
|
||||
?>
|
||||
<li>
|
||||
<a href="index.php?page=system_info"><i class="fa fa-cube fa-fw"></i> <?php echo _("System"); ?></a>
|
||||
</li>
|
||||
|
@ -207,6 +215,9 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
|
|||
case "theme_conf":
|
||||
DisplayThemeConfig();
|
||||
break;
|
||||
case "vnstat":
|
||||
DisplayVnstat();
|
||||
break;
|
||||
case "system_info":
|
||||
DisplaySystem();
|
||||
break;
|
||||
|
|
|
@ -9,7 +9,7 @@ function update_system_packages() {
|
|||
|
||||
function install_dependencies() {
|
||||
install_log "Installing required packages"
|
||||
sudo apt-get install lighttpd $php_package git hostapd dnsmasq || install_error "Unable to install dependencies"
|
||||
sudo apt-get install lighttpd $php_package git hostapd dnsmasq vnstat || install_error "Unable to install dependencies"
|
||||
}
|
||||
|
||||
install_raspap
|
||||
|
|
Loading…
Reference in a new issue