Slide 1

Slide 1 text

ZabbixAPIΛͭΜͭΜͨ͠ OSC2021 Online/Nagoya( community = “Python౦ւ”, 
 date = “2021/05/29”, location = [“Zoom”, “YoutubeLive”] )

Slide 2

Slide 2 text

Zabbixɺ͝ଘ஌Ͱ͔͢ʁ

Slide 3

Slide 3 text

৭ʑͳπʔϧΛ؂ࢹͰ͖Δ 
 Φʔϓϯιʔειϑτ΢ΣΞͰ͢

Slide 4

Slide 4 text

https://www.zabbix.com/jp/features ΑΓ

Slide 5

Slide 5 text

͓࢓ࣄ͔ΒΑ͘࢖͏ͷͰ͕͢ɺ ࡉʑͱͨ͠ॲཧΛWebͰϙνϙν͸ ਏ͍ͷͰAPIΛΑ͘ୟ͖·͢

Slide 6

Slide 6 text

طʹZabbixAPIΛ؆୯ʹ࢖͑Δ PythonϞδϡʔϧ͸ଟ͍ͷͰ͕͢

Slide 7

Slide 7 text

ZabbixυΩϡϝϯτʹ͋Δ 
 αϯϓϧJSONΛ ௚઀ίϐϖͰ͖Δ΄͏͕ ݸਓతʹ͸ָͩͬͨͷͰ

Slide 8

Slide 8 text

ͦΜͳπʔϧΛ࿉੒͠·ͨ͠

Slide 9

Slide 9 text

https://github.com/2bobo/pyzbxtool

Slide 10

Slide 10 text

Կ͕Ͱ͖Δ͔? • API΁ͷϩάΠϯͱϩάΠϯ৘ใͷอ࣋ • API༻ͷJSONΛ౤͚͛ͭΔͱ݁ՌΛड͚औΔ

Slide 11

Slide 11 text

ͱ͍͏͘Β͍Կ΋ͯ͘͠Ε·ͤΜ

Slide 12

Slide 12 text

ͦͷ୅ΘΓ؆୯Ͱ͢

Slide 13

Slide 13 text

࢖͍ํ 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)

Slide 14

Slide 14 text

ެࣜυΩϡϝϯτͷ JSONΛίϐϖ͢Ε͹OK https://www.zabbix.com/documentation/current/manual/api/reference/apiinfo/version

Slide 15

Slide 15 text

؆୯Ͱ͠ΐʁ

Slide 16

Slide 16 text

ߋʹࠓͳΒͳΜͱʂʂ

Slide 17

Slide 17 text

ZabbixSenderػೳ΋ ηοτʹ!!

Slide 18

Slide 18 text

Zabbix Sender? • Zabbixʹ؂ࢹσʔλΛ౤͚͛ͭΔϞϊ • ϗετ΍Ωʔɺ஋Λࢦఆͯ͠ZabbixServerʹૹΔͷ͕ͩɺಠࣗͷύ έοτͰ௨৴͞ΕΔ • ZabbixͰ΋ఏڙ͞Ε͍ͯΔ͕ɺPython͔Β௚઀౤͛ΕΔͱRasPiͱ͔ Ͱ࢖͏ͱ͖ʹָ

Slide 19

Slide 19 text

࢖͍ํ import pyzbx-tool zbx_sender = pyzbx-tool.ZabbixSender("zabbix_server_ip", "10051") zbx_sender.add("host", "key", "value") result = zbx_sender.send() print(result)

Slide 20

Slide 20 text

͜Ε΋؆୯Ͱ͠ΐʁ

Slide 21

Slide 21 text

ຊདྷ͸෼͚ͨ΄͏͕Α͍ػೳͰ͕͢ ݸਓతʹΑ͘࢖͏ػೳΛࡶʹ 
 ·ͱΊ͚ͨͩͩͬͨΓ͠·͢

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

ͱ͍͏͜ͱͰɺ Pythonͷ࿩ͳͷ͔Zabbixͷ࿩ͳͷ͔ Α͘Θ͔Βͳ͍࿩Ͱͨ͠

Slide 24

Slide 24 text

͜ΜͳLTͰ΋OKͳPython౦ւʹ ੋඇ͝ࢀՃ͍ͩ͘͞

Slide 25

Slide 25 text

࣍ճ͸8ʙ9݄ࠒʹ։࠵༧ఆͰ͢