aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/aggregated_traffic.pl
diff options
context:
space:
mode:
Diffstat (limited to 'web/nms.gathering.org/aggregated_traffic.pl')
-rwxr-xr-xweb/nms.gathering.org/aggregated_traffic.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/web/nms.gathering.org/aggregated_traffic.pl b/web/nms.gathering.org/aggregated_traffic.pl
new file mode 100755
index 0000000..5c78e73
--- /dev/null
+++ b/web/nms.gathering.org/aggregated_traffic.pl
@@ -0,0 +1,25 @@
+#! /usr/bin/perl
+use strict;
+use DBI;
+use lib '../../include';
+use nms;
+use CGI;
+use File::Basename;
+my $cwd = dirname($0);
+my $dbh = nms::db_connect();
+
+my $cgi = CGI->new;
+
+print $cgi->header(-type=>'text/json', -expires=>'now');
+
+my $q = $dbh->prepare('select sum(n1.sum_in) as sum_in, sum(n1.sum_out) as sum_out from (select sum(ifInoctets) as sum_in, sum(ifOutoctets) as sum_out from polls2 where time >= now() - \'15 minutes\'::interval group by switch) as n1');
+$q->execute();
+while (my $ref = $q->fetchrow_hashref()) {
+ my $bitsface = $ref->{'sum_in'}/900/8;
+
+ print <<"EOF";
+{
+ "sum_in": "$bitsface"
+}
+EOF
+}