Difference between revisions of "IT2DT2 Linux"
From Teknologisk videncenter
TheRealKANi (talk | contribs) (→1337 Team) |
TheRealKANi (talk | contribs) (→1337 Team) |
||
Line 66: | Line 66: | ||
clear | clear | ||
echo "Sorting Logfile......" | echo "Sorting Logfile......" | ||
− | |||
echo -e "\n Writing output to a file..\n" | echo -e "\n Writing output to a file..\n" | ||
cat ./apache1337.tmp | head -n 10 > "${output}visits.Total" | cat ./apache1337.tmp | head -n 10 > "${output}visits.Total" | ||
cat ./apache1337.uni | head -n 10 > "${output}Internal.Total" | cat ./apache1337.uni | head -n 10 > "${output}Internal.Total" | ||
− | + | rm -R ./apache1337.tmp ./apache1337.uni | |
clear | clear | ||
echo "Done" | echo "Done" |
Revision as of 10:32, 16 September 2011
Contents
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.
- Find de 10 mest anvendte sider fra logfilen
- Find hvor mange eksterne sider der hentes
- Hvilke 10 sider er de mest populære eksternt
- Find hvor mange interne sider der hentes (RFC1918 adresser)
- Hvilke 10 sider er de mest populære internt
Konkurence
Der konkurerres om
- Det hold der først finder oplysningerne
- Det hold hvis script hurtigst finder informationerne
Hints
At komme igang
- Opret et arbejdsbibliotek
- Gå ind i det
- Hent den store logfil
- 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
- Kenneth H. Mørch.
- Kasper Ovesen.
- Henrik Pedersen
- Danny Christensen
#!/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
awk '{ print $1, $2}' ./apa.uni | uniq -c | sort -nr > ./apache1337.uni
clear
echo "Sorting Logfile......"
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