Site updated: 2022-10-18 10:31:32
This commit is contained in:
1 parent
c67e4f8532
commit
ed571e359c
66 files changed
+817
-70
No files matched your search
@@ -6,6 +6,20 @@
|
||||
"description": "hito的博客",
|
||||
"home_page_url": "https://blog.jingxiyuan.cn",
|
||||
"items": [
|
||||
{
|
||||
"id": "https://blog.jingxiyuan.cn/2022/10/18/nagios%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/",
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/18/nagios%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/",
|
||||
"title": "搭建nagios监控",
|
||||
"date_published": "2022-10-18T01:39:00.000Z",
|
||||
"content_html": "<h4 id=\"监控端服务安装与配置\"><a class=\"anchor\" href=\"#监控端服务安装与配置\">#</a> 监控端服务安装与配置</h4>\n<ol>\n<li>nagios 需要安装主程序和 nrpe(nagios 和各被监控主机都必须安装)。如需使用自研前端可通过安装 ndoutils (用于把 nagios 监控信息写入数据库) 和 mysql 实现。具体安装见<span class=\"exturl\" data-url=\"aHR0cHM6Ly9zdXBwb3J0Lm5hZ2lvcy5jb20va2Iv\">官网</span></li>\n<li>nagios 默认监控命令脚本放置在 libexec 中,自定义脚本后也放到此处</li>\n<li>etc/objects/commands.cfg 用于保存 nagios 默认监控命令</li>\n<li>etc/nrpe.cfg 文件中需要添加用于被监控执行命令项(各被监控主机中都需要添加)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/18/image.png\" alt=\"\" /></li>\n<li>etc/objects/hosts 目录下配置需要被监控的主机信息<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/18/image2.png\" alt=\"\" /></li>\n<li>etc/objects/servers 目录下配置需要在被监控主机上执行的监控命令(第 4 项中的命令)<br />\n<img data-src=\"https://file.jingxiyuan.cn/images/2022/10/18/image3.png\" alt=\"\" /></li>\n</ol>\n<h4 id=\"被监控端服务安装与配置\"><a class=\"anchor\" href=\"#被监控端服务安装与配置\">#</a> 被监控端服务安装与配置</h4>\n<ol>\n<li>被监控端需要安装 nrpe</li>\n<li>被监控端需要把监控端的命令写入到 nrpe 的配置文件中</li>\n<li>被监控端需要把命令执行脚本放入 libexec 目录中</li>\n<li>被监控端自动安装脚本(可借鉴)</li>\n</ol>\n<pre><code class=\"language-bash\">1、请先修改脚本中的服务端IP。\n2、如被监控端不支持let计算命令请执行sudo dpkg-reconfigure dash命令,弹出选择窗口后选择no。\n3、需要在脚本同目录下创建CentOS、Ubuntu、sh和conf目录,目录下分别放置nrpe的tar安装包、监控脚本和nrpe配置文件。\n\n#!/bin/bash\n#服务端ip\nSERVER_IP=10.10.10.121\n#安装目录\nINSTALL_HOME=`pwd`\n#安装ubuntu版本\nINSTALL_UBUNTU()\n{\n\tsudo apt-get update\n\tsudo apt-get install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev wget openssl\n\t\n\tcd /tmp\n\t#wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-4.0.3.tar.gz\n\tcp $INSTALL_HOME/Ubuntu/nrpe.tar.gz ./\n\ttar xzf nrpe.tar.gz\n\n\tcd /tmp/nrpe-nrpe-4.0.3/\n\tsudo ./configure --enable-command-args --with-ssl-lib=/usr/lib/x86_64-linux-gnu/\n\tsudo make all\n\n\tsudo make install-groups-users\n\n\tsudo make install\n\n\tsudo make install-config\n\n\tsudo sh -c "echo >> /etc/services"\n\tsudo sh -c "sudo echo '# Nagios services' >> /etc/services"\n\tsudo sh -c "sudo echo 'nrpe 5666/tcp' >> /etc/services"\n\t\n\t#判断系统是高版本还是低版本\n\tVERSION=`lsb_release -r --short`\n\tIS_LOW_VERSION=`echo "$VERSION < 15" | bc`\n\n\tif [ $IS_LOW_VERSION = 1 ]; then\n\t\t#低版本\n\t\tsudo make install-init\n\telse\n\t\t#高版本\n\t\tsudo make install-init\n\t\tsudo systemctl enable nrpe.service\n\tfi\n\t\n\tsudo mkdir -p /etc/ufw/applications.d\n\tsudo sh -c "echo '[NRPE]' > /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'title=Nagios Remote Plugin Executor' >> /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'description=Allows remote execution of Nagios plugins' >> /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'ports=5666/tcp' >> /etc/ufw/applications.d/nagios"\n\tsudo ufw allow NRPE\n\tsudo ufw reload\n\t\n\tsudo sh -c "sed -i '/^allowed_hosts=/s/$/,$SERVER_IP/' /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "sed -i 's/^dont_blame_nrpe=.*/dont_blame_nrpe=1/g' /usr/local/nagios/etc/nrpe.cfg"\n\t\n\tcd $INSTALL_HOME\n\tsudo cp ./sh/* /usr/local/nagios/libexec/\n\tsudo chmod +xr /usr/local/nagios/libexec/*\n\t\n\tsudo sh -c "echo 'command[check_ping]=/usr/local/nagios/libexec/check_ping -H 127.0.0.1 -w 3000.0,80% -c 5000.0,100% -p 5' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_mem]=/usr/local/nagios/libexec/check_mem.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_disk]=/usr/local/nagios/libexec/check_disk.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_my_service]=/usr/local/nagios/libexec/check_my_service.sh \\$ARG1\\$' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_system_info]=/usr/local/nagios/libexec/check_system_info.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tNETWORK_INDEX=1\n\tfor NETWORK_NAME in `cat /proc/net/Line truncated
|
||||
"tags": [
|
||||
"技术分享",
|
||||
"经验分享",
|
||||
"心得体会",
|
||||
"nagios",
|
||||
"服务监控"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "https://blog.jingxiyuan.cn/2022/10/17/redis%E4%B8%BB%E4%BB%8E%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/",
|
||||
"url": "https://blog.jingxiyuan.cn/2022/10/17/redis%E4%B8%BB%E4%BB%8E%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/",
|
||||
|
||||
Reference in new issue
Block a user