Created
July 1, 2014 21:23
-
-
Save breim/4f9b79fa3579dd5e1461 to your computer and use it in GitHub Desktop.
Bandwidth consumption on digital ocean with vnstat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// sudo apt-get install vnstat | |
// sudo vnstat -u -i eth0 | |
// sudo vnstat -i eth0 | |
$results = shell_exec("vnstat -m --oneline"); | |
$resultsArray = explode("\n", trim($results)); | |
$servidorArray = explode(";", $resultsArray[0]); | |
$data = $servidorArray[2]; | |
$download = $servidorArray[3]; | |
$upload = $servidorArray[4]; | |
echo $results; | |
echo "<br>"; | |
echo $data; | |
echo "<br>"; | |
echo $download; | |
echo "<br>"; | |
echo $upload; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment