#!/bin/sh DB_HOST="192.168.7.253" DB_PORT="5432" DB_USER="netflow" DB_PASS="1234" DB_NAME="netflow" DB_TABLE=`date "+%Y-%m"` SQL_QUERY="CREATE TABLE \"${DB_TABLE}\" (\ \"id\" bigserial NOT NULL UNIQUE PRIMARY KEY,\ \"dpkts\" bigint,\ \"doctets\" bigint,\ \"srcaddr\" cidr,\ \"dstaddr\" cidr,\ \"nexthop\" cidr,\ \"input\" smallint,\ \"output\" smallint,\ \"srcport\" int,\ \"dstport\" int,\ \"proto\" smallint,\ \"tos\" smallint,\ \"tcp_flags\" smallint\ );" psql -q -d ${DB_NAME} -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USER} -c "${SQL_QUERY}" > /dev/null 2>&1 exit 0