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


相关内容

热门资讯

德国总理:美国正在被伊朗羞辱 德国之声4月27日报道,德国总理默茨在访问一所学校时表示,在当前的持续冲突中,伊朗领导层正试图羞辱美...
理响中国|“长”歌以行,风云激... 光阴如梭,东方潮阔。这里是中国的长三角,世界的长三角。无论过去、现在还是未来,这片土地都因时代而生,...
白宫:特朗普及其国安团队开会讨... 新华社华盛顿4月27日电 美国白宫新闻秘书莱维特27日在记者会上证实,总统特朗普及其国家安全团队当天...
人民日报刊文:日本放开杀伤性武... 日本放开杀伤性武器出口推高地缘冲突风险(国际论坛)常思纯《人民日报》(2026年04月28日 第 0...
医疗保障法草案二审:明确生育保... 满足多样化健康保障需求本报记者 彭 波4月27日,医疗保障法草案二审稿提请十四届全国人大常委会第二十...
天津一景区发生自转旋翼机事故1... 澎湃新闻记者 吕新文中国民用航空华北地区管理局4月22日公布《豪客通航“10•1”天津长芦汉盐旅游区...
卡塔尔埃米尔与美国总统特朗普通... 当地时间24日,卡塔尔埃米尔塔米姆与美国总统特朗普通电话,重点就中东地区局势以及伊朗与美国谈判问题交...
男子30年前被扣押2859克黄... 澎湃新闻记者 王鑫家住辽宁省大连市的潘永嘉近日向澎湃新闻反映称,三十年前,他在大连周水子机场被盖州市...
商务部:取消反制欧盟两家金融机... 中华人民共和国商务部令二〇二六年 第1号鉴于欧盟已取消对中国两家金融机构的制裁措施,现公布《关于取消...
过去24小时共有5艘船只通过霍... 总台记者当地时间24日获悉,过去24小时内,共有5艘船只通过霍尔木兹海峡,其中包括一艘伊朗油轮。(总...