Created
August 17, 2019 12:50
-
-
Save unique1984/a95dcae15c0bcaa08b7ffc9a7027d8c8 to your computer and use it in GitHub Desktop.
Web Sunucudan arşivlenmiş loglar dahil anahtar kelime ve domain ile arama
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| if [ -z $1 ]; then | |
| echo "Kullanım: getApacheLogs access [domain] [pattern]" | |
| echo "Kullanım: getApacheLogs error [pattern]" | |
| exit | |
| fi | |
| domain=$2 | |
| if [ -z $2 ]; then | |
| domain="^.*" | |
| else | |
| domain="^$2.*" | |
| fi | |
| pattern=$3".*" | |
| if [ -z $3 ]; then | |
| pattern=".*" | |
| fi | |
| if [ $1 = "access" ]; then | |
| #~ echo 'for i in `ls -vr /var/log/apache2 | grep ^other_vhosts_access\.log\.[0-9]*\.gz`; do zcat /var/log/apache2/$i | grep -i '${domain}${pattern}'; done ; cat /var/log/apache2/other_vhosts_access.log.1 | grep '${domain}${pattern}' ; cat /var/log/apache2/other_vhosts_access.log | grep '${domain}${pattern} | |
| ssh ysnteknoloji 'for i in `ls -vr /var/log/apache2 | grep ^other_vhosts_access\.log\.[0-9]*\.gz`; do zcat /var/log/apache2/$i | grep -i '${domain}${pattern}'; done ; cat /var/log/apache2/other_vhosts_access.log.1 | grep '${domain}${pattern}' ; cat /var/log/apache2/other_vhosts_access.log | grep '${domain}${pattern} | |
| exit | |
| elif [ $1 = "error" ]; then | |
| pattern=$2 | |
| ssh ysnteknoloji 'for i in `ls -vr /var/log/apache2 | grep ^error\.log\.[0-9]*\.gz`; do zcat /var/log/apache2/$i | grep -i '${pattern}'; done ; cat /var/log/apache2/error.log.1 | grep '${pattern}' ; cat /var/log/apache2/error.log | grep '${pattern} | |
| exit | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scriptin çalışması için ssh bağlantısını .ssh/config dosyası ile otomatik hale getirmek gerekmekte, veya
ssh -iile IdentityFile gösterilecek şekilde kod düzenlenmeli.getApacheLogs.sh access yasinkarabulak.com sozlesme.pdf