Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Hacked up graph for bandwidth monitoring gist
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["annotatedtimeline"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Time');
data.addColumn('number', 'Bytes/Second');
<?php
$row = 1;
if (($handle = fopen("/home/mwheeler/bandwidth.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if ($c==0){
$timestamp = $data[$c];
} else if ($c==2) {
$a = str_replace(" KB", "", $data[$c]);
if ($a>0) {
$speed = $a*1024;
}
}
if ($speed & $timestamp){
$speeds[$timestamp] = $speed ;
}
}
}
fclose($handle);
}
echo "data.addRows([";
$first = false;
foreach ($speeds as $k => $v) {
if ($first == false){
echo "[new Date(".$k."*1000),".$v."]\n";
$first = true;
}
else {
echo ",[new Date(".$k."*1000),".$v."]\n";
}
}
echo "]);\n";
?>
var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
chart.draw(data, {dateFormat: 'HH:mm MMMM dd, yyyy'});
}
</script>
</head>
<body>
<div id='chart_div' style='width: 1000px; height: 400px;'></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.