Home
TrafMeter Web Online Help
TrafMeter
What is TrafMeter?
License Agreement
TrafMeter Editions
Registration Info
How To Contact Us
Description
System requirements
Introduction
Installation Package
Installation Guide
Opening the configuration
Selecting NIC
Capturing the traffic
TrafMeter Service Monitor
User authentication
Sending SMS
NAT
Traffic Shaper
Viewing the Traffic Counters
Processing the captured packet
Logging the Application Events
Logging the denied packets
Firewall
Zeroing counters
Users
Filter Manager
Filter Editor
Rule Editor
IP Address Groups
Database Connection String
XML Traffic Reports
Using XSL formatting
The example of XSL formatting
The example of XSL formatting (2)
Traffic Logging into the Database
Database table
Packet Logging
Into the plaintext file
Filename template
Into the database
Database Table
Microsoft SQL Server Syntax
MySQL Server Syntax
Microsoft Access Syntax
Useful SQL scripts
Host Header Logging
Into the plaintext file
Into the database
Database Table
Microsoft SQL Server Syntax
MySQL Server Syntax
Microsoft Access Syntax
Result Codes
Counting VPN packests
Table for storing Filter Names
Registry Settings
FAQ
TrafMeter FAQ
Traffic counting with TrafMeter FAQ
Configuration examples
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7
Example 8
Knowledge base
IP protocol number
Type Of Service (ToS) field
MAC address
Promiscuous mode
Ethernet hub
Ethernet switch
Ethernet
NAT router
HOWTO: Creating an OLE DB Connection String for Microsoft SQL Server
HOWTO: Creating an OLE DB Connection String for an Access
HOWTO: Creating an OLE DB Connection String for MySQL
Manual editing of the XML files
Zeroing counters using TrafReset
How to enable
Reloading the Filterset
TrafMeter :: Useful SQL scripts for analyzing the table with the captured packets

Useful SQL scripts for analyzing the table with the captured packets

TrafMeter doesn't have a native tool for building the reports from a Packet Logging database. To help in creating your custom SQL-scripts for building various reports we provide some Microsoft SQL Server examples listed below.

1. Calculating the total amount of traffic for every filter

select filterid, sum(sent),sum(recv) from packets group by filterid

2. Calculating the total amount of traffic for every filter for a specific day

select filterid as filterid, sum(sent) as sent, sum(recv) as recv from packets
   where datediff(day,'2002-11-24',ts)=0
   group by filterid
   order by filterid

3. Calculating the total amount of traffic for every filter for a specific month

select filterid as filterid, sum(sent) as sent, sum(recv) as recv from packets
   where datediff(month,'2002-11-01',ts)=0
   group by filterid
   order by filterid

4. Calculating the total amount of traffic per day for a specific filter for a specific month

Set the variable @dd to the first day of the required month.

declare @dd datetime
set @dd='2002-11-01'
select datediff(day,@dd,ts) as mday, sum(sent) as sent, sum(recv) as recv
   from packets
   where (filterid=1 AND (datediff(month,@dd,ts)=0))
   group by datediff(day,@dd,ts)
   order by datediff(day,@dd,ts)

The example above shows the dates with a zero-based index. E.g. the first day of the month will be 0, the second day of month will be 1. To avoid this problem, you can use the following script with a temporary table:

drop table #p1
go
declare @dd datetime
set @dd='2002-11-01'
select datediff(day,@dd,ts) as mday, sum(sent) as sent, sum(recv) as recv
   into #p1
   from packets 
   where (filterid=1 AND (datediff(month,@dd,ts)=0))
   group by datediff(day,@dd,ts)
go
update #p1 set mday=mday+1
go
select * from #p1 order by mday

5. Calculating the total amount of traffic per host for a specific filter for a specific month

select dst_ip, sum(sent) as sent, sum(recv) as recv 
   from packets
   where (filterid=1 AND (datediff(month,'2002-11-01',ts)=0))
   group by dst_ip

 

This HTML Help has been published using the chm2web software.