Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
analyze_logs_by_rake
Search
namu
February 06, 2014
Technology
1
2.1k
analyze_logs_by_rake
ログ解析にRakeを使うことをオススメします
M3 Tech Talk #18 2014/01/31 #m3dev
namu
February 06, 2014
Tweet
Share
More Decks by namu
See All by namu
How To Create Chrome Extensions
namutaka
3
2.3k
Other Decks in Technology
See All in Technology
20250116_自部署内でAmazon Nova体験会をやってみた話
riz3f7
1
100
re:Invent 2024のふりかえり
beli68
0
110
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
6.5k
Bring Your Own Container: When Containers Turn the Key to EDR Bypass/byoc-avtokyo2024
tkmru
0
860
商品レコメンドでのexplicit negative feedbackの活用
alpicola
2
360
生成AI × 旅行 LLMを活用した旅行プラン生成・チャットボット
kominet_ava
0
160
I could be Wrong!! - Learning from Agile Experts
kawaguti
PRO
8
3.4k
FODにおけるホーム画面編成のレコメンド
watarukudo
PRO
2
280
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
ABWGのRe:Cap!
hm5ug
1
120
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
960
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Adopting Sorbet at Scale
ufuk
74
9.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Optimising Largest Contentful Paint
csswizardry
33
3k
Why Our Code Smells
bkeepers
PRO
335
57k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Transcript
Rake Ͱϩάղੳ M3 Teck Talk #18 2014.01.31 தଜوࢤ
Rakeͱ • make ͷruby൛ • JavaͰ͍͏ͱ͜Ζͷant • Rakefileͱ͍͏ϑΝΠϧ໊ͰλεΫΛఆٛ • rakeίϚϯυͰλεΫΛ࣮ߦ
rakeͷ֓ཁ • ʮRakefileʯͱ͍͏ϑΝΠϧ໊ͰॲཧΛهड़ • هࡌશͳRuby • taskϝιουͰλεΫΛఆٛ • ґଘؔΛఆٛͯ͠Ұ࿈ͷॲཧͷྲྀΕΛ࡞ΕΔ •
fileϝιουͰϑΝΠϧΛ࡞͢ΔλεΫΛఆٛ • ϑΝΠϧ͕͋ͬͨΓɺґଘ͢ΔϑΝΠϧΑΓ৽͚͠ΕεΩοϓ ͢Δ • shϝιουͰγΣϧίϚϯυΛ࣮ߦͰ͖Δ
؆୯ͳྫ͔Β
$ rake -P #λεΫҰཡ rake hello rake world hello !
$ rake hello # hello Λ࣮ߦ Hello ! $ rake world # worldΛ࣮ߦ Hello World ! $ rake file1.txt ˌfile1.txtΛ࡞ $ ls file1.txt ! $ cat file1.txt 11111 # Rakefile ! task :hello do puts "Hello" end ! task :world => [:hello] do puts "World" end ! file "file1.txt" do |t| sh "echo 1111 > #{t.name}" end
$ rake all.txt << create file1.txt >> complete file1.txt <<
create file2.txt echo 2222 > file2.txt >> complete file2.txt << create all.txt cat file1.txt file2.txt > all.txt >> complete all.txt ! $ cat file1.txt 1111 ! $ cat file2.txt 2222 ! $ cat all.txt 1111 2222 file "file1.txt" do |t| puts "<< create file1.txt" File.open(t.name, "w") do |file| file.puts("1111") end puts ">> complete file1.txt" end ! file "file2.txt" do |t| puts "<< create file2.txt" sh "echo 2222 > #{t.name}" puts ">> complete file2.txt" end ! file "all.txt" => ["file1.txt", "file2.txt"] do |t| ! puts "<< create all.txt" sh "cat #{t.prerequisites.join(' ')} > #{t.name}" puts ">> complete all.txt" end
RakeΛ͏͓͢͢ΊϙΠϯτ
͓͢͢ΊϙΠϯτ • RubyͰॻ͚Δ • ̍ͭͷλεΫΛখ͍͞ػೳʹɺґଘؔͰҰ࿈ͷྲྀΕΛ ࡞Δͱɺػೳ͝ͱʹ࣮ߦͰ͖ͯσόοά͍͢͠ • ಈ࡞֬ೝ༻ͷॲཧΛఆ͍ٛ͢͠ • ్தͰࢭΊ࣮ͯߦࡁΈͷfileλεΫεΩοϓͯ͠ɺଓ
͖͔Β࣮ߦͰ͖Δ
ฒྻ࣮ߦ
ฒྻ࣮ߦ file1.txt ࡞ file2.txt ࡞ all.txt࡞ ͜͜ฒྻͰ࣮ߦͰ͖Δ
Pwrake https://github.com/masa16/Pwrake/ • ฒྻ࣮ߦ൛rake • ͦͷ··ͷRakefileͰฒྻ࣮ߦ͕Ͱ͖Δ • ࢦఆͨ͠λεΫʹґଘ͢ΔλεΫ܈ΛεϨουͰฒྻԽ ! •
Πϯετʔϧํ๏ $ gem install pwrake • ͍ํ $ pwrake -j <ฒྻ> <λεΫ໊>
$ pwrake -j 2 all.txt << create file1.txt << create
file2.txt echo 2222 > file2.txt >> complete file1.txt >> complete file2.txt << create all.txt cat file1.txt file2.txt > all.txt >> complete all.txt file "file1.txt" do |t| puts "<< create file1.txt" File.open(t.name, "w") do |file| file.puts("1111") end puts ">> complete file1.txt" end ! file "file2.txt" do |t| puts "<< create file2.txt" sh "echo 2222 > #{t.name}" puts ">> complete file2.txt" end ! file "all.txt" => ["file1.txt", "file2.txt"] do |t| ! puts "<< create all.txt" sh "cat #{t.prerequisites.join(' ')} > #{t.name}" puts ">> complete all.txt" end
ϩάղੳͷ࣮ํ๏
ϩάղੳ access.01.log access.02.log access.03.log access.04.log result.01.csv result.02.csv result.03.csv result.04.csv result_all.csv
$ rake -P rake data/result.1.txt rake data/result.2.txt rake data/result.3.txt rake
data/result_all.log data/result.1.txt data/result.2.txt data/result.3.txt ! $ pwrake -j 2 run # # log/access.1.log => data/result.1.log # log/access.2.log => data/result.2.log # log/access.3.log => data/result.3.log # results = [] (1..3).each do |num| logfile = "data/result.#{num}.txt" results << logfile ! file logfile do |t| sh "grep 'iPad' log/access.#{num}.log > #{t.name}" end end ! # # data/result.1.log # data/result.2.log => data/result_all.log # data/result.3.log # file “data/result_all.log" => results do |t| sh "cat #{t.prerequisites.join(' ‘)} > #{t.name}" end ! task :run => [“data/result_all.log"]
͓·͚
Tips • fileλεΫͷλʔήοτ ͱ͢ΔϑΝΠϧɺॲཧ ͷ࠷ޙʹmvͰ࡞Δ • ్தͰఀࢭͨ͠ͱ͖ʹɺ ࡞Γ͔͚ϑΝΠϧ͕͋Δ ͨΊʹɺεΩοϓ͞Εͳ ͍Α͏ʹ͢ΔͨΊ
file “target.txt” do |t| ! sh “grep HOGE src.log > “ + “ #{t.name}.tmp “ ! sh “mv #{t.name}.tmp #{t.name}” end