{"id":852,"date":"2014-11-13T12:04:01","date_gmt":"2014-11-13T15:04:01","guid":{"rendered":"http:\/\/blog.abratel.com.br\/?p=852"},"modified":"2014-11-13T12:06:57","modified_gmt":"2014-11-13T15:06:57","slug":"instalar-sensor-de-temperatura-nagios-termometro","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=852","title":{"rendered":"Instalar sensor de temperatura &#8211; Nagios &#8211; Termometro"},"content":{"rendered":"<p>Este sensor abaixo pode ser comprado nos sites da china por menos de R$40,00.<\/p>\n<p><center><a href=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/11\/temper_usb_m.jpg\"><img loading=\"lazy\" src=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/11\/temper_usb_m-300x224.jpg\" alt=\"temper_usb_m\" width=\"300\" height=\"224\" class=\"alignnone size-medium wp-image-853\" srcset=\"https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/11\/temper_usb_m-300x224.jpg 300w, https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/11\/temper_usb_m.jpg 448w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/center><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nyum install gcc libusb-devel libusb\r\n\r\n# download software:\r\nwget http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/11\/pcsensor-master.tar\r\n# unzip\r\ntar -zvf pcsensor-master.tar\r\ncd pcsensor-master\r\nmake clean\r\nmake\r\ncd \/usr\/src\/pcsensor\r\n.\/pcsensor\r\n     2014\/11\/13 12:57:38 Temperature 81.72F 27.62C\r\n\r\n\r\n\r\n[root@zeus uferes]# whereis lsusb\r\nlsusb: \/sbin\/lsusb \/usr\/share\/man\/man8\/lsusb.8.gz\r\n[root@zeus uferes]#  \/sbin\/lsusb\r\nBus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub\r\nBus 005 Device 002: ID 0557:2304 ATEN International Co., Ltd\r\nBus 006 Device 001: ID 0000:0000\r\nBus 008 Device 001: ID 0000:0000\r\n&lt;strong&gt;Bus 003 Device 005: ID 0c45:7401 Microdia TEMPer Temperature Sensor&lt;\/strong&gt;\r\n\r\n<\/pre>\n<p>Criar script para nagios check_temper<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n# script para checar a temperatura do DC\r\n# exit 1 = warning; exit 2 = Critico; exit 3 = Unknown\r\n\r\n\r\ntempe=$(\/usr\/local\/bin\/pcsensor | awk '{print $5} ' | cut -c 1-2)\r\ntemperatura=$(\/usr\/local\/bin\/pcsensor)\r\nif [ $tempe -lt &quot;32&quot; ] ;  then # se for menor (is less)\r\n        echo &quot;Temperatura atual do Data Center: $temperatura&quot;\r\n        exit 0;\r\nelif  [ $tempe -lt &quot;34&quot; ] ;  then\r\n        echo &quot;Temperatura no Data Center: $temperatura&quot;\r\n        exit 1;\r\nelif  [ $tempe -lt &quot;60&quot; ] ;  then\r\n        echo &quot;Temperatura no Data Center: $temperatura&quot;\r\n        exit 2;\r\nelse\r\n        echo &quot;Aguarde nova checagem de temperatura em 2 minutos...&quot;\r\n        exit 3;\r\nfi\r\nexit 3;\r\n\r\n<\/pre>\n<p><strong>Para testar o termometro ligado em outro servidor:<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nservices.cfg\r\n\r\ndefine service{\r\n  use                             local-service         ; Name of service template to use\r\n  host_name                       servidor_em_que_esta_o_termometro\r\n  service_description             Checa a temperatura no DataCenter\r\n  check_command                   check_themper_by_ssh\r\n  check_period                    24x7\r\n  }\r\n\r\ndefine command {\r\n        command_name check_themper_by_ssh\r\n        command_line  $USER1$\/check_by_ssh -H $HOSTADDRESS$ -4 -C &quot;sudo \/usr\/src\/pcsensor\/check_themper&quot;\r\n}\r\n<\/pre>\n<p><strong>Para usar no nagios do proprio servidor:<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndefine service{\r\n  use                             local-service         ; Name of service template to use\r\n  host_name                       localhost\r\n  service_description             Checa a temperatura no DataCenter\r\n  check_command                   check_themper\r\n  check_period                    24x7\r\n  }\r\n\r\ndefine command {\r\n        command_name check_themper_by_ssh\r\n        command_line  $USER1$\/check_themper\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Este sensor abaixo pode ser comprado nos sites da china por menos de R$40,00. Criar script para nagios check_temper Para testar o termometro ligado em outro servidor: Para usar no nagios do proprio servidor:<\/p>\n","protected":false},"author":1,"featured_media":856,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/852"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=852"}],"version-history":[{"count":3,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/852\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/852\/revisions\/858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/media\/856"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}