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
530
PyScriptの話
2bo
0
210
名古屋とお菓子🍪
2bo
0
330
名古屋 勉強会 会場 選定 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
240
Other Decks in Programming
See All in Programming
Full stack testing :: basic to basic
up1
1
930
talk-with-local-llm-with-web-streams-api
kbaba1001
0
180
선언형 UI에서의 상태관리
l2hyunwoo
0
150
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
370
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
Rails Girls Zürich Keynote
gr2m
94
13k
The Pragmatic Product Professional
lauravandoore
32
6.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Being A Developer After 40
akosma
87
590k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Music & Morning Musume
bryan
46
6.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
How STYLIGHT went responsive
nonsquared
95
5.2k
Six Lessons from altMBA
skipperchong
27
3.5k
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݄ࠒʹ։࠵༧ఆͰ͢