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
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
2.1k
経営・意思・エンジニアリング
ymatsuwitter
23
19k
LLM in 2023 and 2024
ymatsuwitter
8
5.2k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
2.5k
LLM in toB Service and Its UX
ymatsuwitter
6
9.9k
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.6k
Monorepo on AWS
ymatsuwitter
0
260
Tech behind LayerX SaaS products
ymatsuwitter
0
3k
Other Decks in Programming
See All in Programming
イベント駆動で成長して委員会
happymana
1
320
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Ethereum_.pdf
nekomatu
0
460
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
subpath importsで始めるモック生活
10tera
0
300
CSC509 Lecture 12
javiergs
PRO
0
160
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Facilitating Awesome Meetings
lara
50
6.1k
GraphQLとの向き合い方2022年版
quramy
43
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Code Reviewing Like a Champion
maltzj
520
39k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Speed Design
sergeychernyshev
25
620
Into the Great Unknown - MozCon
thekraken
32
1.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
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/