栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nagios监控系统

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nagios监控系统

安装配置nagios 

nagios需要依赖lamp环境,所有我们先在nagios服务器上安装配置lamp环境

[root@localhost ~]# mount /dev/cdrom /media/

[root@localhost ~]# rm -rf /etc/yum.repos.ddhcpd.conf.example /etc/dhcp/dhcpd.conf

cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y

[root@localhost nrpe-2.15]# vim /etc/dhcp/dhcpd.conf

subnet 192.168.6.0 netmask 255.255.255.0 {

  range 192.168.6.26 192.168.6.30;

  default-lease-time 600;

  max-lease-time 7200;

}

[root@localhost nrpe-2.15]# systemctl restart dhcpd

6、添加被监控客户端的测试选项(server1)

[root@localhost ~]# cd /usr/local/nagios/etc/objects/

[root@localhost objects]# cp -p localhost.cfg 192.168.6.20.cfg

[root@localhost objects]# vim 192.168.6.20.cfg

修改:

删除host group选项

define hostgroup{

        hostgroup_name  linux-servers ; The name of the hostgroup

        alias           Linux Servers ; Long name of the group

        members         localhost     ; Comma separated list of hosts that belong to this group

        }

define host{

use linux-server

host_name server2

alias server2

address 192.168.6.20

}

替换所有模块中的host_name的名称为server2

:% s/localhost/server2/g

添加模块:

define service{

        use                             local-service

        host_name                       server2

        service_description             FTP

        check_command                   check_ftp

        notifications_enabled           0

        }

define service{

        use                             local-service

        host_name                       server2

        service_description             DHCP

        check_command                   check_dhcp

        notifications_enabled           0

        }

define service{

        use                             local-service

        host_name                       server2

        service_description             DNS

        check_command                   check_dns

        notifications_enabled           0

        }

7、配置nagios.cfg,添加监控节点

[root@localhost objects]# vim /usr/local/nagios/etc/nagios.cfg

添加: 32后

cfg_file=/usr/local/nagios/etc/objects/192.168.6.20.cfg

8、重启服务

killall -9 nagios

systemctl start nagios &

systemctl start httpd

9、查看监控结果

等待一段时间后,会对所有项目进行检测完毕

我们通过结果,可以看到有通过检测的选项(绿色),警告(黄色),未知服务(橘色),最后一列给出了故障和检测信息。http服务标记了403错误,我们给http服务添加一个主页文件。然后等待一下就能看到以下结果。

二、添加mysql监控

1、在mysql服务器(被监控服务器)上配置:

[root@localhost ~]# mysql -u root -p123.com mysql> create database abc;

mysql> grant all on abc.* to 'zhang1'@'192.168.1.%' identified by '123.com'; mysql> flush privileges;

mysql>quit

第1步:在监控服务器上安装mariadb与配套组件

[root@localhost ~]# yum -y install mariadb mariadb-devel

第2步:在nagios监控服务器中配置

1、检测连接数据库服务器

/usr/local/nagios/libexec/check_mysql -u zhang1 -d abc -H 192.168.1.100 -P3306 --password='123.com'

2、定义mysql命令

[root@localhost ~]# vim /usr/local/nagios/etc/objects/commands.cfg

添加:

define command{

command_name

check_mysql

command_line $USER1$/check_mysql -H $HOSTADDRESS$ -P3306 -u zhang1 -d abc --password='123.com'

}

第3步:在主机检测配置文件中添加检测信息

vim /usr/local/nagios/etc/objects/192.168.10.2.cfg

添加:

define service{

use local-service ;Name of service template to use

host_name server1

service_description MYSQL

check_command check_mysql

notifications_enabled 0

}

第 4 步:从新加载nagios服务,就可以在检测页面中看到

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/450741.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号