Difference between revisions of "IT2DT2 Linux"

From Teknologisk videncenter
Jump to: navigation, search
m (At komme igang)
(1337 Team)
Line 39: Line 39:
  
 
=1337 Team=
 
=1337 Team=
 +
#!/bin/sh
 +
input=$1
 +
output=$2
 +
clear
 +
echo "Sorting Logfile"
 +
clear
 +
echo "Sorting Logfile."
 +
cat ${input} | awk '{ print $7}'|sort > ./apax.tmp &
 +
cat ${input} | awk '{ print $1}'|sort > ./apax2.tmp &
 +
echo "pre"
 +
wait %1 %2
 +
echo "post"
 +
cat ./apax.tmp ./apax2.tmp > ./apa.tmp
 +
clear
 +
echo "Sorting Logfile.."
 +
awk '{ print $1, $2}' ./apa.tmp | grep -E "index.php/|index.htm" | uniq -c | sort -nr > ./apache1337.tmp
 +
clear
 +
echo "Sorting Logfile..."
 +
awk '{ print $1}' ./apa.tmp | grep -E "192.168.|172.16.|10.10." > ./apa.uni
 +
#clear
 +
#echo "Sorting Logfile...."
 +
#awk '{ print $1}' ./apa.tmp | grep 172.16. > ./apa2.tmp
 +
#clear
 +
#echo "Sorting Logfile....."
 +
#awk '{ print $1}' ./apa.tmp | grep 10.10.10. > ./apa3.tmp
 +
#cat ./apa1.tmp ./apa2.tmp ./apa3.tmp > apa.uni
 +
#rm -R ./apa1.tmp ./apa2.tmp ./apa3.tmp
 +
awk '{ print $1, $2}' ./apa.uni | uniq -c | sort -nr > ./apache1337.uni
 +
clear
 +
echo "Sorting Logfile......"
 +
#rm -R ./apa.uni
 +
echo -e "\n Writing output to a file..\n"
 +
cat ./apache1337.tmp | head -n 10 > "${output}visits.Total"
 +
cat ./apache1337.uni | head -n 10 > "${output}Internal.Total"
 +
#rm -R ./apache1337.tmp  ./apache1337.uni
 +
clear
 +
echo "Done"
 +
clear
 +
exit 0
  
 
=BRMS=
 
=BRMS=

Revision as of 10:28, 16 September 2011

Logfil opgave

Kopier apache httpd-access.log til et arbejdesbibliotek på din Linuxserver. Filen fylder ca 470 MB og er opsamlet i perioden 27 februar 2011 til 8. august 2011 fra mars.tekkom.dk.

  1. Find de 10 mest anvendte sider fra logfilen
  2. Find hvor mange eksterne sider der hentes
    1. Hvilke 10 sider er de mest populære eksternt
  3. Find hvor mange interne sider der hentes (RFC1918 adresser)
    1. Hvilke 10 sider er de mest populære internt

Konkurence

Der konkurerres om

  1. Det hold der først finder oplysningerne
  2. Det hold hvis script hurtigst finder informationerne

Hints

At komme igang

  1. Opret et arbejdsbibliotek
  2. Gå ind i det
  3. Hent den store logfil
  4. Lav en lille logfil med de øverste 10000 linier
heth@mars2:~$ <input>mkdir logfil</input>
heth@mars2:~$ <input>cd logfil</input>

heth@mars2:logfil$ <input>wget http://mars.tekkom.dk/data/httpd-access.log</input>
--2011-09-01 09:38:20--  http://mars.tekkom.dk/data/httpd-access.log
Læser mars.tekkom.dk... 127.0.1.1
Connecting to mars.tekkom.dk|127.0.1.1|:80... forbundet.
HTTP forespørgsel sendt, afventer svar... 200 OK
Længde: 468007853 (446M) [text/plain]
Saving to: `httpd-access.log'

100%[======================================>] 468.007.853  254M/s   in 1,8s

2011-09-01 09:38:22 (254 MB/s) - `httpd-access.log' saved [468007853/468007853]

heth@mars2:logfil$ <input>head -n 10000 httpd-access.log > small.log</input>


1337 Team

  1. !/bin/sh

input=$1 output=$2 clear echo "Sorting Logfile" clear echo "Sorting Logfile." cat ${input} | awk '{ print $7}'|sort > ./apax.tmp & cat ${input} | awk '{ print $1}'|sort > ./apax2.tmp & echo "pre" wait %1 %2 echo "post" cat ./apax.tmp ./apax2.tmp > ./apa.tmp clear echo "Sorting Logfile.." awk '{ print $1, $2}' ./apa.tmp | grep -E "index.php/|index.htm" | uniq -c | sort -nr > ./apache1337.tmp clear echo "Sorting Logfile..." awk '{ print $1}' ./apa.tmp | grep -E "192.168.|172.16.|10.10." > ./apa.uni

  1. clear
  2. echo "Sorting Logfile...."
  3. awk '{ print $1}' ./apa.tmp | grep 172.16. > ./apa2.tmp
  4. clear
  5. echo "Sorting Logfile....."
  6. awk '{ print $1}' ./apa.tmp | grep 10.10.10. > ./apa3.tmp
  7. cat ./apa1.tmp ./apa2.tmp ./apa3.tmp > apa.uni
  8. rm -R ./apa1.tmp ./apa2.tmp ./apa3.tmp

awk '{ print $1, $2}' ./apa.uni | uniq -c | sort -nr > ./apache1337.uni clear echo "Sorting Logfile......"

  1. rm -R ./apa.uni

echo -e "\n Writing output to a file..\n" cat ./apache1337.tmp | head -n 10 > "${output}visits.Total" cat ./apache1337.uni | head -n 10 > "${output}Internal.Total"

  1. rm -R ./apache1337.tmp ./apache1337.uni

clear echo "Done" clear exit 0

BRMS

BOGO

Winning

Batman

Fiskergruppen