On Thu, 23 Sep 2004 15:24:40 +0200 (CEST)
"Alen Komic" <[EMAIL PROTECTED]> wrote:

> Hello all,
> 
> Quotation is not defined correctly in flow-export util for postgresql
> support.
> Correct quotation for mysql is " char, and for pgsql is '.
> This patch corrects it.
> 
> Cheers
> -- 
> Alen Komic

http://bugs.gentoo.org/show_bug.cgi?id=50926

------- Additional Comment #7 From Molchanov Alexander 2004-05-14 03:56 PST ------- 

Flow-tools patch for exporting in PostgreSQL format
Description
This a patch for flow-tools.67 for exporting flows to a PostgreSQL database 7.x.

http://netflow.pregi.net/downloads/patch.flow

------- Additional Comment #8 From Molchanov Alexander 2004-05-14 03:57 PST ------- 

above patch description is here:
http://netflow.pregi.net/flowtools-patch.html

------- Additional Comment #9 From Molchanov Alexander 2004-05-19 23:54 PST ------- 

Created an attachment (id=31749) [edit]
flow-tools/files/0.67/patch-memoryleak-format5.patch

result of called function PQexec() not free!

Export into PostgreSQL is very slow ! I use export into text and
after from text to postgresql:

[Perl cut]
               # more fast variant
        ####################################
        if [ ! -d "${BACKUPDIR}/${collector}" ] ; then
                echo "Creating new dir '${BACKUPDIR}/${collector}'"
                mkdir -p "${BACKUPDIR}/${collector}"
        fi      

        dumpfile="${BACKUPDIR}/${collector}/${SQLDB}.sql"

        echo "Creating '$dumpfile'"

        echo -e "--\n-- PostgreSQL database dump\n--\t\t created by $ProgramName\n" > 
$dumpfile
        echo -e "-- `LANG=C date`\n--\n" >> $dumpfile
        echo -e "SET client_encoding = 'SQL_ASCII';" >> $dumpfile
        echo -e "SET check_function_bodies = false;\n" >> $dumpfile
        echo -e "SET SESSION AUTHORIZATION 'flowtools';\n" >> $dumpfile
        echo -e "SET search_path = public, pg_catalog;\n\n" >> $dumpfile

        echo -e "CREATE TABLE ${SQLDB} ${DB_PSQL_FIELDS};\n\n--\n" >> $dumpfile

        ###fields=`psql -c "select * from ${SQLDB} limit 0;" ${collector} | head -n 1 
| sed -e 's/ |/,/g'`
        i_field=1
        fields=""
        while [ 1 ] ; do
                curr_field=`echo ${DB_PSQL_FIELDS} | cut -d ',' -f $i_field`
                if [ -z "$curr_field" ] ; then
                        break
                fi

                curr_field=`echo $curr_field | sed -r 's/^\(//' | sed -r 's/\)$//'`
                field_name=`echo $curr_field | sed -r 's/^([^ \t]+).+$/\1/'`
                fields="$fields, \"$field_name\""
        done
        fields=`echo $fields | sed -r 's/^, //'`
        echo -e "COPY ${SQLDB} ($fields) FROM stdin WITH DELIMITER AS ',';" >> 
$dumpfile

        # export into text
        ${BINDIR}/flow-cat $CatOptions ${Fregexp} \
                | ${BINDIR}/flow-xlate -x $CFGDIR/xlate-as-change.cfg -X 
replase_as0_to24626 \
                | ${BINDIR}/flow-export -f2 -m 0xC1E3041 \
                | perl -e 'my $first_line = <STDIN>; while (<STDIN>) { print; }' \
                >> $dumpfile

        echo -e "\\.\n\n" >> $dumpfile
        ####################################
        /bin/date
        echo "Delete(if exist) table '${SQLDB}' (don't worry if 'ERROR') ..."
        #       must run from [EMAIL PROTECTED] !!!
        ${PSQL_BIN} -c "DROP TABLE ${SQLDB}" ${collector}

        echo "Exporting data from '$dumpfile'"
        ${PSQL_BIN} -f "$dumpfile" ${collector}

        /bin/date
        echo
}
----------------

$dumpfile is simple SQL dump

example result file:

--
-- PostgreSQL database dump
--               created by export_ft.sh

-- Tue Aug 17 09:43:25 MSD 2004
--

SET client_encoding = 'SQL_ASCII';
SET check_function_bodies = false;

SET SESSION AUTHORIZATION 'flowtools';

SET search_path = public, pg_catalog;


CREATE TABLE kirov20040816 (unix_secs bigint, doctets bigint, srcaddr inet, dstaddr 
inet, inpu
t int4, output int4, srcport int4, dstport int4, src_as int4, dst_as int4);

--

COPY kirov20040816 ("unix_secs", "doctets", "srcaddr", "dstaddr", "input", "output", 
"srcport"
, "dstport", "src_as", "dst_as") FROM stdin WITH DELIMITER AS ',';
.....

P.S. i writing billing now (based on netflow, postgresql, mrtg, webaccounting and 
other)
and using perl and bash for it.
After finishing i will release it by GPL.
Current version 0.9-rc1, but i already using it for my company.

-- 
Molchanov Alexander(Xorader) <[EMAIL PROTECTED]>
PGP Fingerprint = 50C7 8479 59E4 8228 F27C 5E8C EDF5 FECC 6CA2 B1E2
_______________________________________________
Flow-tools mailing list
[EMAIL PROTECTED]
http://mailman.splintered.net/mailman/listinfo/flow-tools

Reply via email to