设为首页 收藏本站
查看: 1202|回复: 0

nagios 监控自身

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-10-27 09:29:15 | 显示全部楼层 |阅读模式
nagios 监控自身

定义监控命令 commands.cfg
vim /usr/local/nagios/etc/objects/commands.cfg

#local_server check-host-alive command definition
define command{
        command_name        xxx   #定义监控的名字(自定义)
        command_line        xxx   #定义命令具体实现的功能 $USER1$ = /usr/local/nagios/libexec/ 变量在/usr/local/nagios/etc/resource.cfg中定义
}

#local_server check-host-alive command definition
define command{
        command_name        check-host-alive   
        command_line        $USER1$/ping  -H  $HOSTADDRESS$  -w  3000.0,80%  -c  5000.0,100%  -p  5
}


定义监控对象 localhost.cfg

Localhost.cfg相当于是一个监控LINUX主机的模板,如果需要监控其他LINUX主机,可以把这个文件复制一份进行修改。

cp localhost.cfg linux.cfg
vim linux.cfg

define host {
        use                 监控使用的模板
        host_name         被监控主机的主机名
        alias                被监控主机别名
        address                被监控主机IP地址
}


define host{
        use                     linux-server            
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }
use linux-server:加载linux-server的配置(linux-server已在templates.cfg中定义)
use local-service:加载local-service的配置(已在templates.cfg中定义)


查看templates.cfg:

define host{
        name                            linux-server    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
        check_period                    24x7            ; By default, Linux hosts are checked round the clock
        check_interval                  5               ; Actively check the host every 5 minutes
        retry_interval                  1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts              10              ; Check each Linux host 10 times (max)
        check_command                   check-host-alive ; Default command to check Linux hosts
        notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
                                                        ; the value that is inherited from the generic-host template!
        notification_interval           120             ; Resend notifications every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
        contact_groups                  admins          ; Notifications get sent to the admins by default
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }


check_periaod  24X7: 检测的时间段为24X7,24X7在timeperiod.cfg
contact_groups  admins:发通知给admins组,admins组在contacts.cfg中定义


加载监控对戏那个配置文件 nagios.cfg
vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

检查配置语法是否有误
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

启动nagios和httpd服务
service httpd restart
service nagios restart
chkconfig httpd on
chkconfig nagios restart

配置登录页面认证用户

进入WEB页面查看
http://ip/nagios


自定义监控项目

自定义监控对象

监控/boot分区
首先查看commands.cfg



定义监控的分区
vim  localhost.cfg
define service{
        use                     local-service
        host_name               localhost
        service_description     Boot Partition                        在nagios Services 中显示的名称
        check_command           check_local_disk!50%!40%!/boot       
        notifications_enabled         1                                是否开启提醒功能。1为开启,0为禁用
}

重启nagios
service  nagios  restart

notifications_enabled


运维网声明 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-26597-1-1.html 上篇帖子: nagios 安装 下篇帖子: nagios监控远端主机 监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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