Skip to content

Commit 84785b5

Browse files
committed
Receive bot instructions from Grafolean; rearrange DB; support Netflow v5; disable autoheal by default
1 parent a27a744 commit 84785b5

File tree

7 files changed

+259
-299
lines changed

7 files changed

+259
-299
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
BACKEND_URL=https://grafolean.com/api
22
BOT_TOKEN=
3+
DB_DIR=
34
JOBS_REFRESH_INTERVAL=60
45
NETFLOW_PORT=2055

Pipfile.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dbutils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ def migration_step_2():
137137
with db.cursor() as c:
138138
# UNLOGGED: Disabling WAL avoids high I/O load. Since NetFlow data is of temporary nature, this still
139139
# allows us to perform queries, but if the database crashes it is acceptable to lose all of the records.
140-
c.execute(f'CREATE UNLOGGED TABLE {DB_PREFIX}records (seq BIGSERIAL NOT NULL PRIMARY KEY, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, client_ip TEXT);')
141-
c.execute(f'CREATE INDEX {DB_PREFIX}records_ts ON {DB_PREFIX}records (ts);')
140+
c.execute(f'CREATE UNLOGGED TABLE {DB_PREFIX}records (seq BIGSERIAL NOT NULL PRIMARY KEY, ts NUMERIC(16,6) NOT NULL, client_ip TEXT);')
142141

143142
c.execute(f"""
144143
CREATE UNLOGGED TABLE {DB_PREFIX}flows (
@@ -155,6 +154,5 @@ def migration_step_2():
155154
);
156155
""")
157156

158-
def migration_step_3():
159-
with db.cursor() as c:
160-
c.execute(f'CREATE TABLE {DB_PREFIX}bot_jobs (job_id TEXT NOT NULL, last_used_seq BIGSERIAL DEFAULT NULL);')
157+
c.execute(f'CREATE TABLE {DB_PREFIX}bot_jobs (job_id TEXT NOT NULL PRIMARY KEY, last_used_seq BIGSERIAL);')
158+

docker-compose.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ services:
121121
- grafolean
122122

123123

124-
autoheal:
125-
# This container automatically restarts any container that fails its health check. Not a bullet-proof solution, but better than nothing.
126-
image: willfarrell/autoheal
127-
container_name: grafolean-netflow-bot-autoheal
128-
environment:
129-
- AUTOHEAL_CONTAINER_LABEL=all
130-
volumes:
131-
- /var/run/docker.sock:/var/run/docker.sock
132-
restart: always
133-
networks:
134-
- grafolean
124+
# autoheal:
125+
# # This container automatically restarts any container that fails its health check. Not a bullet-proof solution, but better than nothing.
126+
# image: willfarrell/autoheal
127+
# container_name: grafolean-netflow-bot-autoheal
128+
# environment:
129+
# - AUTOHEAL_CONTAINER_LABEL=all
130+
# volumes:
131+
# - /var/run/docker.sock:/var/run/docker.sock
132+
# restart: always
133+
# networks:
134+
# - grafolean
135135

136136

137137
networks:

0 commit comments

Comments
 (0)