首页 > 运营 > 帮助中心 > 正文

Nagios远程监控安装与配置详解图文第3/3页

2020-07-28 14:30:48
字体:
来源:转载
供稿:网友

2、增加新的配置文件
先创建简单的配置文件timeperiods.cfg,其内容如下:
define timeperiod{    timeperiod_name 24x7    alias      24 Hours A Day, 7 Days A Week    sunday     00:00-24:00    monday     00:00-24:00    tuesday     00:00-24:00    wednesday    00:00-24:00    thursday    00:00-24:00    friday     00:00-24:00    saturday    00:00-24:00    }
这个文件的定义明晰易懂,不多做说明。另建议7X24小时监控。
第二个手动创建的配置文件是 contacts.cfg,其格式如下:
define contact {    contact_name     sa  //不要有空格    alias        system administrator    service_notification_period  24x7    host_notification_period    24x7    service_notification_options  w,u,c,r    host_notification_options    d,u,r    service_notification_commands service-notify-by-sms,service-notify-by-email //这个命令读配置文件miscommands.cfg    host_notification_commands   host-notify-by-email,host-notify-by-sms   //这个命令读配置文件miscommands.cfg    email             sery@163.com    pager             13333333333 //手机号,收报警短信    }   //不要把这个符号写掉了define contact {    contact_name     sery    alias        system administrator    service_notification_period  24x7    host_notification_period    24x7    service_notification_options  w,u,c,r    host_notification_options    d,u,r    service_notification_commands service-notify-by-sms,service-notify-by-email    host_notification_commands   host-notify-by-email,host-notify-by-sms    email             sery@sohu.com    pager             13312345678    }
上面的文件定义了2个联系人,如果有更多联系人的话,照这个格式在后面追加即可。服务通知选项(service_notification_options)与主机通知选项(host_notification_options)的几个选项在这里说明一下:w-warning , u-unknown,c-critical,r-recovery;d-down,u-unreachable,注意一下,主机报警和服务报警有些差异。
紧接着的第三个手动创建的配置文件是contactgroups.cfg文件,这个文件是依照上一个文件contacts.cfg来的,contactgroups文件相对简单一些,其格式如下:
define contactgroup {    contactgroup_name  sagroup //不要用空格    alias        system administrator group    members       sa,sery //本例有2个成员}
多个成员之间用逗号做分界符,如果有更多的联系组,就依相同的格式在文件中追加余下的组。
关键的角色终于登场,这就是配置文件hosts.cfg。下面是我定义的两个主机的基本样式:
#define monitor host################################################################## Wangjing IDC servers                     ##################################################################define host {    host_name         nagios-server    alias           nagios server    address          61.x..x.49    contact_groups       sagroup //多个联系组用逗号分隔,
数据来源于contactgroups.cfg check_command check-host-alive max_check_attempts 5 notification_interval 10 //值可调,大小什么值合适需自己测定 notification_period 24x7 notification_options d,u,r }define host { host_name 24-25 alias server 24-25 address 202.X.24.25 contact_groups sagroup check_command check-host-alive //down机就发报警通知 max_check_attempts 5 notification_interval 10 notification_period 24x7 notification_options d,u,r }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表