nagios 监控自身
admin
2023-02-09 06:40:06
0

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


相关内容

热门资讯

王虹、邓煜为啥能获菲尔兹奖? 当地时间7月23日早晨,2026年国际数学家大会在美国费城开幕。国际数学联盟在开幕式上正式公布第二十...
高温津贴,不能用绿豆汤冲抵 近日,深圳市人力资源和社会保障局发布关于高温津贴的典型劳动仲裁案例,并普法提醒:即便劳动合同约定日薪...
菲律宾,你到底想干什么 中国和菲律宾关系,又出幺蛾子了。反正,最近几天,麻烦不断,场面火爆。仁爱礁,菲两艘小艇冲撞我巡逻船只...
聚焦长期价值,方舟云康以数智化... 来源:江南时报 在慢病管理领域,单纯追逐“流量”的互联网医疗模式已显疲态。当线上获客成本持续走高、用...
阿拉比卡以后喝不到了?对话云大... 搜狐科技《思想大爆炸——对话科学家》栏目第157期,对话云南大学农学院教授何飞飞。 嘉宾简介: 何飞...
微信重磅更新!超实用 7月23日,微信派发文晒微信未成年人模式,进入“未成年人模式”后,家长可为孩子设置“每日消费限额”和...
13岁少年帮聋哑舅舅卖瓜,记者... 河南13岁少年帮聋哑舅舅卖瓜走红,记者购买2万斤西瓜助农,临走时少年妈妈拉着记者表示感谢:“如果不是...
12999元起!三星首款阔折叠... 7月22日晚,三星举行 Galaxy Z8 系列折叠屏手机全球发布会,一口气带来了Galaxy Z ...
西门子抽油烟机为什么不转了 西门子抽油烟机为什么不转了1、可能是油烟机里面的电机坏掉了,或者是里面的风扇叶片上有太多的油渍,也有...
四预警齐发!台风“红霞”最新路... 今天(24日)6时,中央气象台发布高温黄色预警、暴雨蓝色预警、强对流天气蓝色预警、台风橙色预警。高温...