All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Leblond <eric@regit.org>
To: netfilter-devel@vger.kernel.org
Cc: Eric Leblond <eric@regit.org>
Subject: [PATCH 2/5] pgsql schema: add nfacct table
Date: Wed,  1 Aug 2012 23:27:13 +0200	[thread overview]
Message-ID: <1343856436-11129-3-git-send-email-eric@regit.org> (raw)
In-Reply-To: <1343856436-11129-1-git-send-email-eric@regit.org>

This patch adds a nfacct table to the postgresql schema. It enables
the storage of all counters at each poll.
---
 doc/pgsql-ulogd2.sql |   22 ++++++++++++++++++++++
 ulogd.conf.in        |    8 ++++++++
 2 files changed, 30 insertions(+)

diff --git a/doc/pgsql-ulogd2.sql b/doc/pgsql-ulogd2.sql
index 8f47bf9..0fc2b45 100644
--- a/doc/pgsql-ulogd2.sql
+++ b/doc/pgsql-ulogd2.sql
@@ -33,6 +33,7 @@ DROP TABLE IF EXISTS sctp CASCADE;
 DROP TABLE IF EXISTS icmp CASCADE;
 DROP TABLE IF EXISTS icmpv6 CASCADE;
 DROP TABLE IF EXISTS nufw CASCADE;
+DROP TABLE IF EXISTS nfacct CASCADE;
 DROP TABLE IF EXISTS ulog2_ct CASCADE;
 DROP TABLE IF EXISTS ulog2 CASCADE;
 
@@ -149,6 +150,16 @@ CREATE TABLE icmpv6 (
   icmpv6_csum integer default NULL
 ) WITH (OIDS=FALSE);
 
+CREATE TABLE nfacct (
+  sum_name varchar(128),
+  sum_pkts integer default 0,
+  sum_bytes integer default 0,
+  oob_time_sec integer default NULL,
+  oob_time_usec integer default NULL
+) WITH (OIDS=FALSE);
+
+CREATE UNIQUE INDEX unique_acct ON nfacct(sum_name, oob_time_sec, oob_time_usec);
+
 -- 
 -- VIEWS
 -- 
@@ -696,6 +707,17 @@ END
 $$ LANGUAGE plpgsql SECURITY INVOKER;
 
 
+CREATE OR REPLACE FUNCTION INSERT_NFACCT(
+                IN sum_name varchar(128),
+                IN sum_pkts integer,
+                IN sum_bytes integer,
+                IN oob_time_sec integer,
+                IN oob_time_usec integer
+        )
+RETURNS void AS $$
+        INSERT INTO nfacct (sum_name,sum_pkts,sum_bytes,oob_time_sec,oob_time_usec)
+                VALUES ($1,$2,$3,$4,$5);
+$$ LANGUAGE SQL SECURITY INVOKER;
 
 
 CREATE OR REPLACE FUNCTION DELETE_PACKET(
diff --git a/ulogd.conf.in b/ulogd.conf.in
index 879ab3c..0e45714 100644
--- a/ulogd.conf.in
+++ b/ulogd.conf.in
@@ -232,6 +232,14 @@ table="ulog2_ct"
 pass="changeme"
 procedure="INSERT_OR_REPLACE_CT"
 
+[pgsql4]
+db="nulog"
+host="localhost"
+user="nupik"
+table="nfacct"
+pass="changeme"
+procedure="INSERT_NFACCT"
+
 [dbi1]
 db="ulog2"
 dbtype="pgsql"
-- 
1.7.10.4


  parent reply	other threads:[~2012-08-01 21:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01 21:27 [ulogd patch 0/5] nfacct and pgsql update Eric Leblond
2012-08-01 21:27 ` [PATCH 1/5] nfacct: add variable to not zero counter after read Eric Leblond
2012-08-03  9:24   ` Pablo Neira Ayuso
2012-08-01 21:27 ` Eric Leblond [this message]
2012-08-03  9:29   ` [PATCH 2/5] pgsql schema: add nfacct table Pablo Neira Ayuso
2012-08-01 21:27 ` [PATCH 3/5] pgsql schema: fix timestamp default value Eric Leblond
2012-08-03  9:29   ` Pablo Neira Ayuso
2012-08-01 21:27 ` [PATCH 4/5] pgsql: only disable key if it starts with underscore Eric Leblond
2012-08-03  9:29   ` Pablo Neira Ayuso
2012-08-01 21:27 ` [PATCH 5/5] nfacct: add timestamp option Eric Leblond
2012-08-03  9:35   ` Pablo Neira Ayuso
2012-08-03  9:43     ` Eric Leblond
2012-08-03 11:24       ` Pablo Neira Ayuso
2012-08-03 14:54         ` Pablo Neira Ayuso
2012-09-01 12:49     ` Mr Dash Four
2012-09-02 20:03       ` Mr Dash Four

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343856436-11129-3-git-send-email-eric@regit.org \
    --to=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.