69 lines
2.4 KiB
YAML
69 lines
2.4 KiB
YAML
---
|
|
- name: Check Grafana Logs After Test
|
|
hosts: production
|
|
gather_facts: no
|
|
become: no
|
|
|
|
tasks:
|
|
- name: Check last 20 Grafana access attempts
|
|
shell: |
|
|
cd ~/deployment/stacks/traefik
|
|
tail -200 logs/access.log | grep -i grafana | tail -20
|
|
args:
|
|
executable: /bin/bash
|
|
register: latest_logs
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Extract client IPs with timestamps
|
|
shell: |
|
|
cd ~/deployment/stacks/traefik
|
|
tail -100 logs/access.log | grep -i grafana | tail -10 | while IFS= read -r line; do
|
|
time=$(echo "$line" | grep -oP '"time":"[^"]*"' | sed 's/"time":"//;s/"//' | cut -d'T' -f2 | cut -d'+' -f1)
|
|
client=$(echo "$line" | grep -oP '"ClientHost":"[^"]*"' | sed 's/"ClientHost":"//;s/"//')
|
|
status=$(echo "$line" | grep -oP '"DownstreamStatus":[0-9]+' | sed 's/"DownstreamStatus"://')
|
|
if [[ "$client" =~ ^10\.8\.0\.[0-9]+$ ]]; then
|
|
echo "$time | ClientHost: $client | Status: $status ? VPN-IP (Traffic kommt ?ber VPN!)"
|
|
elif [[ "$client" == "89.246.96.244" ]]; then
|
|
echo "$time | ClientHost: $client | Status: $status ? ?ffentliche IP (Traffic kommt NICHT ?ber VPN)"
|
|
else
|
|
echo "$time | ClientHost: $client | Status: $status ? Unbekannt"
|
|
fi
|
|
done
|
|
args:
|
|
executable: /bin/bash
|
|
register: analysis
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display analysis
|
|
debug:
|
|
msg: "{{ analysis.stdout_lines }}"
|
|
|
|
- name: Get unique client IPs
|
|
shell: |
|
|
cd ~/deployment/stacks/traefik
|
|
tail -100 logs/access.log | grep -i grafana | tail -10 | grep -oP '"ClientHost":"[^"]*"' | sed 's/"ClientHost":"//;s/"//' | sort -u
|
|
args:
|
|
executable: /bin/bash
|
|
register: unique_ips
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display unique IPs
|
|
debug:
|
|
msg: "{{ unique_ips.stdout_lines }}"
|
|
|
|
- name: Final result
|
|
debug:
|
|
msg:
|
|
- ""
|
|
- "=== ERGEBNIS ==="
|
|
- "Pr?fe die obigen Zeilen:"
|
|
- ""
|
|
- "? Wenn ClientHost: 10.8.0.7 ? Traffic kommt ?ber VPN!"
|
|
- " ? Dann k?nnen wir die tempor?re IP-Erlaubnis entfernen!"
|
|
- ""
|
|
- "? Wenn ClientHost: 89.246.96.244 ? Traffic kommt NICHT ?ber VPN"
|
|
- " ? Dann m?ssen wir weiter debuggen"
|