This is simple vnstats html with cron I’m using here: http://gotux.net/stats If you would like to do similar setup, you can follow this instructions.
# pacman -S vnstat # vnstat -u -i venet0 # nano /etc/rc.conf (and add "vnstat" to your DEAMONS="")
Prepare Nginx and Directory
Add this following function to your /etc/nginx/nginx.conf file:
server {
server_name stats.domain.com;
root /var/www/stats;
index index.html;
} #stats
Create Directory and Initial Images
mkdir /var/www/stats
You can use this basic css stylesheet:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
*,html { margin:0; padding:0; } body { color: #555; background-color: #d5d5d5; font: 1em Georgia, serif; } a { text-decoration: none; color: #356aa0; } a:hover { text-decoration: underline; } #page { width: 517px; margin: 25px auto; } #page h3 { float: right; font-size: 1em; } #page h4 { font-size: 0.90em; } #page p { padding-top: 5px; } #main { overflow: hidden; padding: 7px; background-color: #e5e5e5; border: 1px solid #f5f5f5; } |
Then create this basic index.html file:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<html> <head> <title> stats | domain.com </title> <meta name="robots" content="noindex,nofollow" /> <meta name="description" content="description" /> <meta name="keywords" content="key, words" /> <link rel="stylesheet" type="text/css" media="all" href="style.css" /> </head> <body> <div id="page"> <div id="main"> <h3> stats.<a href="http://domain.com/">domain.com</a> </h3> <p> <h4> summary stats </h4> <img src="summary.png" alt="summary" /> </p> <p> <h4> hourly stats </h4> <img src="hourly.png" alt="hourly" /> </p> <p> <h4> daily stats </h4> <img src="daily.png" alt="daily" /> </p> <p> <h4> monthly stats </h4> <img src="monthly.png" alt="monthly" /> </p> <p> <h4> top10 stats </h4> <img src="top10.png" alt="top10" /> </p> </div> <!--#main--> </div> <!--#page--> </body> </html> |
Run this command to create initial images:
vnstati -s -nh -i venet0 -o /var/www/stats/summary.png vnstati -h -nh -i venet0 -o /var/www/stats/hourly.png vnstati -d -nh -i venet0 -o /var/www/stats/daily.png vnstati -m -nh -i venet0 -o /var/www/stats/monthly.png vnstati -t -nh -i venet0 -o /var/www/stats/top10.png
Configure Cron
As regular user add this following line in your .bashrc file:
export EDITOR=nano
Then execute command “crontab -e” and add this lines:
@hourly vnstati -s -nh -i venet0 -o /var/www/stats/summary.png @hourly vnstati -h -nh -i venet0 -o /var/www/stats/hourly.png @hourly vnstati -d -nh -i venet0 -o /var/www/stats/daily.png @hourly vnstati -m -nh -i venet0 -o /var/www/stats/monthly.png @hourly vnstati -t -nh -i venet0 -o /var/www/stats/top10.png
This will automatically update your stats images hourly.
If you don’t have cron installed you can do this:
# pacman -S cronie # systemctl start cronie
Interface Notes:
eth0, wired network interface. (Dedi)
venet0, wired network interface. (VPS)
wlan0, wireless network interface. (Wireless)
Note if you’re using new systemd on Arch Linux, you’re interfaces will be named differently please check your interface by running “ip addr” command.
You can see how this graphs will look at http://gotux.net/stats/