From 0f5df1cceec6e16ee5b1f65736e2b1b5f0be18de Mon Sep 17 00:00:00 2001 From: Alexey Nizhegolenko Date: Mon, 25 Jan 2021 09:15:23 +0200 Subject: [PATCH] One more minor fixed and install.sh file update --- geoparser.py | 5 +++-- install.sh | 33 ++++++++++++++++----------------- settings.ini.back | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/geoparser.py b/geoparser.py index abaa9cc..f00b6ec 100755 --- a/geoparser.py +++ b/geoparser.py @@ -88,7 +88,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER try: CLIENT.write_points(METRICS) except Exception: - logging.exception("Cannot establish connection to InfluxDB: ") + logging.exception("Cannot establish connection to InfluxDB: ") # NOQA def main(): @@ -115,7 +115,8 @@ def main(): if os.path.exists(LOGPATH): logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE) # NOQA else: - print('File %s not found' % LOGPATH) + logging.info('Nginx log file %s not found', LOGPATH) + print('Nginx log file %s not found' % LOGPATH) if __name__ == '__main__': diff --git a/install.sh b/install.sh index cb7a205..d05ef69 100755 --- a/install.sh +++ b/install.sh @@ -8,30 +8,21 @@ WORKDIR=$(pwd) echo "" -echo "Downloading latest GeoLiteCity.dat from MaxMind" +echo "Creating virtual ENV and install all needed requirements..." sleep 1 -wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz -mkdir tmpgeo -tar -xvf GeoLite2-City.tar.gz -C ./tmpgeo && cd ./tmpgeo/*/. -cp ./GeoLite2-City.mmdb $WORKDIR -cd $WORKDIR +python3 -m venv venv && source venv/bin/activate + +pip3 install -r requirements.txt && deactivate echo "" -echo "Creating virtual ENV and installing requirements..." -sleep 1 -virtualenv venv && source venv/bin/activate - -pip install -r requirements.txt && deactivate - -echo "" -echo "Please edit settings.ini file and set right parameters..." +echo "Please edit settings.ini file and set the needed parameters..." sleep 1 cp settings.ini.back settings.ini "${VISUAL:-"${EDITOR:-vi}"}" "settings.ini" echo "" -echo "Installing SystemD service..." +echo "Installing GeoStat SystemD service..." sleep 1 while read line do @@ -41,6 +32,14 @@ done < "./geostat.service.template" > /lib/systemd/system/geostat.service systemctl enable geostat.service echo "" -echo "All done, now you can start getting GEO data from your log" -echo "run 'systemctl start geostat.service' for this" +echo "Last step, you need to register and download the lates GeoLite2 City mmdb file from the maxmind.com website" +echo "After you get an account on the maxmind.com you can find the needed file by the link below" +echo "https://www.maxmind.com/en/accounts/YOURACCOUNTID/geoip/downloads" +echo "Please don't forget to unzip and put the GeoLite2-City.mmdb file in the same directory with the geoparse.py" +echo "script, or you can put it enywhere and then change the way in the settings.ini" + +echo "" +echo "Good, all was done and you can start getting GEO data from your Nginx/Apache log file now" +echo "Please run 'systemctl start geostat.service' for starting the GeoStat script" +echo "You can find the GeoStat application logs in the syslog file if you need" echo "Good Luck !" diff --git a/settings.ini.back b/settings.ini.back index bd99eea..dbdc2ee 100644 --- a/settings.ini.back +++ b/settings.ini.back @@ -8,15 +8,15 @@ geoipdb = ./GeoLite2-City.mmdb [INFLUXDB] # Database URL -host = 185.27.96.227 +host = INFLUXDB_SERVER_IP port = 8086 #Database name -database = telegraf +database = INFLUXDB_DATABASE_NAME # HTTP Auth -username = telegraf -password = itieh0eeMo +username = INFLUXDB_USER_NAME +password = INFLUXDB_USER_PASSWORD # Measurement name measurement = geodata