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
500
鯖 On RasPi ~Mackerelで簡単家モニタリング~
Mackerel meetup #4にてLT発表
y_matsuwitter
June 02, 2015
Tweet
Share
More Decks by y_matsuwitter
See All by y_matsuwitter
経営・意思・エンジニアリング
ymatsuwitter
21
16k
LLM in 2023 and 2024
ymatsuwitter
8
4.1k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
1
2.3k
LLM in toB Service and Its UX
ymatsuwitter
6
8.8k
Agent and small LLM validation
ymatsuwitter
7
2.7k
Information management for a culture of speed: The story of Notion and LayerX
ymatsuwitter
4
9k
Monorepo on AWS
ymatsuwitter
0
210
Tech behind LayerX SaaS products
ymatsuwitter
0
2.6k
2022-10-14-geeksai
ymatsuwitter
23
17k
Other Decks in Programming
See All in Programming
Git Rebase
bkuhlmann
11
1.6k
二郎系ラーメンのコールで学ぶ AST 解析
memory1994
PRO
7
1.7k
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
260
Komplexe Oberflächen mit SVG und der Web Animation API
joergneumann
0
670
Elm Form Validation
bkuhlmann
0
510
Git Lint
bkuhlmann
4
750
SIMD Parallel Programming with the Vector API
josepaumard
0
140
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
300
Ruby Pattern Matching
bkuhlmann
0
920
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.1k
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
260
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Automating Front-end Workflow
addyosmani
1356
200k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Code Review Best Practice
trishagee
55
15k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
Designing Experiences People Love
moore
136
23k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
Bash Introduction
62gerente
604
210k
The Brand Is Dead. Long Live the Brand.
mthomps
49
28k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
How STYLIGHT went responsive
nonsquared
92
4.8k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
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/