{"id":5069,"date":"2024-01-13T19:30:01","date_gmt":"2024-01-13T11:30:01","guid":{"rendered":"https:\/\/www.kenpai.com\/cms\/5069\/"},"modified":"2024-01-13T19:30:01","modified_gmt":"2024-01-13T11:30:01","slug":"nagios%e7%9b%91%e6%8e%a7%ef%bc%88%e4%ba%8c%ef%bc%89%e4%b9%8b%e7%9b%91%e6%8e%a7windows-server%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.kenpai.com\/cms\/5069\/","title":{"rendered":"nagios\u76d1\u63a7\uff08\u4e8c\uff09\u4e4b\u76d1\u63a7windows server\u670d\u52a1\u5668"},"content":{"rendered":"<\/p>\n<p><strong>\u6458\u8981<\/strong> <br \/>\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528nagios\u901a\u8fc7nsclient\u76d1\u63a7windows\u4e3b\u673a\u3002 <br \/>\u6b64\u6b21\u5b9e\u9a8c\u73af\u5883\u57fa\u4e8e\u4e0a\u7bc7\u6587\u7ae0\uff0c\u76d1\u63a7\u7aef\u5728Linux\u73af\u5883\u4e0b\uff0cWindows\u670d\u52a1\u5668\u4f7f\u7528\u7684\u65f6windows server 2012\u3002<\/p>\n<p style=\"text-align:\">\n<p><strong>1. \u5b89\u88c5NSClient  <\/strong> <br \/>\u8bbf\u95eehttp:\/\/nsclient.org\/nscp\/\u4e0b\u8f7dNSClient  \uff0c\u8fd9\u91cc\u6211\u4f7f\u7528\u7684\u662fNSCP-0.4.3.143-x64\u7684msi\u5b89\u88c5\u5305\u3002\u4e0b\u8f7d\u4e4b\u540e\u76f4\u63a5\u5b89\u88c5\uff0c\u8fc7\u7a0b\u4e2d\u4f1a\u63d0\u793a\u8f93\u5165Nagios\u76d1\u63a7\u670d\u52a1\u5668\u5730\u5740\u548c\u5bc6\u7801\u3002\u5730\u5740\u586b\u5199\u6b63\u786e\uff0c\u5bc6\u7801\u4e0d\u7528\u8bbe\u7f6e\u3002Nagios\u76d1\u63a7\u670d\u52a1\u5668\u4e8b\u5148\u5728\u76d1\u63a7Linux\u670d\u52a1\u5668\u65f6\u5019\u5df2\u7ecf\u642d\u5efa\u597d\uff0c\u9700\u8981\u7684\u5c0f\u4f19\u4f34\u770b\u8fd9\u91cc\u3002<\/p>\n<p><strong>2.\u914d\u7f6eNSClient  <\/strong> <br \/>\u5728 NSClient   \u7684\u5b89\u88c5\u76ee\u5f55\u6253\u5f00 nsclient.ini\uff0c\u5c06\u76d1\u63a7\u670d\u52a1\u5668\u7684IP\u5730\u5740\u52a0\u5230 allowed hosts \u6307\u4ee4\u540e\u9762\u3002 <br \/>\u7136\u540e\u68c0\u67e5\u4e0b12489\u7aef\u53e3\u662f\u5426\u6b63\u5e38\u76d1\u542c <br \/>netstat -an | more<\/p>\n<p>\u56e0\u4e3a\u5b89\u88c5\u65f6\u5019\u9700\u8981\u7684\u6a21\u5757\u5df2\u7ecf\u52fe\u9009\u4e86\uff0c\u6240\u4ee5\u914d\u7f6e\u6587\u4ef6\u4e2d\u4e0d\u7528\u518d\u4f5c\u8bbe\u7f6e\u3002\u5426\u5219\u53ef\u4ee5\u901a\u8fc7\u53bb\u6389\u6bcf\u4e2a\u6a21\u5757\u524d\u7684;\u6765\u542f\u7528\u8be5\u6a21\u5757\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\u5373\u5b8c\u6210\u4e86Windows Server 2012\u4e0a\u7684\u914d\u7f6e\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u8bbe\u7f6eNagios\u76d1\u63a7\u670d\u52a1\u5668\u3002<\/p>\n<p><strong>3.Nagios\u76d1\u63a7\u670d\u52a1\u5668\u8bbe\u7f6e<\/strong> <br \/>vi \/usr\/local\/nagios\/etc\/nagios.cfg <br \/>\u641c\u7d22\u627e\u5230\uff1a <br \/>Definitions for monitoring a Windows machine <br \/>cfg_file=\/usr\/local\/nagios\/etc\/objects\/windows.cfg <br \/>\u5c06\u7b2c\u4e8c\u884c\u7684#\u53bb\u6389\u6253\u5f00Nagios\u76d1\u63a7\u7684Windows\u6a21\u5757\uff0c\u7136\u540e\u4fdd\u5b58\u3002 <\/p>\n<p>\u63a5\u7740\u7f16\u8f91 <br \/>\u627e\u5230\u5e76\u8bbe\u7f6e\u76d1\u63a7\u7684\u670d\u52a1\u5668\uff1a <br \/>\u8bbe\u7f6e\u88ab\u76d1\u63a7\u4e3b\u673a\u540d\u548c\u88ab\u76d1\u63a7\u7684Windows\u670d\u52a1\u5668\u5730\u5740\u3002 <br \/><strong>\u6b64\u5730\u5740\u4e3aLinux\u670d\u52a1\u7aef\u7684ip\u5730\u5740<\/strong><\/p>\n<p>vi \/usr\/local\/nagios\/etc\/objects\/windows.cfg define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we\\\\\\&#8217;re giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.0.2 ; IP address of the host }<\/p>\n<p>\u63a5\u4e0b\u6765\u641c\u7d22\u5404\u79cd\u76d1\u63a7\u7684\u670d\u52a1\u5e76\u8bbe\u7f6e\uff1a<\/p>\n<p>#\u76d1\u63a7NSClient\u7248\u672c\u3002 Create a service for monitoring the version of NSCLient   that is installed Change the host_name to match the name of the host you defined above  define service{ use generic-service host_name winserver service_description NSClient   Version check_command check_nt!CLIENTVERSION }  #\u76d1\u63a7\u670d\u52a1\u5668\u5728\u7ebf\u65f6\u95f4\u3002 Create a service for monitoring the uptime of the server Change the host_name to match the name of the host you defined above  define service{ use generic-service host_name winserver service_description Uptime check_command check_nt!UPTIME }   #\u76d1\u63a7\u670d\u52a1\u5668CPU\u8d1f\u8f7d\u3002 Create a service for monitoring CPU load Change the host_name to match the name of the host you defined above  define service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 20,30,50 }   #\u76d1\u63a7\u670d\u52a1\u5668\u7684\u5185\u5b58\u5360\u7528\u3002  Create a service for monitoring memory usage  Change the host_name to match the name of the host you defined above  define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 }   #\u76d1\u63a7\u7cfb\u7edfC\u76d8\u7684\u78c1\u76d8\u5360\u7528\u3002 Create a service for monitoring C: disk usage Change the host_name to match the name of the host you defined above  define service{ use generic-service host_name winserver service_description C: Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 }<\/p>\n<p>\u8fdb\u5165\u76ee\u5f55 \/usr\/local\/nagios\/libexec\/ <br \/>\u5728nagios\u76d1\u63a7\u7aef\u9a8c\u8bc1\u662f\u5426\u53ef\u4ee5\u76d1\u63a7\u5230windows\u4e3b\u673a\uff0c\u7528\u547d\u4ee4.\/check_nt -H 192.168.13.132 -p 12489 -v UPTIME\u53ef\u4ee5\u68c0\u6d4b\u5230Windows\u670d\u52a1\u5668\u5df2\u7ecf\u542f\u52a8\u7684\u65f6\u957f\uff0c\u4e5f\u8868\u793a\u53ef\u4ee5\u4eceWindows\u670d\u52a1\u5668\u62ff\u5230\u6570\u636e\u4e86\u3002 <\/p>\n<p>\u73b0\u5728\u5c31\u53ef\u4ee5\u767b\u5f55\u5230nagios\u7684web\u754c\u9762\uff0c\u67e5\u770b\u4f60\u7684\u76d1\u63a7\u4fe1\u606f\u4e86 <\/p>\n<p>\u66f4\u591a\u5173\u4e8e\u4e91\u670d\u52a1\u5668\uff0c<span class='wp_keywordlink'><a href=\"https:\/\/www.kenpai.com\/domain.html\" title=\"\u57df\u540d\u6ce8\u518c\" target=\"_blank\">\u57df\u540d<\/a><\/span>\u6ce8\u518c\uff0c\u865a\u62df\u4e3b\u673a\u7684\u95ee\u9898\uff0c\u8bf7\u8bbf\u95ee<span class='wp_keywordlink'><a href=\"https:\/\/www.kenpai.com\/\" title=\"\u57a6\u6d3e\u79d1\u6280\u5b98\u7f51\" target=\"_blank\">\u57a6\u6d3e\u79d1\u6280<\/a><\/span>\u5b98\u7f51\uff1a<span class='wp_keywordlink'><a href=\"https:\/\/www.kenpai.com\/\" title=\"\u57a6\u6d3e\u79d1\u6280\u5b98\u7f51\" target=\"_blank\">www.kenpai.com<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528nagios\u901a\u8fc7nsclient\u76d1\u63a7windows\u4e3b\u673a\u3002 \u6b64\u6b21\u5b9e\u9a8c\u73af\u5883\u57fa\u4e8e\u4e0a\u7bc7\u6587\u7ae0\uff0c\u76d1\u63a7\u7aef\u5728Linux\u73af\u5883\u4e0b\uff0cWindows\u670d\u52a1<\/p>\n","protected":false},"author":2,"featured_media":4348,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3322],"tags":[3941],"class_list":["post-5069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ktougao","tag-nagioswindows-server"],"_links":{"self":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts\/5069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/comments?post=5069"}],"version-history":[{"count":0,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/posts\/5069\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/media\/4348"}],"wp:attachment":[{"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/media?parent=5069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/categories?post=5069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kenpai.com\/cms\/wp-json\/wp\/v2\/tags?post=5069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}