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
320
ZabbixAPIをつんつんした
OSC Nagoya 2021
Pyhton東海/JuliaTokai 合同ミニ勉強会
発表資料
2bo
June 03, 2021
Tweet
Share
More Decks by 2bo
See All by 2bo
巨大ガジェット買ってみた
2bo
0
430
PyScriptの話
2bo
0
180
名古屋とお菓子🍪
2bo
0
310
名古屋 勉強会 会場 選定 2019
2bo
2
140
お城Pythonの作り方/OshiroPython
2bo
1
610
Python勉強法
2bo
0
780
Python 環境構築方法 2016
2bo
2
1.6k
Python東海の紹介(仮).py
2bo
0
330
pep8を読んでみよう.pdf
2bo
0
210
Other Decks in Programming
See All in Programming
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
940
Uncharted packages (Laravel Live Denmark)
freekmurze
0
140
初めてのiOS関連GitHub ActionsをMarketplaceに公開するまでの実録
konifar
3
200
Rubyのobject_id
qnighy
6
1.3k
座談会 「Strict ConcurrencyとSwift 6が開く新時代: 私たちはどう生きるか?」
shiz
4
2.9k
Boost Your Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
1
930
Rustではじめる負荷試験
skanehira
5
1.1k
The Future of Frontend i18n : Intl.MessageFormat
sajikix
1
2.4k
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
BasicBasic認証
sadnessojisan
5
2.5k
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
100
Swiftコードバトル必勝法
toshi0383
0
140
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
228
18k
How to train your dragon (web standard)
notwaldorf
85
5.6k
Being A Developer After 40
akosma
82
580k
Design by the Numbers
sachag
277
19k
Building an army of robots
kneath
302
42k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
34
1.9k
5 minutes of I Can Smell Your CMS
philhawksworth
201
19k
Music & Morning Musume
bryan
46
6k
Mobile First: as difficult as doing things right
swwweet
220
8.8k
Code Reviewing Like a Champion
maltzj
518
39k
Intergalactic Javascript Robots from Outer Space
tanoku
268
26k
Debugging Ruby Performance
tmm1
72
12k
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݄ࠒʹ։࠵༧ఆͰ͢