Nagios监控基础配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nagios监控基础配置相关的知识,希望对你有一定的参考价值。
一、搭建Nagios监控服务器
1、部署运行环境LAMP
[[email protected] ~]# yum -y install httpd
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# systemctl enable httpd
[[email protected] ~]# yum -y install mariadb-server mariadb
[[email protected] ~]# systemctl restart mariadb
[[email protected] ~]# systemctl enable mariadb
[[email protected] ~]# mysqladmin -hlocalhost -u root password "123456"
[[email protected] ~]# yum -y install php-mysql php
2、安装准备:编译工具 创建用户和组
[[email protected] /]# rpm -q gcc gcc-c++
[[email protected] /]# useradd nagios
[[email protected] /]# groupadd nagcmd
[[email protected] /]# usermod -G nagcmd nagios
3、安装源码包
1) 解包
[[email protected] /]# tar -zxf nagios-4.2.4.tar.gz
[[email protected] /]# cd nagios-4.2.4/
[[email protected] nagios-4.2.4]# ./configure --help | more >分页查看帮助信息
[[email protected] nagios-4.2.4]# ./configure
--with-nagios-user=nagios \ 所有者
--with-nagios-group=nagcmd \ 从属组
--with-command-user=nagios \ 软件执行者
--with-command-group=nagcmd 软件执行的组
2) 编译
[[email protected] nagios-4.2.4]# make all >编译主程序 #做完这步,最好开两个终端方便查看安装
[[email protected] nagios-4.2.4]# make install >安装程序
[[email protected] nagios-4.2.4]# ls /usr/local/nagios/ >主配置文件
[[email protected] nagios-4.2.4]# make install-init >安装控制脚本
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
Init script installed
[[email protected] nagios-4.2.4]# cat /etc/rc.d/init.d/nagios >系统的脚本文件
3、【安装】
[[email protected] nagios-4.2.4]# make install-commandmode >设置文件权限
[[email protected] nagios-4.2.4]# make install-config >安装配置
[[email protected] nagios-4.2.4]# make install-webconf >部署网站配置
[[email protected] nagios-4.2.4]# make install-exfoliation >页面风格
4、 查看安装目录及配置文件说明
[[email protected] nagios-4.2.4]# ls /usr/local/nagios/
bin/ etc/ libexec/ sbin/ share/ var/
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/bin/
nagios >验证配置信息
nagiostats >命令行显示监控信息
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/etc/ >主配置文件目录
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/libexec/ >监控插件目录 (默认为空)
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/sbin/ >编译好的脚本文件(二进制)
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/share/ >网页文件目录
[[email protected] nagios-4.2.4]#ls /usr/local/nagios/var/ >日志目录
5、安装监控插件
[[email protected] nagios-plugins-2.1.4]# tar -zxf /nagios-plugins-2.1.4.tar.gz >解包
[[email protected] nagios-plugins-2.1.4]# cd /nagios-4.2.4/nagios-plugins-2.1.4/ >进入目录
[[email protected] nagios-plugins-2.1.4]# ./configure && make && make install > 源码安装
[[email protected] nagios-4.2.4]# ls /usr/local/nagios/libexec/ >查看安装的插件
6、启动nagios监控服务
设置访问监控页面的用户名(nagiosadmin)和密码(自定义) >名字为默认值
[[email protected] nagios-4.2.4]# vim /etc/httpd/conf.d/nagios.conf
52 AuthUserFile /usr/local/nagios/etc/htpasswd.users >存储访问的用户名和密码
[[email protected] nagios-4.2.4]# which htpasswd >查看是否有这个命令
/usr/bin/htpasswd
[[email protected] nagios-4.2.4]# rpm -qf /usr/bin/htpasswd >查询那个包提供的
httpd-tools-2.4.6-40.el7.x86_64
[[email protected] nagios-4.2.4]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin >建web管理用户
New password: 111111 >输入密码
Re-type new password: 111111 >验证密码
-c 选项
[[email protected] nagios-4.2.4]# cat /usr/local/nagios/etc/htpasswd.users >查看生成的文件
nagiosadmin:$apr1$UGaLKGiO$GNSYq.O2T6qVQab6aKTWR/
[[email protected] nagios-4.2.4]# systemctl restart httpd >重起网站服务
[[email protected] nagios-4.2.4]# /etc/rc.d/init.d/nagios start >开启nagios服务
[[email protected] nagios-4.2.4]# /etc/rc.d/init.d/nagios status >查看状态
nagios (pid 3883) is running...
7、访问监控网页
[[email protected] 桌面]# firefox http://192.168.4.21/nagios
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
【下面是主页面】
三、配置nagios服务
(默认不用任何配置 就监控本机)
services 监控信息
Current Load cpu负载
Current Users 登入系统的用户数
HTTP 网站服务运行状态
Root Partition 根分区
SSH 监控ssh服务
Swap Usage 交换分区
Total Processes 总的进程数量
Host Status Totals 监控主机
Service Status Totals 监控资源
OK 正常
WARNING 警告
Unknown 不知道
Critical 严重错误
Pending 监控中
以上是关于Nagios监控基础配置的主要内容,如果未能解决你的问题,请参考以下文章