成都网站建设设计

将想法与焦点和您一起共享

nagios监控自身-创新互联

nagios 监控自身

创新互联公司是专业的金山网站建设公司,金山接单;提供成都网站设计、网站建设、外贸网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行金山网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

定义监控命令 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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页名称:nagios监控自身-创新互联
本文路径:http://chengdu.cdxwcx.cn/article/ccohco.html