Show monthly traffic in bottom status bar

shwetha17

Member
May 24, 2018
785
0
16
Hello everyone!

I'm thinking about showing the monthly traffic usage in the bottom status bar.
This code works just fine:

Code:
vnstat -m | grep "`LC_ALL=C date +"%b '%y"`" | awk '{print $9 $10}'
Is there any possibility to show that in the statusbar?
I already found the place in index.html, but since my html/php/js knowledge isn't that good, I've no idea where to add it.

A hint would be nice!
 

somus1735

Member
May 25, 2018
833
0
16
Something like this:
Code:
<td class="statuscell">
<div class="stval" id="servertime"></div>
</td> <!-- ^^existing -->
<?php $bw=shell_exec("vnstat -m | grep \"`LC_ALL=C date +\"%b '%y\"`\" | awk '{print $9 $10}'"); ?>
<td class="statuscell">
<div><center><?php print $bw; ?></center></div>
</td>
 

das329717

Member
May 25, 2018
928
0
16
Works like a charm!

This is what I've got now:

index.html (actually changed it to index.php)
Code:
<?php $bw=shell_exec("vnstat -m | grep \"`LC_ALL=C date +\"%b '%y\"`\" | awk '{print $9 $10}'"); ?>
<td>
<table id="st_traffic" class="statuscell" cellpadding="0" cellspacing="0">
<tr>
<td><div class="sthdr">Monthly traffic:</div></td><td><div class="stval"><?php print $bw; ?></div></td>
</tr>
</table>
</td>

Changes to styles.css:
Code:
#st_traffic .sthdr { padding-left: 8px }
#st_traffic .stval { text-align: center }

Thanks for the fast reply!