{"id":7401,"date":"2024-04-04T21:01:02","date_gmt":"2024-04-04T13:01:02","guid":{"rendered":""},"modified":"2024-04-04T21:01:02","modified_gmt":"2024-04-04T13:01:02","slug":"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7401.html","title":{"rendered":"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u6ce8\uff1a\u672c\u73af\u5883\u9ed8\u8ba4\u5b89\u88c5\u5728\/usr\/local\/nagios\u4e2d nagios\u7248\u672c\uff1anagios-4.2.4 \u63d2\u4ef6\u7248\u672c\uff1anagios-plugins-2.1.2
\u672c\u73af\u5883\u9ed8\u8ba4\u9632\u706b\u5899\u5173\u95ed\uff1asystemctl stop firewalld<\/p>\n

\u5b9e\u9a8c\u73af\u5883\u5982\u4e0b\uff1a<\/h5>\n
\n

<\/center> <\/p>\n


\n<\/center> <\/p>\n\n\n\n\n\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

\u672c\u6587\u57fa\u4e8ecentos\u6700\u5c0f\u5316\u5b89\u88c5
\u672c\u6587\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a
1. Nagios\u4ecb\u7ecd\u548cyum \u5b89\u88c5web\u73af\u5883
2. Nagios4.2\u6e90\u7801\u5305\u7f16\u8bd1
3. Nagios\u63d2\u4ef6\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u4ee5\u53ca\u914d\u7f6e\u89e3\u8bfb
4. Nagios\u5b9e\u73b0\u90ae\u4ef6\u544a\u8b66
5. Nagios \u4f7f\u7528nrpe\u76d1\u63a7\u8fdc\u7a0bLinux
6. Nagios\u5b89\u88c5pnp4nagios\u5b9e\u73b0\u7ed8\u56fe<\/p>\n


\n

\u4e00 Nagios\u4ecb\u7ecd\u548cyum\u5b89\u88c5web\u73af\u5883<\/h3>\n
\n

1.1 \u5b89\u88c5apache+php\u73af\u5883<\/p>\n

yum install<\/span> -y httpd php  <\/code><\/pre>\n

1.2 \u8bbe\u7f6eapache\u548c\u81ea\u52a8\u542f\u52a8 <\/p>\n

systemctl restart httpd #\u542f\u52a8httpd<\/span>\nsystemclt enable httpd  #\u8bbe\u7f6e\u4e3a\u5f00\u673a\u9ed8\u8ba4\u542f\u52a8<\/span><\/code><\/pre>\n

1.3 \u6d4b\u8bd5apache\u662f\u5426\u542f\u52a8 \/var\/www\/html\/index.html<\/p>\n

<html<\/span>><\/span>\n<head<\/span>><\/span>test apache<\/head<\/span>><\/span>\n<body<\/span>><\/span>\n    <h1<\/span>><\/span>test apache <\/h1<\/span>><\/span>\n<\/body<\/span>><\/span>\n<\/html<\/span>><\/span><\/code><\/pre>\n

1.4 \u6d4b\u8bd5apache+php\u662f\u5426\u542f\u52a8\u6210\u529f\/var\/www\/html\/test.php<\/p>\n

<?php<\/span> echo<\/span> \"test php \"<\/span> ?><\/span><\/span><\/code><\/pre>\n

1.5 ntpdata\u7edf\u4e00\u7cfb\u7edf\u65f6\u95f4<\/p>\n

yum install -y<\/span> ntpdate\nntpdate cn.pool<\/span>.ntp<\/span>.org<\/span> <\/code><\/pre>\n
\n

\u4e8c Nagios4.2\u6e90\u7801\u5305\u7f16\u8bd1<\/h3>\n
\n

2.1 \u5b89\u88c5nagios\u4f9d\u8d56\u5305<\/p>\n

yum install -y<\/span> gcc glibc glibc-common<\/span> gd gd-devel<\/span> xinetd openssl-devel<\/span> unzip perl<\/code><\/pre>\n

2.2 \u6dfb\u52a0\u7528\u6237\u5e76\u6388\u6743 <\/p>\n

mkdir \/usr\/local<\/span>\/nagios \nuseradd nagios -s<\/span> \/sbin\/nologin -M<\/span> \nchown nagios:nagios \/usr\/local<\/span>\/nagios\/<\/span> \nll -d<\/span> \/usr\/local<\/span>\/nagios\/<\/span><\/code><\/pre>\n

2.3 \u4e0b\u8f7d\u5e76\u5b89\u88c5nagios4.2.4<\/p>\n

tar zxvf nagios-4.2<\/span>.4<\/span>.tar.gz\ncd nagios-4.2<\/span>.4<\/span>\n.\/configure --prefix=\/usr\/local\/nagios  \nmake all #\u7f16\u8bd1<\/span>\nmake install<\/span> #\u5b89\u88c5<\/span>\nmake install<\/span>-init  #\u7ba1\u7406nagios\u670d\u52a1\u7684\u811a\u672c<\/span>\nmake install<\/span>-commandmode  #\u6743\u9650\u914d\u7f6e<\/span>\nmake install<\/span>-config #\u914d\u7f6e\u6587\u4ef6\u5b89\u88c5<\/span>\nmake install<\/span>-webconf #httpd\u652f\u6301nagios\u7684\u914d\u7f6e(\u9700\u8981\u91cd\u542fhttpd)<\/span><\/code><\/pre>\n

2.4 \u68c0\u6d4bnagios core\u662f\u5426\u5b89\u88c5\u6210\u529f<\/strong><\/p>\n

2.4.1 \u67e5\u770bnagios core\u5b89\u88c5\u7248\u672c<\/p>\n

[root@anan nagios-4.2<\/span>.4<\/span>]# \/usr\/local\/nagios\/bin\/nagios --version\n\nNagios Core 4.2<\/span>.4<\/span>\nCopyright (c) 2009<\/span>-present Nagios Core Development Team and<\/span> Community Contributors\nCopyright (c) 1999<\/span>-2009<\/span> Ethan Galstad\nLast Modified: 2017<\/span>-08<\/span>-24<\/span>\nLicense: GPL\n\nWebsite: https:\/\/www.nagios.org<\/span>\nThis program is<\/span> free software; you can redistribute it and<\/span>\/or<\/span> modify\nit under the terms of<\/span> the GNU General Public<\/span> License version 2<\/span> as<\/span>\npublished<\/span> by<\/span> the Free Software Foundation.\n\nThis program is<\/span> distributed in<\/span> the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of<\/span>\nMERCHANTABILITY or<\/span> FITNESS FOR<\/span> A PARTICULAR PURPOSE.  See the\nGNU General Public<\/span> License for<\/span> more details.\n\nYou should have received a copy<\/span> of<\/span> the GNU General Public<\/span> License\nalong with<\/span> this program; if<\/span> not<\/span>, write<\/span> to<\/span> the Free Software\nFoundation, Inc., 675<\/span> Mass Ave, Cambridge, MA 02139<\/span>, USA.<\/code><\/pre>\n

2.4.2 \u68c0\u67e5\u662f\u5426\u751f\u6210\u4e86\u5bf9\u5e94httpd\u7684web\u914d\u7f6e\u6587\u4ef6 <\/p>\n

ls -al \/etc\/httpd\/conf.d<\/span>\/ <\/code><\/pre>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

2.4.2 cd \/usr\/local\/nagios\/ #\u67e5\u770b\u662f\u5426\u6709\u4ee5\u4e0b\u51e0\u4e2a\u76ee\u5f55<\/p>\n

bin:<\/span>Nagios #\u53ef\u6267\u884c\u7a0b\u5e8f\u6240\u5728\u76ee\u5f55<\/span>\netc:<\/span>Nagios #\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u76ee\u5f55<\/span>\nsbin:<\/span>nagios #CGI\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u4e5f\u5c31\u662f\u6267\u884c\u5916\u90e8\u547d\u4ee4\u6240\u9700\u8981\u6587\u4ef6\u7684\u6240\u5728\u7684\u76ee\u5f55<\/span>\nshare:<\/span>   #nagios\u7f51\u9875\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55<\/span>\nlibexec:<\/span>    #nagios\u5916\u90e8\u63d2\u4ef6 \u6240\u5728\u76ee\u5f55<\/span>\nvar:<\/span>   #nagios\u65e5\u5fd7\u6587\u4ef6\uff0clock\u7b49\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55<\/span>\n<\/code><\/pre>\n

2.5 \u4e3anagios\u6dfb\u52a0\u9ed8\u8ba4\u767b\u9646\u540dnagiosadmin \u5e76\u8bbe\u7f6e\u5bc6\u7801<\/strong><\/p>\n

htpasswd -c<\/span> \/usr\/local<\/span>\/nagios\/etc\/htpasswd.<\/span>users nagiosadmin<\/code><\/pre>\n

2.6 \u914d\u7f6e\u9875\u9762\u68c0\u6d4b\u662f\u5426\u6b63\u5e38\u5e76\u6dfb\u52a0\u522b\u540d\u653e\u5165.bashrc\u4e2d<\/p>\n

alias<\/span> nagioscheck='\/usr\/local<\/span>\/nagios\/bin\/nagios -v \/usr\/local<\/span>\/nagios\/etc\/nagios.cfg'<\/code><\/pre>\n

2.7 nagios\u670d\u52a1\u5668\u7ba1\u7406<\/p>\n

chkconfig --add<\/span> nagios #nagios\u52a0\u5165\u670d\u52a1\u7ba1\u7406<\/span>\nsystemctl enable nagios #\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/span>\nsystemctl restart nagios #\u542f\u52a8nagios<\/span>\nsystemctl restart httpd #\u91cd\u542fhttpd <\/span><\/code><\/pre>\n

2.8 \u767b\u9646\u7f51\u9875localhost\/nagios\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fdb\u5165\u7f51\u7ad9<\/p>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

\u4e09 Nagios\u63d2\u4ef6\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u4ee5\u53ca\u914d\u7f6e\u89e3\u8bfb<\/h3>\n

3.1 \u4e0b\u8f7d\u5e76\u5b89\u88c5<\/p>\n

wget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.2.1.tar.gz<\/span>\ntar zxvf nagios-plugins<\/span>-<\/span>2.2<\/span>.1<\/span>.<\/span>tar.<\/span>gz\ncd zxvf nagios-plugins<\/span>-<\/span>2.2<\/span>.1<\/span>\n.<\/span>\/configure --<\/span>prefix=<\/span>\/usr\/local<\/span>\/nagios\/<\/span> --<\/span>with<\/span>-nagios<\/span>-user<\/span>=<\/span>nagios --<\/span>with<\/span>-nagios<\/span>-group<\/span>=<\/span>nagios\nmake &&<\/span> make install<\/code><\/pre>\n

3.2 \u68c0\u67e5nagios\u63d2\u4ef6\u662f\u5426\u5b89\u88c5\u6210\u529f<\/p>\n

ll -h<\/span> \/usr\/local<\/span>\/nagios\/libexec\/<\/span><\/code><\/pre>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

3.3 \u4fee\u6539\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6 \u6dfb\u52a0\u6216\u8005\u51cf\u5c11\u9700\u8981\u76d1\u63a7\u7684\u5185\u5bb9<\/p>\n

vi  \/usr\/local<\/span>\/nagios\/etc\/objects\/localhost.cfg<\/code><\/pre>\n

3.4 \u7b80\u5316nagios\u914d\u7f6e<\/p>\n

cat \/usr\/local<\/span>\/nagios\/etc\/nagios.<\/span>cfg |<\/span> egrep -v<\/span> '^#|^$'<\/span><\/code><\/pre>\n

3.5 nagios\u914d\u7f6e\u7b80\u8981\u8bf4\u660e<\/p>\n

log_file=\/usr\/local<\/span>\/nagios\/var\/nagios.log<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/commands.cfg #\u547d\u4ee4\u914d\u7f6e\u6587\u4ef6<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/contacts.cfg  #\u8054\u7cfb\u4eba\u914d\u7f6e\u6587\u4ef6<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/timeperiods.cfg #\u68c0\u6d4b\u65f6\u95f4\u914d\u7f6e<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/templates.cfg #\u6a21\u677f\u914d\u7f6e<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/localhost.cfg #\u4e3b\u673a\u914d\u7f6e<\/span>\ncfg_file=\/usr\/local<\/span>\/nagios\/etc\/objects\/resource.cf #\u5b8f\u5b9a\u4e49\u914d\u7f6e<\/span>\n<\/code><\/pre>\n

3.6 \u6dfb\u52a0\u4e3b\u673a\u76d1\u63a7\u76ee\u5f55\/usr\/local\/nagios\/etc\/nagios.cfg<\/p>\n

cfg_dir=\/usr\/local<\/span>\/nagios\/etc<\/span>\/objects\/hosts<\/span> #\u9700\u8981\u521b\u5efa\u6587\u4ef6\u5939 \u8be5\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u914d\u7f6e\u6587\u4ef6\u90fd\u4f1a\u88ab\u52a0\u8f7d<\/span>\n<\/code><\/pre>\n

3.7 \u81ea\u5b9a\u4e49\u6dfb\u52a0\u76d1\u63a7\u4e3b\u673a \u76d1\u63a7\u4e3b\u673a\u7ec4\u4ee5\u53ca\u76d1\u63a7\u5bf9\u8c61 vi \/usr\/local\/nagios\/etc\/objects\/hosts\/140.cfg<\/p>\n

######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>###\u5b9a\u4e49\u4e3b\u673a###<\/span>######<\/span>######<\/span>######<\/span>#### define host{ use linux-server host_name nagios_192.168.32.140 address 192.168.32.140 } ###<\/span>######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>\u5b9a\u4e49\u4e3b\u673a\u7ec4######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>### define hostgroup{ hostgroup_name localgroup alias localgroup members nagios_192.168.32.140 } ###<\/span>######<\/span>######<\/span>######<\/span>######<\/span>\u5b9a\u4e49\u76d1\u63a7\u670d\u52a1######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>##### define service{ use generic-service host_name nagios_192.168.32.140 service_description ping_www check_command check_ping!30.0,10%!100.0,40% } define service { use generic-service host_name nagios_192.168.32.140 service_description check_Port 80 check_command check_tcp!80 } define service { use generic-service host_name nagios_192.168.32.140 service_description check_Port82 check_command check_tcp!80 } <\/span><\/code><\/pre>\n

\u56db Nagios\u5b9e\u73b0\u90ae\u4ef6\u544a\u8b66<\/h3>\n

4.1 \u7f16\u5199\u90ae\u4ef6\u811a\u672c \/usr\/local\/nagios\/libexec\/nagios_email.py<\/code><\/p>\n

#!\/usr\/bin\/python<\/span>\n# -*- coding: utf-8 -*-<\/span>\n\nfrom<\/span> email.mime.text import<\/span> MIMEText\nfrom<\/span> email.header import<\/span> Header\nimport<\/span> smtplib\nimport<\/span> sys\n\nsmtpaddr = 'smtp.163.com'<\/span>\n#smtpaddr = 'smtp.qq.com'<\/span>\nmyemail='18725883755@163.com'<\/span>\n#password='password' #\u8f93\u5165\u4f60\u7684\u5bc6\u7801<\/span>\n#f = open('\/usr\/local\/nagios\/libexec\/password','r')<\/span>\n#password = f.readline()<\/span>\n\nrecvmail=sys.argv[1<\/span>]\nsubject=sys.argv[2<\/span>]\ncontent=sys.argv[3<\/span>]\n\nmsg = MIMEText(\"\"\"%s\"\"\"<\/span>%(content), \"html\"<\/span>, \"utf-8\"<\/span>)\n\nmsg['Subject'<\/span>] = Header(subject, 'utf-8'<\/span>).encode()\nmsg['From'<\/span>] = myemail\nmsg['To'<\/span>] =  recvmail\n\ntry<\/span>:\n        server = smtplib.SMTP()\n        server.connect(smtpaddr, \"25\"<\/span>)\n        server.starttls()\n        server.login(myemail, password)\n        server.sendmail(myemail, recvmail.split(','<\/span>), msg.as_string())\n        server.quit()\n        print(\"success\"<\/span>)\nexcept<\/span> Exception, e:\n        print(\"fail: \"<\/span>+str(e))\n<\/code><\/pre>\n

4.2 \u6d4b\u8bd5\u90ae\u4ef6\u63a5\u6536\u662f\u5426\u6b63\u5e38<\/p>\n

chmod<\/span> a+x<\/span> \/usr\/local<\/span>\/nagios\/libexec\/nagios_email.py\n\/usr\/local<\/span>\/nagios\/libexec\/nagios_email.py \"18725883755@163<\/span>.com\"<\/span> \"disk not enough\"<\/span> \"disk is <20\"<\/span><\/code><\/pre>\n

4.3 \u5b9a\u4e49\u90ae\u4ef6\u63a5\u6536\u4eba\uff1acontacts.cfg <\/p>\n

define contact{\n    contact_name    nagiosadmin\n    use             generic.contact\n    alias<\/span>           Nagios<\/span> Admin<\/span>\n\n    email            nagios@localhost<\/span>  #\u8fd9\u91cc\u6539\u4e3a\u9700\u8981\u63a5\u6536\u4fe1\u606f\u7684\u90ae\u7bb1<\/span>\n}<\/code><\/pre>\n

4.4 \u66f4\u6539\u9ed8\u8ba4\u7684\u544a\u8b66\u914d\u7f6e\uff0c\u4f7f\u7528python\u811a\u672c\u53d1\u9001
\/usr\/local\/nagios\/etc\/objects\/commands.cfg<\/code><\/p>\n

define command{\n        command_name    notify-service-by-email\n        command_line    python \/usr\/local<\/span>\/nagios\/libexec\/nagios_email.py $CONTACTEMAIL<\/span>$ \"**<\/span> $NOTIFICATIONTYPE<\/span>$ Service Alert: $HOSTALIAS<\/span>$\/<\/span>$SERVICEDESC<\/span>$ is $SERVICESTATE<\/span>$ **<\/span>\"<\/span> \"**<\/span>**<\/span>* Nagios **<\/span>**<\/span>*<<\/span>br \/><br \/>Notification Type: $NOTIFICATIONTYPE<\/span>$<<\/span>br \/><br \/>Service: $SERVICEDESC<\/span>$<<\/span>br \/>Host: $HOSTALIAS<\/span>$<<\/span>br \/>Address: $HOSTADDRESS<\/span>$<<\/span>br \/>State: $SERVICESTATE<\/span>$<<\/span>br \/><br \/>Date\/Time: $LONGDATETIME<\/span>$<<\/span>br \/><br \/>Additional Info:<br \/><br \/>$SERVICEOUTPUT<\/span>$<<\/span>br \/>\"<\/span>\n        }\n<\/code><\/pre>\n

\u4e94 Nagios \u4f7f\u7528nrpe\u76d1\u63a7\u8fdc\u7a0bLinux<\/h3>\n

\u6ce8\uff1anagios\u9700\u8981\u5b89\u88c5nrpe\u548cnagios-plugins <\/p>\n

5.1 \u5b89\u88c5nrpe\u63d2\u4ef6 :<\/p>\n

 yum install gcc gcc-c++ openssl-devel openssl make #\u5b89\u88c5\u57fa\u672c\u4f9d\u8d56<\/span>\nwget https:\/\/github.com<\/span>\/NagiosEnterprises\/nrpe\/releases\/download\/nrpe-3.2<\/span>.1<\/span>\/nrpe-3.2<\/span>.1<\/span>.tar<\/span>.gz<\/span>\ntar zxvf nrpe-3.2<\/span>.1<\/span>.tar<\/span>.gz<\/span>\ncd nrpe-3.2<\/span>.1<\/span>\n.\/configure --prefix=\/usr\/local\/nagios\nmake all\nmake install\nmake install-config<\/code><\/pre>\n

5.2 nrpe\u662f\u5426\u5b89\u88c5\u6210\u529f<\/p>\n

 ll -h<\/span> \/usr\/local<\/span>\/nagios\/libexec\/check_nrpe \/usr\/local<\/span>\/nagios\/bin\/nrpe<\/code><\/pre>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

5.3 \u7b80\u5316 nrpe\u914d\u7f6e\u5e76\u6dfb\u52a0nagios_server\u53ef\u4ee5\u76d1\u63a7nagios_client<\/p>\n

cp \/usr\/local<\/span>\/nagios\/etc\/nrpe.<\/span>cfg \/usr\/local<\/span>\/nagios\/etc\/nrpe.<\/span>cfg_bak\ncat \/usr\/local<\/span>\/nagios\/etc\/nrpe.<\/span>cfg |<\/span>egrep -v<\/span> '^#|^$'<\/span>\n<\/code><\/pre>\n

nagios_client\u4fee\u6539\/usr\/local\/nagios\/etc\/nrpe.cfg<\/p>\n

allowed_hosts=127.0<\/span>.0.1<\/span>,::1<\/span>,192.168<\/span>.32.140<\/span> #\u6dfb\u52a0nagios_server\u670d\u52a1\u5668ip<\/span><\/code><\/pre>\n

5.4 \u542f\u52a8nrpe <\/p>\n

\/usr\/local<\/span>\/nagios\/bin\/nrpe -d<\/span> -c<\/span> \/usr\/local<\/span>\/nagios\/etc\/nrpe.<\/span>cfg\n<\/code><\/pre>\n

5.5 \u67e5\u770b5666\u7aef\u53e3\u662f\u5426\u542f\u52a8<\/p>\n

netstat -tulnp |grep nrpe<\/span><\/code><\/pre>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

5.6 nrpe\u542f\u52a8\u6d4b\u8bd5<\/p>\n

\/usr\/local<\/span>\/nagios\/libexec\/check_nrpe -H 192.168<\/span>.32<\/span>.139<\/span> #\u8fdc\u7a0b\u670d\u52a1\u5668ip<\/span><\/code><\/pre>\n

5.7 nagios_service\u6dfb\u52a0\u88ab\u76d1\u63a7\u4e3b\u673a\u670d\u52a1 (\u53c2\u8003\u4e3b\u673a\u76d1\u63a7)<\/p>\n

######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>###\u5b9a\u4e49\u4e3b\u673a###<\/span>######<\/span>######<\/span>######<\/span>#### define host{ use linux-server host_name nagios_192.168.32.139 address 192.168.32.139 } ###<\/span>######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>\u5b9a\u4e49\u4e3b\u673a\u7ec4######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>### define hostgroup{ hostgroup_name 192.168.32.139 alias localgroup members nagios_192.168.32.139 } ###<\/span>######<\/span>######<\/span>######<\/span>######<\/span>\u5b9a\u4e49\u76d1\u63a7\u670d\u52a1######<\/span>######<\/span>######<\/span>######<\/span>######<\/span>##### define service{ use generic-service host_name nagios_192.168.32.139 service_description ping_www check_command check_ping!30.0,10%!100.0,40% } define service { use generic-service host_name nagios_192.168.32.139 service_description check_Port 80 check_command check_tcp!80 } define service { use generic-service host_name nagios_192.168.32.139 service_description check_Port82 check_command check_tcp!80 } <\/span><\/code><\/pre>\n

\"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a<\/p>\n

\u4f7f\u7528NRPE\u76d1\u63a7Linux cpu\u4fe1\u606f<\/p>\n

5.8 \u4f7f\u7528NRPE\u76d1\u63a7Linux cpu\u4fe1\u606f
\u6dfb\u52a0\u81ea\u5b9a\u4e49\u547d\u4ee4 \/usr\/local\/nagios\/etc\/objects\/commands.cfg<\/p>\n

define command{\n        command_name    check_nrpe\n        command_line    $USER1<\/span>$\/<\/span>check_nrpe -H<\/span> $HOSTADDRESS<\/span>$ <\/span>$ARG1<\/span>$ <\/span>    }\n<\/code><\/pre>\n

\u6dfb\u52a0\u4e3b\u673a\u8fdc\u7a0b\u76d1\u63a7
\/usr\/local\/nagios\/etc\/objects\/hosts\/139.cfg\u4e2d\u6dfb\u52a0service\u5b9a\u4e49<\/p>\n

define service{\n        use<\/span> generic-service\n        host_name nagios_192.168.32<\/span>.139<\/span>\n        service_description check_Load\n        check_command check_nrpe!check_load\n}\n\n<\/code><\/pre>\n
\n

\u516d\uff1aNagios\u5b89\u88c5pnp4nagios\u5b9e\u73b0\u7ed8\u56fe<\/h3>\n
\n

6.1 pnp4nagios\u7684\u5b89\u88c5<\/p>\n

yum -y install<\/span> rrdtool rrdtool-devel perl-rrdtool perl-Time-HiRes php-gd\ncd \/usr\/local\/src\/\nwget 'https:\/\/jaist.dl.sourceforge.net\/project<\/span>\/pnp4nagios\/PNP-0.6<\/span>\/pnp4nagios-0.6<\/span>.26<\/span>.tar.gz'\ntar -zxvf pnp4nagios-0.6<\/span>.26<\/span>.tar.gz\ncd pnp4nagios-0.6<\/span>.26<\/span>\n.\/configure --prefix=\/usr\/local\/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios\nmake all\nmake install<\/span>            #\u5b89\u88c5pnp4nagios\u7684\u4e3b\u7a0b\u5e8f\u548cweb\u6587\u4ef6<\/span>\nmake install<\/span>-config     #\u5b89\u88c5\u914d\u7f6e\u6587\u4ef6<\/span>\nmake install<\/span>-init       #\u5b89\u88c5\u542f\u52a8\u811a\u672c<\/span>\nmake install<\/span>-webconf    #\u5b89\u88c5\u7f51\u9875\u914d\u7f6e(\u91cd\u542fhttpd)<\/span><\/code><\/pre>\n

6.2 \u9a8c\u8bc1pnp4nagios\u7684\u5b89\u88c5<\/p>\n

\/usr\/local<\/span>\/pnp4nagios\/bin\/npcd --version<\/span><\/code><\/pre>\n

6.3 \u66f4\u65b0pnp4nagios\u7684\u914d\u7f6e<\/p>\n

cd  \/usr\/local\/pnp4nagios\/etc\/\ncp<\/span> misccommands.cfg<\/span>-sample misccommands.cfg<\/span>\ncp<\/span> nagios.cfg<\/span>-sample.nagios<\/span>.cfg<\/span> \ncp<\/span> rra.cfg<\/span>-sample rra.cfg<\/span><\/code><\/pre>\n

\u672a\u5b8c\u5f85\u7eed\u2026\u2026<\/p>\n


\n

\u9519\u8bef\u8bb0\u5f55\uff1a<\/h3>\n

\u95ee\u9898\u4e00<\/strong>\uff1a\u8fde\u63a5\u5931\u8d25<\/p>\n

[root@anan var]# \/usr\/local\/nagios\/libexec\/check_nrpe -H 192.168<\/span>.32<\/span>.139<\/span>\nconnect to<\/span> address 192.168<\/span>.32<\/span>.139<\/span> port<\/span> 5666<\/span>: No route to<\/span> host\nconnect to<\/span> host 192.168<\/span>.32<\/span>.139<\/span> port<\/span> 5666<\/span>: No route to<\/span> host<\/code><\/pre>\n

\u539f\u56e0\uff1a\u9632\u706b\u5899\u672a\u5173\u95ed\uff0c\u5173\u95ed\u9632\u706b\u5899\u540e\u6b63\u5e38<\/p>\n


\n

\u95ee\u9898\u4e8c<\/strong>\uff1a\u6ca1\u6709\/usr\/local\/nagios\/etc\/nrpe.cfg<\/code>\u8be5\u6587\u4ef6 <\/p>\n

\u539f\u56e0\uff1a\u672a\u5728\u5b89\u88c5nrpe\u65f6\u6ca1\u6709\u6267\u884cmake install-config<\/code>\u547d\u4ee4<\/h3>\n

\u95ee\u9898\u4e09<\/strong>\uff1a\u5b89\u88c5pnp4nagios\u4e0d\u8981\u653e\u5728\/usr\/local\/nagios\u4e0b \u5426\u5219\u4f1a\u8986\u76d6nagios\u9875\u9762 \u5bfc\u81f4\u9875\u9762\u5931\u8d25<\/p>\n


\n","protected":false},"excerpt":{"rendered":"najios\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u6ce8\uff1a\u672c\u73af\u5883\u9ed8\u8ba4\u5b89\u88c5\u5728\/usr\/local\/nagios\u4e2dnagios\u7248\u672c\uff1anagios-4.2.4\u63d2\u4ef6\u7248\u672c\uff1anagios-plugins-2.1.2\u5b9e\u9a8c\u73af...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7401"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7401"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7401\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}

Host Name<\/th>\nOS<\/th>\nIP<\/th>\nSoftware<\/th>\n<\/tr>\n
Nagios-Server<\/td>\nCentOS 7<\/td>\n192.168.32.140<\/td>\nApache\u3001Php\u3001Nagios\u3001nagios-plugins<\/td>\n<\/tr>\n
Nagios-Client<\/td>\nCentOS 7<\/td>\n192.168.32.139<\/td>\nnagios-plugins\u3001nrpe<\/td>\n<\/tr>\n