监控linux主机,我目前没有windows server,后续会补充上
我这边以添加一台server  ip 192.168.20.250为例
我这边联系人不变,监控的服务也不变,
1.添加用户名
useradd -M  nagios  -s /sbin/nologin 
2.安装nagios-plugin
 tar zxvf  nagios-plugins-1.4.14.tar.gz 
./configure  --prefix=/usr/local/nagios 
Make
Make install
3.安装nrpe
./configure  --prefix=/usr/local/nagios 
make all
 make install-plugin
make install-daemon
make install-daemon-config
4.编辑nrpe.cfg文件
server_port=5666    nrpe端口
allowed_hosts=192.168.20.221     nagios server ip
command[check_users]=/usr/local/nagios/libexec/check_users -w 3 -c 5
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 15% -p / -u GB
command[check_zombie_procs]=/usr/local/nagios//libexec/check_procs -w 1 -c 2 -s Z
command[check_total_procs]=/usr/local/nagios//libexec/check_procs -w 150 -c 200
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20 -c 10
command[check_ping]=/usr/local/nagios/libexec/check_ping -H $ARG1$ -w $ARG2$  -c $ARG3$ -p 5
防火墙上开启5666的端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5666  -j ACCEPT
Ok,启动250上的nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
再nagios server上
进入到
/usr/local/nagios/etc/objects
define host{
        host_name               192.168.20.250
        alias                   192.168.20.250
        address                 192.168.20.250
        contact_groups          admins
        max_check_attempts      5
         notification_interval  200
         notification_options   d,u,r
}           这个要有,不然在监控的时候会一直显示DOWN状态
进入到/usr/local/nagios/etc/servers 
新建文件:192.168.20.250.cfg
define service{
        use             generic-service
        host_name       192.168.20.250
        service_description     check-host-alive
        check_command           check_ping!100.0,20%!500.0,60%
        max_check_attempts      5
        normal_check_interval   1
}
define service{
        use             generic-service
        host_name       192.168.20.250
        service_description     check_ssh
        check_command           check_ssh
        max_check_attempts      5
        normal_check_interval   1
}
define service{
        use     generic-service
        host_name       192.168.20.250
        service_description     check_http
        check_command           check_http
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       192.168.20.250
        service_description     check_smtp
        check_command           check_smtp
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       192.168.20.250
        service_description     check_disk
        check_command           check_nrpe!check_disk
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       192.168.20.250
        service_description     check_load
        check_command           check_nrpe!check_load
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       192.168.20.250
        service_description     check_swap
        check_command           check_nrpe!check_swap
        max_check_attempts 5
        normal_check_interval 1
}
这些都是250上运行的服务
检查nagios是否出错
 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
Total Warnings: 0
Total Errors:   0
Ok,没有问题
[root@server221 servers]# service nagios restart 
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
再web访问nagios看看,会自动多出来192.168.20.250这个主机的监控状态
这些监控的服务,可以和我们建立的192.168.20.250的服务名对比下
我们的监控服务选项,都是从servers下的配置文件来的
之前在排除error的时候,nagios有发送邮件,其实也可以自己模拟一下的,nagios发送邮件
Nagios下,如果到libexec下会发现没有内存和CPU、网卡流量等监控信息
个人在安装的时候发现,nagios基本上没有图表来诠释服务器状态,cacti主要是可以采集信息,nagios主要是使用它的监控机制
Cacti 数据采集
像硬盘空间、负载、流量等都可以显示出来
如果选择cacti与nagios结合,无意是最大的选择方向,后续会将cacti与nagios的结合整理出来,以上安装是自己边安装边去解决error,可能再某一块写的不是很好,还请大家指点出来,共同学习
如果对nagios有兴趣,可以加入QQ群:140704742
以上是自己亲手整理出来的,可以正常监控,正常实现报警机制