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
2k
経営・意思・エンジニアリング
ymatsuwitter
23
18k
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
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.1k
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1.1k
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
160
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
190
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
480
Identifying User Idenity
moro
6
9.5k
macOS でできる リアルタイム動画像処理
biacco42
9
2.3k
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
4
2k
Outline View in SwiftUI
1024jp
1
280
Better Code Design in PHP
afilina
PRO
0
110
Macとオーディオ再生 2024/11/02
yusukeito
0
320
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Visualization
eitanlees
145
15k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Code Reviewing Like a Champion
maltzj
520
39k
A better future with KSS
kneath
238
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Designing for humans not robots
tammielis
249
25k
Building Applications with DynamoDB
mza
90
6.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
The Language of Interfaces
destraynor
154
24k
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/