Nagios监控基础配置(一)
时间:2022-03-13 20:11
一、搭建Nagios监控服务器
1、部署运行环境LAMP
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# yum -y install mariadb-server mariadb
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# mysqladmin -hlocalhost -u root password "123456"
[root@localhost ~]# yum -y install php-mysql php
2、安装准备:编译工具 创建用户和组
[root@monitor21 /]# rpm -q gcc gcc-c++
[root@monitor21 /]# useradd nagios
[root@monitor21 /]# groupadd nagcmd
[root@monitor21 /]# usermod -G nagcmd nagios
3、安装源码包
1) 解包
[root@monitor21 /]# tar -zxf nagios-4.2.4.tar.gz
[root@monitor21 /]# cd nagios-4.2.4/
[root@monitor21 nagios-4.2.4]# ./configure --help | more >分页查看帮助信息
[root@monitor21 nagios-4.2.4]# ./configure
--with-nagios-user=nagios \ 所有者
--with-nagios-group=nagcmd \ 从属组
--with-command-user=nagios \ 软件执行者
--with-command-group=nagcmd 软件执行的组
2) 编译
[root@monitor21 nagios-4.2.4]# make all >编译主程序 #做完这步,最好开两个终端方便查看安装
[root@monitor21 nagios-4.2.4]# make install >安装程序
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/ >主配置文件
[root@monitor21 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
[root@monitor21 nagios-4.2.4]# cat /etc/rc.d/init.d/nagios >系统的脚本文件
3、【安装】
[root@monitor21 nagios-4.2.4]# make install-commandmode >设置文件权限
[root@monitor21 nagios-4.2.4]# make install-config >安装配置
[root@monitor21 nagios-4.2.4]# make install-webconf >部署网站配置
[root@monitor21 nagios-4.2.4]# make install-exfoliation >页面风格
4、 查看安装目录及配置文件说明
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/
bin/ etc/ libexec/ sbin/ share/ var/
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/bin/
nagios >验证配置信息
nagiostats >命令行显示监控信息
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/etc/ >主配置文件目录
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/libexec/ >监控插件目录 (默认为空)
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/sbin/ >编译好的脚本文件(二进制)
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/share/ >网页文件目录
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/var/ >日志目录
5、安装监控插件
[root@monitor21 nagios-plugins-2.1.4]# tar -zxf /nagios-plugins-2.1.4.tar.gz >解包
[root@monitor21 nagios-plugins-2.1.4]# cd /nagios-4.2.4/nagios-plugins-2.1.4/ >进入目录
[root@monitor21 nagios-plugins-2.1.4]# ./configure && make && make install > 源码安装
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/libexec/ >查看安装的插件
6、启动nagios监控服务
设置访问监控页面的用户名(nagiosadmin)和密码(自定义) >名字为默认值
[root@monitor21 nagios-4.2.4]# vim /etc/httpd/conf.d/nagios.conf
52 AuthUserFile /usr/local/nagios/etc/htpasswd.users >存储访问的用户名和密码
[root@monitor21 nagios-4.2.4]# which htpasswd >查看是否有这个命令
/usr/bin/htpasswd
[root@monitor21 nagios-4.2.4]# rpm -qf /usr/bin/htpasswd >查询那个包提供的
httpd-tools-2.4.6-40.el7.x86_64
[root@monitor21 nagios-4.2.4]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin >建web管理用户
New password: 111111 >输入密码
Re-type new password: 111111 >验证密码
-c 选项
[root@monitor21 nagios-4.2.4]# cat /usr/local/nagios/etc/htpasswd.users >查看生成的文件
nagiosadmin:$apr1$UGaLKGiO$GNSYq.O2T6qVQab6aKTWR/
[root@monitor21 nagios-4.2.4]# systemctl restart httpd >重起网站服务
[root@monitor21 nagios-4.2.4]# /etc/rc.d/init.d/nagios start >开启nagios服务
[root@monitor21 nagios-4.2.4]# /etc/rc.d/init.d/nagios status >查看状态
nagios (pid 3883) is running...
7、访问监控网页
[root@room1pc33 桌面]# firefox
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
【下面是主页面】
三、配置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 监控中
相关推荐
- Android系统编程入门系列之界面Activity交互响应
- 新型横向移动工具原理分析、代码分析、优缺点以及检测方案
- uni-app滚动视图容器(scroll-view)之监听上拉事件
- uniapp h5,app两端复制文本
- Android系统编程入门系列之界面Activity响应丝滑的传统动画
- 【Azure 应用服务】App Service 配置 Application Settings 访问Storage Account得到 could not be resolved: '*.file.core.windows.net'的报错。没有解析成对应中国区 Storage Account地址 *.file.core.chinacloudapi.cn
- 诺基亚短信生成!太好玩了
- iOS 跳转App Store进行评分
- 开发一个即时通讯App
- 关闭苹果IOS app自动更新
电脑软件
本类排行
- 1关闭苹果IOS app自动更新
- 2iOS 跳转App Store进行评分
- 3诺基亚短信生成!太好玩了
- 4Android系统编程入门系列之界面Activity响应丝滑的传统动画
- 5uniapp h5,app两端复制文本
- 6uni-app滚动视图容器(scroll-view)之监听上拉事件
- 7新型横向移动工具原理分析、代码分析、优缺点以及检测方案
- 8Android系统编程入门系列之界面Activity交互响应
- 9开发一个即时通讯App
- 10【Azure 应用服务】App Service 配置 Application Settings 访问Storage Account得到 could not be resolved: '*.file.core.windows.net'的报错。没有解析成对应中国区 Storage Account地址 *.file.core.chinacloudapi.cn