Started on reworking the database

As it turns out smnl used in my case quite some memory. Turns out
this is because of me using the ipv4 module to keep track of bandwidth
usage. This fires so much queries at the database that it can't keep
up, resulting in the query queue of smnl just filling up. Therefor I'm
going to rework some things with the database. To begin libevent monitors
PQsocket() now, so no more need for that timer. Not on master yet as it
no longer handles database reconnection because of this. Regarding the
ipv4 module issue with a lot of data, I'll likely implement some sort of
hashmap which keeps track of stuff locally and just inserts it in the
database every so often, this will require some changes to the module API
however.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
I should probably change this to our new enable_autocommit function

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
Keeping track of bandwidth per hosts locally now, inserting it every 10 seconds

We now have a simple binary search tree in which we store the
hosts and keep track of the bandwidth. We now loop through this
every 10 seconds and launch the actual queries, just after this
we of course clear it so the local 'cache' of it is reset. Currently
hardcoded to 10 seconds, will probably make this a config option in
a future commit.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
Made the dispatch interval a config option

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>