aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/aggregated_traffic.pl
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
committerKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
commit0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch)
tree4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/aggregated_traffic.pl
parente4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff)
Bump lots of changes
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
+}