htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
2. 添加要监控的机器和要监控的服务cfg_file=/usr/local/nagios/etc/objects/localhost.cfg cfg_file=/usr/local/nagios/etc/objects/system_1.cfg
2. 2添加被监听节点需要被监听的服务,例如:/usr/local/nagios/etc/objects/system_1.cfgcfg_file=/usr/local/nagios/etc/objects/system_2.cfg
......nagios_user=nagiosnagios_group=nagioslock_file=/usr/local/nagios/var/nagios.lockstatus_update_interval=10
## define hosts
# system_1 oam_1 define host{ use linux-server,host-pnp host_name system_1_oam_1 address <ip> contact_groups system_1_admins,systems_admins } ...... # system_1 traffic_1 define host{ use linux-server,host-pnp host_name system_1_traffic_1 address <ip> contact_groups system_1_admins,systems_admins } ......
## define services# system_1 oam_1 define service{ use passive_service,srv-pnp service_description CPU_Status host_name system_1_oam_1 contact_groups system_1_admins,systems_admins } define service{ use passive_service,srv-pnp service_description Memory_Status host_name system_1_oam_1 contact_groups system_1_admins,systems_admins } ...... # system_1 traffic_1 define service{ use passive_service,srv-pnp service_description CPU_Status host_name system_1_traffic_1 contact_groups system_1_admins,systems_admins }
define contactgroup{ contactgroup_name system_1_admins alias system_1_admins members oam-1,traffic-1 } ......3.2 /usr/local/nagios/etc/objects/contacts.cfg
define contact{ contact_name oam-1 ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias oam-1 ; Full name of user service_notification_options c host_notification_options d email nobody@localhost.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } define contact{ contact_name traffic-1 ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias traffic-1 ; Full name of user email nobody@localhost.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } ......Note:
#处理performance数据 process_performance_data=1 #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata #performance数据存储文件 host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata #performance数据存储格式 host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$\tSERVICEOUTPUT::$SERVICEOUTPUT$ #performance文件存储方式 host_perfdata_file_mode=a service_perfdata_file_mode=a #performance文件处理时间间隔 host_perfdata_file_processing_interval=15 service_perfdata_file_processing_interval=15 <pre name="code" class="plain">#performance文件处理命令host_perfdata_file_processing_command=process-host-perfdata-fileservice_perfdata_file_processing_command=process-service-perfdata-file 6.2 修改/usr/local/nagios/etc/objects/commands.cfg,增加performance文件处理命令
define command{ command_name process-service-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$ } define command{ command_name process-host-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$ }6.3 修改nagios.cfg,设置在nagios web gui中显示pnp4nagios图标的方式
第一种方法在templates.cfg里面加入如下,只能在新窗口打开图像数据
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
第二种方法可以在鼠标移到pnp4nagios图标的时候就可以开到实时图标,不过效果不是很好,按照说明加入如下:
拷贝status-header.ssi到/usr/local/nagios/share/ssi/目录下面,同时修改templates.cfg,加入如下内容:
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_‘ class=‘tips‘ rel=‘/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$‘ class=‘tips‘ rel=‘/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
Note: 自动出现的小窗口清晰度不好,我喜欢第一种方式
Note: 这里没有涉及email的配置,记得通知设计的时候小心消息泛滥被投诉。。。
实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- Nagios Server端
原文地址:http://blog.csdn.net/cloud_ll/article/details/39315689