[prev in list] [next in list] [prev in thread] [next in thread]
List: ipcop-svn
Subject: [Ipcop-svn] SF.net SVN: ipcop:[4899] ipcop/trunk
From: owes () users ! sourceforge ! net
Date: 2010-08-30 19:54:14
Message-ID: E1OqAQo-0000QK-2b () sfp-svn-6 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 4899
http://ipcop.svn.sourceforge.net/ipcop/?rev=4899&view=rev
Author: owes
Date: 2010-08-30 19:54:13 +0000 (Mon, 30 Aug 2010)
Log Message:
-----------
Add 'dissection' of vnstat output. Next step is adding information to a (new ?) DB
Modified Paths:
--------------
ipcop/trunk/src/scripts/aggregatetraffic.pl
ipcop/trunk/updates/1.9.16/ROOTFILES.i486-1.9.16
Modified: ipcop/trunk/src/scripts/aggregatetraffic.pl
===================================================================
--- ipcop/trunk/src/scripts/aggregatetraffic.pl 2010-08-30 15:40:12 UTC (rev 4898)
+++ ipcop/trunk/src/scripts/aggregatetraffic.pl 2010-08-30 19:54:13 UTC (rev 4899)
@@ -21,7 +21,7 @@
use DBI;
use strict;
-
+use XML::Simple;
#use warnings;
require '/usr/lib/ipcop/traffic-lib.pl';
@@ -36,12 +36,15 @@
my $detailed = 'off';
if ($TRAFFIC::settings{'DETAIL_LEVEL'} eq 'High') {
$detailed = 'on';
+ &aggregate_ulogd();
}
else {
- exit 0;
+ &aggregate_vnstat();
}
+sub aggregate_ulogd()
+{
# FIXME/TODO: as ulogd locks the database we have to stop it here and restart after \
aggregation # As long as ulogd is not running the traffic flow is not logged, we \
lose some data! system("/usr/bin/killall ulogd");
@@ -168,3 +171,33 @@
# FIXME/TODO: Restart ulogd
system("/usr/sbin/ulogd -d") if($TRAFFIC::settings{'ENABLED'} eq 'on');
+}
+
+
+sub aggregate_vnstat()
+{
+ unlink('/tmp/vnstat.xml');
+ system('/usr/bin/vnstat --xml > /tmp/vnstat.xml');
+
+ my $vnstat = eval { XMLin('/tmp/vnstat.xml') };
+ if ($@) {
+ # TODO: report error?
+ exit(1);
+ }
+
+ foreach my $data (@{$vnstat->{interface}}) {
+ # $data->{id}[0] is lan-1, wan-1, etc.
+ print $data->{id}[0]."\n" if ($debugLevel > 0);
+ my $day = 0;
+ while (exists($data->{traffic}->{days}->{day}->{$day})) {
+ my $dataday = $data->{traffic}->{days}->{day}->{$day};
+ # We now have a date and Rx,Tx in KiB
+ print "$dataday->{date}->{year}-$dataday->{date}->{month}-$dataday->{date}->{day} \
Rx: $dataday->{rx} KiB Tx: $dataday->{tx} KiB\n" if ($debugLevel > 0); + \
$day++; +
+ # TODO: store in some DB
+ }
+ }
+
+ unlink('/tmp/vnstat.xml');
+}
Modified: ipcop/trunk/updates/1.9.16/ROOTFILES.i486-1.9.16
===================================================================
--- ipcop/trunk/updates/1.9.16/ROOTFILES.i486-1.9.16 2010-08-30 15:40:12 UTC (rev \
4898)
+++ ipcop/trunk/updates/1.9.16/ROOTFILES.i486-1.9.16 2010-08-30 19:54:13 UTC (rev \
4899) @@ -1,4 +1,5 @@
## please place IPCop files first, then packages sorted by alphabetical order
/etc/rc.d/rc.red
+/usr/local/bin/aggregatetraffic.pl
/usr/share/locale/es_ES/LC_MESSAGES/install.mo
/usr/share/locale/es_ES/LC_MESSAGES/ipcop.mo
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic