Stats for Fail2Ban (for relational database)
#Overview
See diagram at https://github.com/prontodev/ban2stats/blob/master/docs/Ban2Stats_diagram.pdf
Ban2Stats Web Service is a Django web application and also use Haystack to connect with ElasticSearch. It saves attack details to database and sends data to ElasticSearch.
A static web page that display Statistics from Ban2Stats Web Service. In the HTML page contains Javascript that will make Ajax calls to Ban2Stats Web Service and then display content on the page.
is a Python script that makes HTTP Request to Ban2Stats web service API. The client is used by Fail2Ban hook.
ElasticSearch is used to do search and indexing for Ban2Stats Web Service
#Dependencies
- geos
- elasticsearch
- python
pip install -r ban2stats/ban2stats/setup/requirements.txt
pip install -r ban2stats/client/requirements.txt
#Configuration
Create local.py under ban2stats/ban2stats/settings/
- database configuration
- ElasticSearch configuration (HAYSTACK_CONNECTIONS)
- BAN2STATS_SERVICE_TOKEN (should match with client's TOKEN)
#Installation
To work with indexing, Ban2Stats Web Service will feed data to ElasticSearch. For the first time, run follow command to create index for ElasticSearch at Ban2Stats Web Service.
python manage.py rebuild_index
To update index for ElasticSearch (more details on Haystack):
python manage.py update_index
And please setup your system cron job to update index (For example for every 10 min):
In ban2stats/client/webservice_client.py
- WEBSERVICE_HOST
- TOKEN (should match with Banstats's BAN2STATS_SERVICE_TOKEN in settings)
In ban2stats/webpage/index.html
- api_host
#Run
See ElasticSearch documentation.
Ban2Stats Web Service is a Django web application. Please see Django document on how to setup production server. To run development server run:
python manage.py runserver
You can run this using any static web server.
if you want to run it using Python
python -m SimpleHTTPServer 80