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
ZabbixAPIをつんつんした
Search
2bo
June 03, 2021
Programming
0
330
ZabbixAPIをつんつんした
OSC Nagoya 2021
Pyhton東海/JuliaTokai 合同ミニ勉強会
発表資料
2bo
June 03, 2021
Tweet
Share
More Decks by 2bo
See All by 2bo
巨大ガジェット買ってみた
2bo
0
510
PyScriptの話
2bo
0
200
名古屋とお菓子🍪
2bo
0
320
名古屋 勉強会 会場 選定 2019
2bo
2
140
お城Pythonの作り方/OshiroPython
2bo
1
620
Python勉強法
2bo
0
800
Python 環境構築方法 2016
2bo
2
1.7k
Python東海の紹介(仮).py
2bo
0
330
pep8を読んでみよう.pdf
2bo
0
230
Other Decks in Programming
See All in Programming
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
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
920
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
Click-free releases & the making of a CLI app
oheyadam
2
120
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
290
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
CSC509 Lecture 11
javiergs
PRO
0
180
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Code Reviewing Like a Champion
maltzj
520
39k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Transcript
ZabbixAPIΛͭΜͭΜͨ͠ OSC2021 Online/Nagoya( community = “Python౦ւ”, date = “2021/05/29”,
location = [“Zoom”, “YoutubeLive”] )
Zabbixɺ͝ଘͰ͔͢ʁ
৭ʑͳπʔϧΛࢹͰ͖Δ ΦʔϓϯιʔειϑτΣΞͰ͢
https://www.zabbix.com/jp/features ΑΓ
͓ࣄ͔ΒΑ͘͏ͷͰ͕͢ɺ ࡉʑͱͨ͠ॲཧΛWebͰϙνϙν ਏ͍ͷͰAPIΛΑ͘ୟ͖·͢
طʹZabbixAPIΛ؆୯ʹ͑Δ PythonϞδϡʔϧଟ͍ͷͰ͕͢
ZabbixυΩϡϝϯτʹ͋Δ αϯϓϧJSONΛ ίϐϖͰ͖Δ΄͏͕ ݸਓతʹָͩͬͨͷͰ
ͦΜͳπʔϧΛ࿉͠·ͨ͠
https://github.com/2bobo/pyzbxtool
Կ͕Ͱ͖Δ͔? • APIͷϩάΠϯͱϩάΠϯใͷอ࣋ • API༻ͷJSONΛ͚͛ͭΔͱ݁ՌΛड͚औΔ
ͱ͍͏͘Β͍Կͯ͘͠Ε·ͤΜ
ͦͷΘΓ؆୯Ͱ͢
͍ํ import pyzbx-tool zbx_api = pyzbx-tool.ZabbixAPI("http://example.com", "Admin", "zabbix") version_json =
{ "jsonrpc": "2.0", "method": "apiinfo.version", "params": [], "auth": "", "id": 1 } version = zbx_api.call_api(version_json) print(version)
ެࣜυΩϡϝϯτͷ JSONΛίϐϖ͢ΕOK https://www.zabbix.com/documentation/current/manual/api/reference/apiinfo/version
؆୯Ͱ͠ΐʁ
ߋʹࠓͳΒͳΜͱʂʂ
ZabbixSenderػೳ ηοτʹ!!
Zabbix Sender? • ZabbixʹࢹσʔλΛ͚͛ͭΔϞϊ • ϗετΩʔɺΛࢦఆͯ͠ZabbixServerʹૹΔͷ͕ͩɺಠࣗͷύ έοτͰ௨৴͞ΕΔ • ZabbixͰఏڙ͞Ε͍ͯΔ͕ɺPython͔Β͛ΕΔͱRasPiͱ͔ Ͱ͏ͱ͖ʹָ
͍ํ import pyzbx-tool zbx_sender = pyzbx-tool.ZabbixSender("zabbix_server_ip", "10051") zbx_sender.add("host", "key", "value")
result = zbx_sender.send() print(result)
͜Ε؆୯Ͱ͠ΐʁ
ຊདྷ͚ͨ΄͏͕Α͍ػೳͰ͕͢ ݸਓతʹΑ͘͏ػೳΛࡶʹ ·ͱΊ͚ͨͩͩͬͨΓ͠·͢
None
ͱ͍͏͜ͱͰɺ Pythonͷͳͷ͔Zabbixͷͳͷ͔ Α͘Θ͔Βͳ͍Ͱͨ͠
͜ΜͳLTͰOKͳPython౦ւʹ ੋඇ͝ࢀՃ͍ͩ͘͞
࣍ճ8ʙ9݄ࠒʹ։࠵༧ఆͰ͢