设为首页 收藏本站
查看: 1492|回复: 1

安装nagios简单的应用

[复制链接]
累计签到:6 天
连续签到:1 天
发表于 2016-5-7 13:32:03 | 显示全部楼层 |阅读模式


1--关闭服务器和selinux
[iyunv@localhost-150~]# chkconfig  ip6tables off
[iyunv@localhost-150~]# chkconfig  iptables off
[iyunv@localhost-150~]# chkconfig --list|grep iptables
iptables        0:off  1:off   2:off   3:off  4:off   5:off   6:off
[iyunv@localhost-150~]# chkconfig --list|grep ip6tables
ip6tables       0:off  1:off   2:off   3:off  4:off   5:off   6:off
[iyunv@localhost-150~]# vi /etc/selinux/config
更改selinux
SELINUX=disabled
重启服务器
2--Nagios安装 - 服务端(192.168.1.151)
安装一个epel的扩展源
[iyunv@64 ~]# yum install  epel-release (6.7前版本不支持)
[iyunv@64 ~]# wget -P/etc/yum.repos.d/  http://mirrors.aliyun.com/repo/epel-6.repo
安装扩展YUM源
[iyunv@64 ~]# yum install -y httpd nagiosnagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe
安装主要组件及工具
[iyunv@64 ~]# htpasswd -c /etc/nagios/passwdnagiosadmin
创建用户和密码
[iyunv@64 ~]# vim /etc/nagios/nagios.cfg
[iyunv@64 ~]# nagios -v /etc/nagios/nagios.cfg
检测配置文件
Total Warnings: 0
Total Errors:   0
启动服务
[iyunv@64 ~]# service httpd start
[iyunv@64 ~]# service nagios start
浏览器访问: http://ip/nagios
2. Nagios安装 - 客户端(192.168.1.88)
关闭服务器和selinux
[iyunv@localhost~]# chkconfig  ip6tables off
[iyunv@localhost~]# chkconfig  iptables off
[iyunv@localhost~]# chkconfig --list|grep iptables
iptables        0:off  1:off   2:off   3:off  4:off   5:off   6:off
[iyunv@localhost~]# chkconfig --list|grep ip6tables
ip6tables       0:off  1:off   2:off   3:off  4:off   5:off   6:off
[iyunv@localhost~]# vi /etc/selinux/config
SELINUX=disabled
重启服务器

[iyunv@64 ~]# yum install  epel-release (6.7前版本不支持)
[iyunv@localhost ~]# wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo
安装扩展YUM源
[iyunv@localhost ~]#yum install -y nagios-pluginsnagios-plugins-all nrpe nagios-plugins-nrpe
[iyunv@64 ~]#vim /etc/nagios/nrpe.cfg
找到“allowed_hosts=127.0.0.1” 改为 “allowed_hosts=127.0.0.1,192.168.1.108”
allowed_hosts=127.0.0.1,192.168.1.108
找到”dont_blame_nrpe=0”改为  “dont_blame_nrpe=1”
dont_blame_nrpe=1
[iyunv@localhost ~]# /etc/init.d/nrpe start

3. 监控中心(192.168.1.151)添加被监控主机(192.168.1.88)
[iyunv@nagios~]# cd /etc/nagios/conf.d/
[root@nagiosconf.d]# vi 192.168.1.88.cfg
define host{
        use                     linux-server
        host_name           192.168.1.88
        alias                       1.88
        address                 192.168.1.88
        }
define service{
        use                     generic-service
        host_name               192.168.1.88
        service_description     check_ping
        check_command           check_ping!100.0,20%!200.0,50%
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use                     generic-service
        host_name               192.168.1.88
        service_description     check_ssh
        check_command           check_ssh
        max_check_attempts      5
        normal_check_interval   1
        notification_interval   60
}
define service{
        use                     generic-service
        host_name               192.168.1.88
        service_description     check_http
        check_command           check_http
        max_check_attempts      5
        normal_check_interval 1
}
备注:
max_check_attempts     5    ;当nagios检测到问题时,一共尝试检测5次都有问题才会告警,如果该数值为1,那么检测到问题立即告警
normal_check_interval    1   ;重新检测的时间间隔,单位是分钟,默认是3分钟
notification_interval        60 ;在服务出现异常后,故障一直没有解决,nagios再次对使用者发出通知的时间。单位是分钟。如果你认为,所有的事件只需要一次通知就够了,可以把这里的选项设为0。
4--监控客户端硬盘,内存情况
#由于需要nagios调用的监控命令都需要在command.cfg模块中定义而前面的check_nrpe在默认的command.cfg中时没有的  这里需要在command.cfg中将其加入进去
[iyunv@nagios conf.d]# vim/etc/nagios/objects/commands.cfg
定义check_nrpe编辑文件添加下面内容:
define command{
       command_name    check_nrpe
       command_line    $USER1$/check_nrpe-H $HOSTADDRESS$ -c $ARG1$
        }
[root@nagiosconf.d]# vi 192.168.1.88.cfg
在监控的客户端配置中添加以下内容:
define service{
        use    generic-service
        host_name       192.168.1.88
        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.1.88
        service_description     check_disk_hda1
        check_command           check_nrpe!check_hda1
        max_check_attempts 5
        normal_check_interval 1
}
在客户端查看check_load,check_hda1服务
[iyunv@localhost ~]#df -h
Filesystem      Size Used Avail Use% Mounted on
/dev/sda3        18G 1.5G   16G  10% /
tmpfs           932M     0 932M   0% /dev/shm
/dev/sda1       190M  32M  149M  18% /boot
/dev/sdb1        50G  16G   32G  33% /data
[iyunv@localhost ~]#vi /etc/nagios/nrpe.cfg
[iyunv@localhost ~]# /usr/lib64/nagios/plugins/check_disk -w 20%-c 10% -p /dev/sdb1
[iyunv@localhost~]# vi /etc/nagios/nrpe.cfg
command[check_load]=/usr/lib64/nagios/plugins/check_load-w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib64/nagios/plugins/check_disk-w 20% -c 10% -p /dev/sdb1
5--服务器端配置邮件告警
[iyunv@64 ~]# vim /etc/nagios/objects/contacts.cfg
define contact{
        contact_name              123
        use                           generic-contact
        alias                          xin
        email             15210603363@139.com
        }
define contact{
        contact_name              456
        use                           generic-contact
        alias                           aaa
        email             dslchair@qq.com
        }
define contactgroup{
        contactgroup_name          common
        alias                                common
        members                        123,456
        }
备注:
define contactgroup定义组
define contact 定义用户
然后在要需要告警的服务里面加上contactgroup
define service{
        use                     generic-service
        host_name               192.168.1.88
        service_description     check_ping
        check_command           check_ping!100.0,20%!200.0,50%
        max_check_attempts 5
        normal_check_interval 1
      contact_groups        common
}



在需要告警的服务添加定义组





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-213889-1-1.html 上篇帖子: Nagios插件check_oracle_health问题请教 下篇帖子: nagios报警邮件发件人更改 服务器
累计签到:4 天
连续签到:1 天
发表于 2016-7-10 06:29:58 | 显示全部楼层
继续赚金币

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表