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
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.1k
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
150
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
130
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
540
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
13k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Gamification - CAS2011
davidbonilla
80
5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
It's Worth the Effort
3n
183
27k
Writing Fast Ruby
sferik
627
61k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Why Our Code Smells
bkeepers
PRO
334
57k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Code Review Best Practice
trishagee
64
17k
Thoughts on Productivity
jonyablonski
67
4.3k
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