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
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
290
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
200
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
490
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
360
ハイテク休憩
sat
PRO
2
170
MLOps の現場から
asei
7
650
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
320
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
A Tale of Four Properties
chriscoyier
157
23k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Into the Great Unknown - MozCon
thekraken
33
1.5k
Mobile First: as difficult as doing things right
swwweet
222
9k
Building Adaptive Systems
keathley
38
2.3k
Statistics for Hackers
jakevdp
796
220k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Six Lessons from altMBA
skipperchong
27
3.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The World Runs on Bad Software
bkeepers
PRO
65
11k
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