2018-06-15 21:21:13 +00:00
|
|
|
# Apache logide parsija
|
|
|
|
|
2018-06-17 20:14:16 +00:00
|
|
|
Failis ```main.py``` on näide kuidas Apache2 logisid parsida ning raporteerida huvitavamad killud:
|
2018-06-15 21:21:13 +00:00
|
|
|
|
|
|
|
* Parsib Apache logifaili kirjed ApacheLogParser klassi abil mis on kirjeldatud failis log_parsers.py
|
2018-06-17 20:14:16 +00:00
|
|
|
* Laadib ```requests``` mooduli abil alla BlankMap-World6.svg, värvib selle ära ```lxml``` mooduli abil ning salvestab top.svg faili sisse
|
2018-06-15 21:21:13 +00:00
|
|
|
* Genereerib Bootstrap baasil koostatud veebilehe mallist template.html faili raport.html
|
2018-06-17 20:14:16 +00:00
|
|
|
|
|
|
|
Sõltuvuste paigladamiseks:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
apt install -y python-jinja2 python-lxml python-pygal python-geoip python-numpy python-matplotlib
|
|
|
|
dnf install -y python-jinja2 python-lxml python-pygal python2-GeoIP python2-numpy python2-matplotlib
|
|
|
|
```
|
|
|
|
|
|
|
|
Käivitamiseks
|
|
|
|
|
|
|
|
```bash
|
|
|
|
(cat /path/to/access.log; zcat /path/to/access.log.1.gz) | python main.py
|
|
|
|
(cat /path/to/access.log; zcat /path/to/access.log.[12].gz) | python main.py
|
|
|
|
(cat /path/to/access.log; zcat /path/to/access.log.[1-5].gz) | python main.py
|
|
|
|
(cat /path/to/access.log; zcat /path/to/access.log.*.gz) | python main.py
|
|
|
|
```
|
|
|
|
|
|
|
|
# Java rakenduste stack trace'de kokku korjaja
|
|
|
|
|
|
|
|
Failis ```main2.py``` on näide kuidas Java rakenduse logikirjetest stack trace'd kokku koguda:
|
|
|
|
|
|
|
|
* Ühisosa Apache logide parsijaga on ```GenericParser``` klass milles sisaldub üldine logide parsimise loogika
|
|
|
|
|
|
|
|
Sõltuvuste paigladamiseks:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
apt install -y python-jinja2
|
|
|
|
dnf install -y python-jinja2
|
|
|
|
```
|
|
|
|
|
|
|
|
Käivitamiseks:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cat blah.log | python main2.py > raport2.html
|
|
|
|
```
|