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
鯖 On RasPi ~Mackerelで簡単家モニタリング~
Search
y_matsuwitter
June 02, 2015
Programming
0
510
鯖 On RasPi ~Mackerelで簡単家モニタリング~
Mackerel meetup #4にてLT発表
y_matsuwitter
June 02, 2015
Tweet
Share
More Decks by y_matsuwitter
See All by y_matsuwitter
Building Products in the LLM Era
ymatsuwitter
10
6.8k
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
2.5k
経営・意思・エンジニアリング
ymatsuwitter
23
19k
LLM in 2023 and 2024
ymatsuwitter
8
5.5k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
2.6k
LLM in toB Service and Its UX
ymatsuwitter
7
10k
Agent and small LLM validation
ymatsuwitter
7
2.9k
Information management for a culture of speed: The story of Notion and LayerX
ymatsuwitter
4
9.9k
Monorepo on AWS
ymatsuwitter
0
290
Other Decks in Programming
See All in Programming
sappoRo.R #12 初心者セッション
kosugitti
0
280
Go 1.24でジェネリックになった型エイリアスの紹介
syumai
2
290
新宿駅構内を三人称視点で探索してみる
satoshi7190
2
120
[JAWS DAYS 2025] 最近の DB の競合解決の仕組みが分かった気になってみた
maroon1st
0
130
たのしいSocketのしくみ / Socket Under a Microscope
coe401_
8
1.4k
SwiftUI Viewの責務分離
elmetal
PRO
2
280
Jakarta EE meets AI
ivargrimstad
0
470
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
930
バッチを作らなきゃとなったときに考えること
irof
2
530
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
280
Rails 1.0 のコードで学ぶ find_by* と method_missing の仕組み / Learn how find_by_* and method_missing work in Rails 1.0 code
maimux2x
1
250
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
1
210
Featured
See All Featured
Music & Morning Musume
bryan
46
6.4k
Site-Speed That Sticks
csswizardry
4
410
The Cult of Friendly URLs
andyhume
78
6.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
260
Building Adaptive Systems
keathley
40
2.4k
Transcript
ḉ on RasPi MackerelͰ؆୯ՈϞχλϦϯά
ωλඃͬͨ
ࣗݾհ • Gunosy Inc. • ։ൃຊ෦ࣥߦһࡶ༻ • iOS, Android, Infrastructure,
Web • Golangڭ • ਖ਼࠲ • ࠷ۙؾʹͳΔͷ: MQTT
ࠓͷ • LunchHack෦Ͱࢼͨ͠ɺRasPiͷ্Ͱಈ͘Mackerelͷ
GunosyLunchHackͱ • Gunosyͷࣾһ༗ࢤͰன৯Λ৯ͭͭࣗ༝ʹOSSίϛοτ ݸਓ։ൃΛߦ͏࣌ؒ • ຖिճΏΔΏΔͱ։࠵த
RaspberryPiͱ
Spec • খܕɾ҆Ձͳڭҭ͚LinuxϚγϯ • RaspberryPi Foundation͕։ൃ • CPU: ARM •
Memory: 256 ~ 1GB • USB microBͰڅి • GPIOϐϯ͕༻ҙ͞Ε͍ͯΔ
ARMͳͷͰ Golang͕ಈ͘ʂʂ GOARCH=arm go build
ͭ·Γʁ
Mackerel͕ಈ͘ʂ
ͱ͍͏Θ͚ͰͬͯΈͨ
جຊతͳϝτϦΫε • CPU • Load Average • Memory • Disk
usage
None
ΧελϜϝτϦΫε • CPUԹ ԼهίϚϯυͰऔಘɺmackerel-plugin࡞ pi@raspberrypi ~ $ cat /sys/class/thermal/thermal_zone0/temp 54072
None
͜Ε͚ͩ͡Ό໘ന͘ͳ͍ͷͰ ՈͷϞχλϦϯά࢝Ίͨ
ͬͨͷ • SHT21 • ϒϨουϘʔυ • ઢ4ຊ΄Ͳ
ͬͨ͜ͱ • I2Cܦ༝ͰԹɾ࣪Λऔಘ • mackerel-pluginԽͯ͠customϝτϦΫεͱͯ͠ه ࢀߟ: https://speakerdeck.com/ymatsuwitter/golang-plus-raspidequ- wei-de-iotru-men-de-nahua
kidoman/embd
About embd • ΈࠐΈϓϩάϥϛϯά͚ϑϨʔϜϫʔΫ • GobotͱൺΔͱ͏গ͠ϨΠϠ? • ରԠগͳ͍ • ֤छBusΛ৮Γ͍͢
• Ұ෦ηϯαͷυϥΠό༻ҙ͞Ε͍ͯΔ
embdͰSHT21͔ΒԹΛऔಘ • ࠓճEmbdͷI2CBusΛར༻ // Busʢܦ࿏ʣͷ࡞ bus := embd.NewI2CBus(1) // ॳظԽ
bus.WriteByte(addr, byte(softreset)) // ॳظԽྃͪ time.Sleep(500 * time.Millisecond)
ଓ͖ // ԹΛૹͬͯΒ͏Α͏৴߸ૹ৴ bus.WriteByte(addr, triggerTemperatureNoHold) // ϋʔυΣΞଆͷ৴߸ͪ time.Sleep(temperatureWait * time.Millisecond)
// 1όΠτಡΈग़͠ first, _ := bus.ReadByte(addr) // 2όΠτಡΈग़͠ second, _ := bus.ReadByte(addr) // ̎ͭͷΛݩʹηϧγεʹม temp := (175.72*float64((int64(first)<<8+int64(second))&statusBitMusk))/float64(1<<16) - 46.85
͜ΕΒͷΛͬͯ mackerel-plugin࡞
Թ
࣪
͍ͭͰʹAlertΛֻ͚ͯΈΔ • Ex. ࣨԹ͕ߴ͗͢Δ߹ʹ௨
None
ࣗͷSlackʹ௨ͯ͠ΈΔ • Ͳͷ͝ՈఉͰར༻͞Ε͍ͯΔͰ͋Ζ͏Slack • SlackΛ௨ઌͱͯ͠ઃఆ͠ɺϝτϦΫεͱͱʹߘ
None
ࠓΖ͏ͱ͍ͯ͠Δ͜ͱ ʮॵ͍ʯAlert => MackerelͷWebHookΛड͚औΔ => IRKitͰΤΞίϯىಈ => Alertऩଋ௨ => ΤΞίϯఀࢭ
ࢀߟ:IRKit • HTTP APIΛͭεϚʔτϦϞίϯ • ΤΞίϯϦϞίϯૢ࡞͢ΔػثΛίʔυʹ੍ͯޚՄೳ http://getirkit.com/
·ͱΊ • RasPiͱMackerelͰ؆୯ՈϞχλϦϯά • Alert؆୯ʹֻ͚ΒΕΔ
Ҏ্
GunosyͰઈࢍΤϯδχΞืूத! http://gunosy.co.jp/recruit/