{"id":710,"date":"2024-05-08T09:27:37","date_gmt":"2024-05-08T06:27:37","guid":{"rendered":"http:\/\/rantivi.ru\/?p=710"},"modified":"2024-06-14T14:24:00","modified_gmt":"2024-06-14T11:24:00","slug":"%d1%82%d0%b5%d1%80%d0%bc%d0%be%d0%b4%d0%b0%d1%82%d1%87%d0%b8%d0%ba-%d0%b4%d0%bb%d1%8f-zabbix","status":"publish","type":"post","link":"https:\/\/rantivi.ru\/?p=710","title":{"rendered":"\u0422\u0435\u0440\u043c\u043e\u0434\u0430\u0442\u0447\u0438\u043a \u0434\u043b\u044f Zabbix"},"content":{"rendered":"\n<h3 class=\"wp-block-heading has-text-align-center\">\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u041e\u0441\u043d\u043e\u0432\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2014<a href=\"https:\/\/www.wildberries.ru\/catalog\/171066665\/detail.aspx\" data-type=\"link\" data-id=\"https:\/\/www.wildberries.ru\/catalog\/171066665\/detail.aspx\">&nbsp;Arduino UNO R3<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.wildberries.ru\/catalog\/120466630\/detail.aspx\" target=\"_blank\" rel=\"noreferrer noopener\">\u041c\u043e\u0434\u0443\u043b\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438<\/a>&nbsp;(ethernet-shield W5100)<\/li>\n\n\n\n<li>\u0418, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439&nbsp;<a href=\"https:\/\/www.wildberries.ru\/catalog\/166557833\/detail.aspx?targetUrl=EX\" target=\"_blank\" rel=\"noreferrer noopener\">\u0434\u0430\u0442\u0447\u0438\u043a \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b<\/a>&nbsp;\u043d\u0430 \u0431\u0430\u0437\u0435 DS18B20<\/li>\n\n\n\n<li><a href=\"https:\/\/www.arduino.cc\/en\/Main\/Software\">Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<div style=\"height:37px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430. \u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u0434\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443 \u00ab\u0431\u0443\u0442\u0435\u0440\u0431\u0440\u043e\u0434\u043e\u043c\u00bb, \u0442\u0435\u0440\u043c\u043e\u0434\u0430\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u043f\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u0435\u0433\u043e \u043f\u0438\u043d\u0430\u043c \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0435 \u0448\u0442\u044b\u0440\u044c\u043a\u0438. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430: \u043a\u0440\u0430\u0441\u043d\u044b\u0439 +5 \u0412, \u0447\u0451\u0440\u043d\u044b\u0439 \u2014 \u0437\u0435\u043c\u043b\u044f, \u0436\u0451\u043b\u0442\u044b\u0439 \u2014 \u0434\u0430\u043d\u043d\u044b\u0435; \u043c\u0435\u0436\u0434\u0443 +5V \u0438 Data \u043f\u0440\u0438\u043f\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440 4,7 \u043a\u041e\u043c.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"159\" src=\"http:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-24.png\" alt=\"\" class=\"wp-image-711\" srcset=\"https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-24.png 466w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-24-300x102.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/figure>\n\n\n\n<div style=\"height:37px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"596\" src=\"http:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-25.png\" alt=\"\" class=\"wp-image-717\" style=\"width:419px;height:auto\" srcset=\"https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-25.png 787w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-25-300x227.png 300w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-25-768x582.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/figure>\n\n\n\n<div style=\"height:37px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439.<\/p>\n\n\n\n<p>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438 \u0438 \u043f\u0440\u0438\u0442\u0432\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u0431\u0431\u0438\u043a\u0441-\u0430\u0433\u0435\u043d\u0442\u043e\u043c, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0431\u043c\u0435\u043d\u0430 \u0441 \u0437\u0430\u0431\u0431\u0438\u043a\u0441-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c&nbsp;<a href=\"https:\/\/www.zabbix.com\/documentation\/3.2\/manual\/appendix\/items\/activepassive\">\u043e\u043f\u0438\u0441\u0430\u043d<\/a>&nbsp;\u0432&nbsp;<a href=\"http:\/\/zabbix.org\/wiki\/Docs\/protocols\/zabbix_agent\/3.2\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n\n\n\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 microDS18B20.h<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"840\" height=\"451\" src=\"http:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-26.png\" alt=\"\" class=\"wp-image-718\" srcset=\"https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-26.png 840w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-26-300x161.png 300w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-26-768x412.png 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"380\" height=\"413\" src=\"http:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-27.png\" alt=\"\" class=\"wp-image-719\" srcset=\"https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-27.png 380w, https:\/\/rantivi.ru\/wp-content\/uploads\/2024\/05\/image-27-276x300.png 276w\" sizes=\"auto, (max-width: 380px) 100vw, 380px\" \/><\/figure>\n\n\n\n<p>\u041a\u043e\u0434<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;microDS18B20.h&gt;\n#include &lt;Ethernet.h&gt;\n\nbyte mac&#91;] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; \/\/ random MAC\nbyte ip&#91;] = { 192, 168, 29, 5 };                      \/\/ip\nbyte subnet&#91;] = { 255, 255, 252, 0 };\nString readString = String(64); \n\nMicroDS18B20 &lt;A4&gt; ds;\nEthernetServer server(10050); \/\/ Zabbix port\n\n\/\/ Zabbix protocol description:\n\/\/ https:\/\/www.zabbix.com\/documentation\/1.8\/protocols\n\/\/ https:\/\/www.zabbix.com\/documentation\/1.8\/protocols\/agent\n\nvoid setup() {\n  delay(500); \n  \n  \/\/ start the Ethernet connection:\n  Ethernet.begin(mac, ip, subnet);\n  server.begin();\n\n}\n\nvoid loop() {\n  byte l;\n  float celsius;\n\n  readString = \"\";\n  l = 0;\n  if (EthernetClient client = server.available())\n  {\n    while (client.connected()) {\n      if (client.available()) {\n        if (l &lt; 63) {\n          char c = client.read();\n          readString.concat(c);\n          l = readString.length();\n        }\n        if ((l &gt; 5) &amp; (l == (byte)readString&#91;5] + 13)) \/\/ end of query from zabbix server \n          {\n            String request = readString.substring(13);\n            if (request.endsWith(\"\\n\")) {\n              request.remove(request.length() - 1); \n            }\n            if (request.equals(\"agent.ping\")) {\n              client.print(\"ZBXD\\x01\"); \/\/ reply header\n              byte replyBytes &#91;] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, '1'}; \/\/4 bytes - length, 4 - reserved, 1 - data\n              client.write(replyBytes, 9);\n            } \n            else \n            if (request.equals(\"env.temp\")) {\n              ds.requestTemp();\n              delay(1000);\n              ds.readTemp();\n              \n              celsius = ds.getTemp();\n              client.print(\"ZBXD\\x01\"); \/\/ reply header\n              byte replyBytes &#91;] = {(byte) String(celsius).length(), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; \/\/4 bytes - length, 4 - reserved\n              client.write(replyBytes, 8);\n              client.print(celsius);\n            }\n          else {\n            client.print(\"ZBXD\\x01\"); \/\/ reply header\n            byte replyBytes &#91;] = {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; \/\/4 bytes - length, 4 - reserved\n            client.write(replyBytes, 8);\n            client.print(\"ZBX_NOTSUPPORTED\");\n          }\n          break;\n        }\n      }\n    }\n    delay(10);\n    client.stop();\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f ethernet-\u043a\u0430\u0431\u0435\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ zabbix_get -s 192.168.29.5 -k agent.ping\n1\n$ zabbix_get -s 192.168.29.5 -k env.temp\n23.12\n$ zabbix_get -s 192.168.29.5 -k bla-blah\nZBX_NOTSUPPORTED<\/code><\/pre>\n\n\n\n<p>\u0412 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u0437\u0430\u0431\u0431\u0438\u043a\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u044b\u0439 \u0445\u043e\u0441\u0442 \u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c IP, \u0432 \u043d\u0451\u043c \u2014 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430(\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445), Numeric (unsigned) agent.ping \u0438 Numeric (float) env.temp, \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u0413\u0440\u0430\u0444\u0438\u043a\u0438, \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u2014 \u0432\u0441\u0451 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e.<\/p>\n\n\n\n<p>\u041f\u0438\u0442\u0430\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u0447\u0435\u0440\u0435\u0437 \u0440\u043e\u0434\u043d\u043e\u0439 USB. \u041a\u043e\u0440\u043f\u0443\u0441 \u2014 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e: \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u043f\u043b\u0430\u0441\u0442\u0438\u043a\u043e\u0432\u0430\u044f \u043a\u043e\u0440\u043e\u0431\u043e\u0447\u043a\u0430, \u0442\u0435\u0440\u043c\u043e\u0443\u0441\u0430\u0434\u043a\u0430, \u0441\u0438\u043d\u044f\u044f \u0438\u0437\u043e\u043b\u0435\u043d\u0442\u0430.<\/p>\n\n\n\n<div style=\"height:35px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: \u0421\u0431\u043e\u0440\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430. \u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u0434\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443 \u00ab\u0431\u0443\u0442\u0435\u0440\u0431\u0440\u043e\u0434\u043e\u043c\u00bb, \u0442\u0435\u0440\u043c\u043e\u0434\u0430\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u043f\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u0435\u0433\u043e \u043f\u0438\u043d\u0430\u043c \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0435 \u0448\u0442\u044b\u0440\u044c\u043a\u0438. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430: \u043a\u0440\u0430\u0441\u043d\u044b\u0439 +5 \u0412, \u0447\u0451\u0440\u043d\u044b\u0439 \u2014 \u0437\u0435\u043c\u043b\u044f, \u0436\u0451\u043b\u0442\u044b\u0439 \u2014 \u0434\u0430\u043d\u043d\u044b\u0435; \u043c\u0435\u0436\u0434\u0443 +5V \u0438 Data \u043f\u0440\u0438\u043f\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440 4,7 \u043a\u041e\u043c. \u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439. \u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"wp-custom-template-1","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-710","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/posts\/710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rantivi.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=710"}],"version-history":[{"count":8,"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions"}],"predecessor-version":[{"id":1166,"href":"https:\/\/rantivi.ru\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions\/1166"}],"wp:attachment":[{"href":"https:\/\/rantivi.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rantivi.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rantivi.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}