运维监控之Nagios实战(二)&Nagios客户端
前面呢,服务器搭建起来了,可是光搭个监控报警服务器有什么用呢,难道只为了监控本机,可是如果本机宕机了,那还能收到报警信息吗,呵呵!
创新互联主要从事网站制作、网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务双河,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
现在我们来弄点被监控机吧...额,我现在就先弄下Linux和Windows主机
被监控机Linux
linux客户端的所用到的工具
- #!/bin/bash
- #filename: nagios-clt.sh
- #Environment: Centos 5.6 32-bit
- #Author: maoxian
- #blog: maoxian.blog.51cto.com
- #定义变量
- tooldir=/usr/local/src
- #添加nagios用户
- useradd nagios
- #安装nagios-plugins-1.4.15,nrpe,
- cd $tooldir
- tar zxvf nagios-plugins-1.4.15.tar.gz
- cd nagios-plugins-1.4.15
- ./configure --with-nagios-user=nagios --with-nagios-group=nagios
- make && make install
- cd $tooldir
- tar zxvf nrpe-2.12.tar.gz
- cd nrpe-2.12
- ./configure
- make all
- make install-plugin
- make install-daemon
- make install-daemon-config
- #配置nrpe信息
- #vim /usr/local/nagios/etc/nrpe.cfg
- #allowed_hosts=127.0.0.1 //允许监控的IP
- #
- /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
到服务器上修改配置文件nagios.cfg,注释localhost.cfg那行 添加一样mylinux.cfg
创建/usr/local/nagios/etc/objects/mylinux.cfg
- #定义主机部分
- define host{
- use linux-server
- host_name nagios-server
- alias naigos-server
- address 192.168.81.128
- icon_p_w_picpath web.gif
- statusmap_p_w_picpath web.gd2
- 2d_coords 100,300
- 3d_coords 100,300,100
- }
- define host{
- use linux-server
- host_name nagios-client
- alias nagios-client
- address 192.168.81.129
- icon_p_w_picpath server.gif
- statusmap_p_w_picpath server.gd2
- 2d_coords 200,300
- 3d_coords 200,300,100
- }
- #定义主机组部分
- define hostgroup{
- hostgroup_name linux-servers ; The name of the hostgroup
- alias Linux Servers ; Long name of the group
- members * ; Comma separated list of hosts that belong to this group
- }
- define hostgroup{
- hostgroup_name linux-server
- alias nagios-test
- members nagios-server,nagios-client
- }
- #定义服务组部分
- define servicegroup{
- servicegroup_name 系统负荷检查
- alias 负荷检查
- members nagios-client,进程总数,nagios-client,登录用户数,nagios-client,根分区,nagios-client,交换空间利用率,nagios-client,PING
- }
- #定义服务部分
- define service{
- use local-service ; Name of service template to use
- host_name *
- service_description PING
- check_command check_ping!100.0,20%!500.0,60%
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 根分区
- check_command check_local_disk!20%!10%!/
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 登录用户数
- check_command check_local_users!20!50
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 进程总数
- check_command check_local_procs!250!400!RSZDT
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 系统负荷
- check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description 交换空间利用率
- check_command check_local_swap!20!10
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description SSH
- check_command check_tcp!22!1.0!10.0
- notifications_enabled 0
- }
- define service{
- use local-service ; Name of service template to use
- host_name nagios-client
- service_description HTTP
- check_command check_http
- notifications_enabled 0
- }
由于我这台机器并没有http 所以会出现异常,可以将以上文件的最后一段去掉.
Windows客户端所用到的客户端 NSClient++
这个很简单,安装完成后编辑安装目录下的NSC.ini这个文件,按需求配置.之后再运行nsclient++.exe
将nagios-ser上的nagios.cfg的windows.cfg那行注释去掉,再编辑windows.cfg 改下IP就行了. 然后重启nagios服务!
配置文件中的配置可以到网上找找相关的资料,这里就不啰嗦了,呵呵!
当前名称:运维监控之Nagios实战(二)&Nagios客户端
链接分享:http://pwwzsj.com/article/jshios.html