修改services_nagios2.cfg配置
vi /etc/nagios3/conf.d/services_nagios2.cfg
notification_interval 1
vi /etc/nagios3/conf.d/generic-service_nagios2.cfg
notification_interval 1
删除install.php
# cd /usr/share/pnp4nagios/html
# mv install.php install.php.bak
Nagios插件目录: /usr/lib/nagios/plugins/
添加pnp4nagios插件
vi /etc/nagios3/conf.d/pnp4nagos.cfg 追加如下配置
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$'class='tips'rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
process_perf_data 1
}
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
process_perf_data 1
}
Code
默认是没有监控内存的,若需要监控复制check_mem.sh文件到插件目录,再添加相关配置文件
添加自定义执行命令
vi /etc/nagios3/conf.d/custom_commond.cfg
监控服务器网卡流量
apt-get install snmpd snmp-mibs-downloader
vi /etc/snmp/snmpd.conf(可备份snmpd.conf,修改下面的localhost-IP为服务器IP,保存此文件即可)
com2sec notConfigUser 127.0.0.1 public
com2sec notConfigUser localhost-IP public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.2
view systemview included .1.3.6.1.2.1.25.1.1
view all included .1
access notConfigGroup "" any noauth exact all none none
Code 重启snmpd服务
下载check_traffic.sh到插件目录
cd /usr/lib/nagios/plugins/
测试执行
./check_traffic.sh -V 2c -C public -H your_ip -I 2 -w 1200,1500 -c 1700,1800 -K -B
# vi /etc/nagios3/conf.d/custom_commond.cfg 追加
define host{
use generic-host ; Inherit default values from a template
host_name Dow1_Server ; The name we're giving to this server
alias DriverServer ; A longer name for the server
address 10.10.0.32 ; IP address of Remote Linux host
}
Code 添加监控服务项,注意使用的命令是自定义的nrpe
# vi /etc/nagios3/conf.d/custom_services.cfg
define service{
use generic-service
host_name Dow1_Server_198.27.75.32
service_description CPU Load
check_command custom_check_nrpe!check_load
}
Code iptables -A INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
service iptables save
service iptables restart