From f6153011a93145f6282445445e4b23223fb58564 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 30 Oct 2017 09:17:57 +0100 Subject: [PATCH] Conf file support default conf, so that it don't mess with custom configuration + make redis persistant --- config/6250.conf | 4 ++-- config/config.cfg.default | 44 +++++++++++++++++++++++++++++++++++++++ install_dependencies.sh | 11 +++++++++- server.py | 2 +- zmq_subscriber.py | 2 +- 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 config/config.cfg.default diff --git a/config/6250.conf b/config/6250.conf index 96e9222..19cb88c 100644 --- a/config/6250.conf +++ b/config/6250.conf @@ -141,7 +141,7 @@ databases 16 #save 900 1 #save 300 10 -#save 60 10000 +save 60 10000 # By default Redis will stop accepting writes if RDB snapshots are enabled # (at least one save point) and the latest background save failed. @@ -184,7 +184,7 @@ dbfilename dump.rdb # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. -dir ./ +dir data/ ################################# REPLICATION ################################# diff --git a/config/config.cfg.default b/config/config.cfg.default new file mode 100644 index 0000000..02c5c5c --- /dev/null +++ b/config/config.cfg.default @@ -0,0 +1,44 @@ +[Dashboard] +#hours +graph_log_refresh_rate = 1 +#sec +rotation_wait_time = 30 +max_img_rotation = 10 +hours_spanned = 48 +zoomlevel = 15 +item_to_plot = Attribute.category +# [1->12] +size_dashboard_left_width = 5 +size_openStreet_pannel_perc = 55 +size_world_pannel_perc = 35 + +[GEO] +#min +updateFrequency = 60 +zoomlevel = 11 +# ~meter +clusteringDistance = 10 + +[Log] +field_to_plot = Attribute.category +fieldname_order=["Event.id", "Attribute.Tag", "Attribute.category", "Attribute.type", ["Attribute.value", "Attribute.comment"]] +char_separator=|| + +[RedisGlobal] +host=localhost +port=6251 + +[RedisLog] +db=0 +channel=1 +zmq_url=tcp://localhost:50000 +#zmq_url=tcp://192.168.56.50:50000 + +[RedisMap] +db=1 +channelProc=CoordToProcess +channelDisp=PicToDisplay +pathMaxMindDB=./data/GeoLite2-City_20171003/GeoLite2-City.mmdb + +[RedisDB] +db=2 diff --git a/install_dependencies.sh b/install_dependencies.sh index 3da38f3..6d8c226 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -3,15 +3,24 @@ set -e set -x -#sudo apt-get install python3-virtualenv +sudo apt-get install python3-virtualenv -y if [ -z "$VIRTUAL_ENV" ]; then virtualenv -p python3 DASHENV + + echo export DASH_HOME=$(pwd) >> ./DASHENV/bin/activate + echo export DASH_CONFIG=$(pwd)/config/ >> ./DASHENV/bin/activate + . ./DASHENV/bin/activate fi pip3 install -U pip argparse redis zmq geoip2 flask +## config +if [ ! -f config/config.cfg ]; then + cp config/config.cfg.sample config/config.cfg +fi + ## Web stuff pushd static/ mkdir -p css fonts diff --git a/server.py b/server.py index 2c7a233..b0b3de7 100755 --- a/server.py +++ b/server.py @@ -9,7 +9,7 @@ from time import sleep, strftime import datetime import os -configfile = os.path.join(os.environ['VIRTUAL_ENV'], '../config.cfg') +configfile = os.path.join(os.environ['DASH_CONFIG'], 'config.cfg') cfg = configparser.ConfigParser() cfg.read(configfile) diff --git a/zmq_subscriber.py b/zmq_subscriber.py index 95cdb7f..e0f6b99 100755 --- a/zmq_subscriber.py +++ b/zmq_subscriber.py @@ -14,7 +14,7 @@ import sys import json import geoip2.database -configfile = os.path.join(os.environ['VIRTUAL_ENV'], '../config.cfg') +configfile = os.path.join(os.environ['DASH_CONFIG'], 'config.cfg') cfg = configparser.ConfigParser() cfg.read(configfile)