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
520
鯖 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
11
9.5k
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
2.8k
経営・意思・エンジニアリング
ymatsuwitter
23
20k
LLM in 2023 and 2024
ymatsuwitter
8
5.8k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
2.8k
LLM in toB Service and Its UX
ymatsuwitter
7
11k
Agent and small LLM validation
ymatsuwitter
7
3k
Information management for a culture of speed: The story of Notion and LayerX
ymatsuwitter
4
10k
Monorepo on AWS
ymatsuwitter
0
320
Other Decks in Programming
See All in Programming
ISUCON研修おかわり会 講義スライド
arfes0e2b3c
1
370
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
1
12k
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
510
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
110
ニーリーにおけるプロダクトエンジニア
nealle
0
760
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
3
410
Modern Angular with Signals and Signal Store:New Rules for Your Architecture @enterJS Advanced Angular Day 2025
manfredsteyer
PRO
0
190
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
250
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
160
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
50
32k
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
150
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
190
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Adopting Sorbet at Scale
ufuk
77
9.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
YesSQL, Process and Tooling at Scale
rocio
173
14k
How to Ace a Technical Interview
jacobian
277
23k
Rails Girls Zürich Keynote
gr2m
94
14k
Bash Introduction
62gerente
614
210k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
500
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
940
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
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/