diff options
author | root <root@frank.tg14.gathering.org> | 2014-04-18 04:20:39 +0200 |
---|---|---|
committer | root <root@frank.tg14.gathering.org> | 2014-04-18 04:20:39 +0200 |
commit | 28573ab4d756872d884e49649c9afed57bc8a093 (patch) | |
tree | 41eb29d82c1703f00a83f4df52420c1fed34863d /munin/total_network_traffic.pl | |
parent | b8938643faba3636510729e70c1018fd516cbfb7 (diff) |
Turn off edit by default.
Diffstat (limited to 'munin/total_network_traffic.pl')
-rwxr-xr-x | munin/total_network_traffic.pl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/munin/total_network_traffic.pl b/munin/total_network_traffic.pl new file mode 100755 index 0000000..eebcba0 --- /dev/null +++ b/munin/total_network_traffic.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl -I/root/tgmanage/include +use strict; +use warnings; +use lib 'include'; +use nms; +use Data::Dumper::Simple; + +my $dbh = nms::db_connect(); +$dbh->{AutoCommit} = 0; + +my $total_traffic = $dbh->prepare("select sum(bytes_in) * 8 / 1048576.0 / 1024.0 as traffic_in, sum(bytes_out) * 8 / 1048576.0 / 1024.0 as traffic_out from get_current_datarate() natural join switches where switchtype like 'dlink3100%' and port < 45") + or die "Can't prepare query: $!"; + +$total_traffic->execute; +print <<EOF; +graph_title Total network traffic +graph_vlabel Gb/s +graph_scale no +EOF +my $ref = $total_traffic->fetchrow_hashref; +print "total_network_traffic_in.label Total incoming traffic\n"; +print "total_network_traffic_in.value ". $ref->{'traffic_in'}."\n"; +print "total_network_traffic_out.label Total outgoing traffic\n"; +print "total_network_traffic_out.value ". $ref->{'traffic_out'}."\n"; +$total_traffic->finish; +$dbh->disconnect(); +exit 0; |