-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Heath Raftery
committed
Nov 19, 2016
1 parent
4559345
commit 815f32a
Showing
5 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
# can add -v for verbose (see headers) | ||
|
||
curl -s --cookie "Authorization=Basic%20YWRtaW46MjEyMzJmMjk3YTU3YTVhNzQzODk0YTBlNGE4MDFmYzM%3D" "http://192.168.0.1/VXKQJFBBBVYUWYEA/userRpm/SystemStatisticRpm.htm?interval=5&autoRefresh=2&sortType=1&Num_per_page=20&Goto_page=1" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
datafile = 'liveplot.dat' | ||
stats datafile skip 1 nooutput | ||
set xrange [0:100] | ||
set autoscale y | ||
set xlabel "Time (s)" | ||
set ylabel "kB/s" | ||
plot for [IDX=2:STATS_columns] datafile using 1:IDX with lines t columnheader(IDX) | ||
pause 5 | ||
reread | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/opt/local/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Storable; | ||
|
||
my $TMP_FILE = 'liveplot.tmp'; | ||
my $DAT_FILE = 'liveplot.dat'; | ||
my $TIME_STEP = 5; | ||
|
||
|
||
#Retrieve the byte hash from last invocation | ||
my %oldBytes; | ||
%oldBytes = %{retrieve($TMP_FILE)} if -e $TMP_FILE; | ||
|
||
while(<>) | ||
{ | ||
last if $_ =~ /statList/; # don't do anything until we get to the statList array | ||
} | ||
|
||
my %bytes; | ||
|
||
while(<>) | ||
{ | ||
last if $_ =~ /;/; # finish at the end of the statList array | ||
#Otherwise, pasrse each row which has content: index, IP, MAC, packets, bytes, etc. | ||
my @fields = split /, /; | ||
# print "$fields[1]\t$fields[4]\n"; | ||
@bytes{substr $fields[1], 1, -1} = $fields[4]; | ||
} | ||
|
||
#print "\nMap\n"; | ||
#print "$_ $bytes{$_}\n" for (sort keys %bytes); | ||
|
||
#store for next invocation | ||
store \%bytes, $TMP_FILE; | ||
|
||
#calculate delta between old bytes and this bytes | ||
my %deltaBytes; | ||
for (keys %bytes) | ||
{ | ||
if(exists $oldBytes{$_}) | ||
{ | ||
$deltaBytes{$_} = ($bytes{$_} - $oldBytes{$_}) / (1024 * $TIME_STEP); | ||
} | ||
else | ||
{ | ||
$deltaBytes{$_} = $bytes{$_} / (1024 * $TIME_STEP); | ||
} | ||
} | ||
|
||
#print "\nDelta\n"; | ||
#print "$_ $deltaBytes{$_}\n" for (sort keys %deltaBytes); | ||
|
||
# Write or update the gnuplot dat file | ||
my $datf; # file handle | ||
my @dat; # file contents | ||
|
||
if(-e $DAT_FILE) | ||
{ | ||
open($datf, '<', $DAT_FILE); | ||
$dat[0] = [ split " ", <$datf> ]; # header contains all the ips | ||
shift @{ $dat[0] }; # get rid of the "time" column | ||
for(my $i = 1; <$datf>; $i++) | ||
{ | ||
$dat[$i] = [ split ]; | ||
shift @{ $dat[$i] }; # get rid of the "time" column | ||
} | ||
close($datf); | ||
} | ||
else # from existing dat file so start from scratch | ||
{ | ||
@dat[0] = [ sort keys %deltaBytes ]; | ||
} | ||
|
||
#insert the new data | ||
unshift @dat, $dat[0]; #make room at the start but preseve the header row | ||
$dat[1] = [ () ]; #blank new row | ||
|
||
for my $i ( 0 .. $#{$dat[0]} ) | ||
{ | ||
#print "pushing value ($deltaBytes{$dat[0][$i]}) for key ($dat[0][$i]).\n"; | ||
push @{ $dat[1] }, $deltaBytes{$dat[0][$i]}; | ||
} | ||
|
||
pop @dat if $#dat > 21; # limit to last 21 values + header row | ||
|
||
open $datf, '>', $DAT_FILE; | ||
|
||
for my $i ( 0 .. $#dat ) | ||
{ | ||
if($i == 0) | ||
{ | ||
print { $datf } "time(s) "; | ||
} | ||
else | ||
{ | ||
print { $datf } ($i-1)*$TIME_STEP . " "; | ||
} | ||
|
||
for my $j ( 0 .. $#{$dat[$i]} ) # oh Perl... | ||
{ | ||
print { $datf } "$dat[$i][$j] "; | ||
#print "$dat[$i][$j] "; | ||
} | ||
print { $datf } "\n"; | ||
#print "\n"; | ||
} | ||
|
||
close $datf; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
rm liveplot.dat | ||
rm liveplot.tmp | ||
|
||
echo "Initiasing data. Please wait 10 seconds..." | ||
|
||
./resetStats.sh > /dev/null | ||
sleep 5 | ||
|
||
getdata() | ||
{ | ||
while [ 1 ] | ||
do | ||
./getStats.sh | ./liveplot.pl | ||
# cat liveplot.dat | ||
sleep 5 | ||
done | ||
} | ||
|
||
getdata & | ||
# allow a couple of datapoints to arrive before plotting | ||
sleep 5 | ||
|
||
echo "Here comes the plot..." | ||
gnuplot liveplot.gnu | ||
|
||
# kill getdata when we exit | ||
kill -- -$$ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
# can add -v for verbose (see headers) | ||
|
||
curl -s --cookie "Authorization=Basic%20YWRtaW46MjEyMzJmMjk3YTU3YTVhNzQzODk0YTBlNGE4MDFmYzM%3D" "http://192.168.0.1/VXKQJFBBBVYUWYEA/userRpm/SystemStatisticRpm.htm?ResetAll=All&interval=5&autoRefresh=2&sortType=1&Num_per_page=20&Goto_page=1" | ||
|