Skip to content

Instantly share code, notes, and snippets.

@schlady
Created October 31, 2016 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schlady/ef094b530f5228e41970dde46c34b794 to your computer and use it in GitHub Desktop.
Save schlady/ef094b530f5228e41970dde46c34b794 to your computer and use it in GitHub Desktop.
Autogenerated vnstat status page
#!/bin/sh
set -e
IFACES=$(ls /var/lib/vnstat/)
TARGET=/var/www/vnstat/
for iface in $IFACES; do
/usr/bin/vnstati -i ${iface} -h -o ${TARGET}/${iface}_hourly.png
/usr/bin/vnstati -i ${iface} -d -o ${TARGET}/${iface}_daily.png
/usr/bin/vnstati -i ${iface} -m -o ${TARGET}/${iface}_monthly.png
/usr/bin/vnstati -i ${iface} -t -o ${TARGET}/${iface}_top10.png
/usr/bin/vnstati -i ${iface} -s -o ${TARGET}/${iface}_summary.png
done
cat > ${TARGET}/index.html <<EOT
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-language" content="en">
<title>Network Traffic</title>
</head>
<body style="white-space: nowrap">
EOT
for iface in $IFACES; do
sed s/IFACE/${iface}/g >> ${TARGET}/index.html <<EOT
<div style="display:inline-block;vertical-align: top">
<img src="IFACE_summary.png" alt="traffic summary" /><br>
<img src="IFACE_monthly.png" alt="traffic per month" /><br>
<img src="IFACE_hourly.png" alt="traffic per hour" /><br>
<img src="IFACE_top10.png" alt="traffic top10" /><br>
<img src="IFACE_daily.png" alt="traffic per day" />
</div>
EOT
done
echo "</body></html>" >> ${TARGET}/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment