Skip to content

Instantly share code, notes, and snippets.

@unique1984
Created August 17, 2019 12:50
Show Gist options
  • Select an option

  • Save unique1984/a95dcae15c0bcaa08b7ffc9a7027d8c8 to your computer and use it in GitHub Desktop.

Select an option

Save unique1984/a95dcae15c0bcaa08b7ffc9a7027d8c8 to your computer and use it in GitHub Desktop.
Web Sunucudan arşivlenmiş loglar dahil anahtar kelime ve domain ile arama
#!/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
@unique1984
Copy link
Copy Markdown
Author

Scriptin çalışması için ssh bağlantısını .ssh/config dosyası ile otomatik hale getirmek gerekmekte, veya ssh -i ile IdentityFile gösterilecek şekilde kod düzenlenmeli.

getApacheLogs.sh access yasinkarabulak.com sozlesme.pdf

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment