One more minor fixed and install.sh file update

This commit is contained in:
Alexey Nizhegolenko 2021-01-25 09:15:23 +02:00
parent 4eb5c68db7
commit 0f5df1ccee
3 changed files with 23 additions and 23 deletions

View file

@ -88,7 +88,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER
try: try:
CLIENT.write_points(METRICS) CLIENT.write_points(METRICS)
except Exception: except Exception:
logging.exception("Cannot establish connection to InfluxDB: ") logging.exception("Cannot establish connection to InfluxDB: ") # NOQA
def main(): def main():
@ -115,7 +115,8 @@ def main():
if os.path.exists(LOGPATH): if os.path.exists(LOGPATH):
logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE) # NOQA logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE) # NOQA
else: 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__': if __name__ == '__main__':

View file

@ -8,30 +8,21 @@
WORKDIR=$(pwd) WORKDIR=$(pwd)
echo "" echo ""
echo "Downloading latest GeoLiteCity.dat from MaxMind" echo "Creating virtual ENV and install all needed requirements..."
sleep 1 sleep 1
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz python3 -m venv venv && source venv/bin/activate
mkdir tmpgeo
tar -xvf GeoLite2-City.tar.gz -C ./tmpgeo && cd ./tmpgeo/*/. pip3 install -r requirements.txt && deactivate
cp ./GeoLite2-City.mmdb $WORKDIR
cd $WORKDIR
echo "" echo ""
echo "Creating virtual ENV and installing requirements..." echo "Please edit settings.ini file and set the needed parameters..."
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..."
sleep 1 sleep 1
cp settings.ini.back settings.ini cp settings.ini.back settings.ini
"${VISUAL:-"${EDITOR:-vi}"}" "settings.ini" "${VISUAL:-"${EDITOR:-vi}"}" "settings.ini"
echo "" echo ""
echo "Installing SystemD service..." echo "Installing GeoStat SystemD service..."
sleep 1 sleep 1
while read line while read line
do do
@ -41,6 +32,14 @@ done < "./geostat.service.template" > /lib/systemd/system/geostat.service
systemctl enable geostat.service systemctl enable geostat.service
echo "" echo ""
echo "All done, now you can start getting GEO data from your log" echo "Last step, you need to register and download the lates GeoLite2 City mmdb file from the maxmind.com website"
echo "run 'systemctl start geostat.service' for this" 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 !" echo "Good Luck !"

View file

@ -8,15 +8,15 @@ geoipdb = ./GeoLite2-City.mmdb
[INFLUXDB] [INFLUXDB]
# Database URL # Database URL
host = 185.27.96.227 host = INFLUXDB_SERVER_IP
port = 8086 port = 8086
#Database name #Database name
database = telegraf database = INFLUXDB_DATABASE_NAME
# HTTP Auth # HTTP Auth
username = telegraf username = INFLUXDB_USER_NAME
password = itieh0eeMo password = INFLUXDB_USER_PASSWORD
# Measurement name # Measurement name
measurement = geodata measurement = geodata