config.inc.php里面的项
$cfg["check_results_dir"]="/var/log/nagios/spool/checkresults"
这个目录一定要是apache与nagios用户都有可读写权限
php send_nrdp.php --url= --token=98jstd044855 --host=11111 --service=iostat --state=1 --output="The service looks okay"
Nagios(1主+Cluster)
#vim /usr/local/nagios/etc/nagios.cfg
check_external_commands=1 # 配置nagios检查扩展命令
accept_passive_service_checks=1 # 配置接受被动服务检测的结果
accept_passive_host_checks=1 #配置接受被动主机检测的结果
配置:nrdp
从Git上下载nrdp文件
解压到/usr/local/nrdp目录下
cd /usr/local/nrdp/
ls
CHANGES.TXT clients install-html INSTALL.TXT LICENSE.TXT nrdp.conf server
cp nrpd.conf /etc/httpd/conf.d/
修改 server/config.inc.php的内容:
1:$cfg["nagios_command_group"]="nagios"
2:$cfg["command_file"]="/var/spool/nagios/cmd/nagios.cmd"
3:$cfg["check_results_dir"]="/var/log/nagios/spool/checkresults"
#把apache用户加到nagios组里
usermod -G nagios apache
/var/log/nagios/spool/checkresults 权限修改
chmod -R 775 checkresults
cluster
#vim nagios.cfg
enable_notifications=0 //阻止它直接送出任何通知信息
obsess_over_services=1 // 配置为强迫型服务(obsess over services)类型
ocsp_command=submit_check_result //定义一个强迫型服务处理(ocsp)命令
obsess_over_hosts=1
ochp_command=submit_hostcheck_result
#vim command.cfg
define command{
command_name submit_check_result //添加这条命令
# --state=$SERVICESTATEID$这个注意:不能写成SERVICESTATE,不然state得不到!
command_line /usr/bin/php $USER1$/send_nrdp.php --url= --token=98jstd044855 --host=$HOSTNAME$ --service='$SERVICEDESC$' --state=$SERVICESTATEID$ --output='$SERVICEOUTPUT$|$SERVICEPERFDATA$'
}
define command {
command_name submit_hostcheck_result
command_line /usr/bin/php $USER1$/send_nrdp.php --url= --token=98jstd044855 --host=$HOSTNAME$ --state=$HOSTSTATEID$ --output='$HOSTOUTPUT$|$HOSTPERFDATA$'
}
define service {
host_name KSC160523105950_3
service_description Current_Load
use local-service
active_checks_enabled 0
passive_checks_enabled 1
check_command check_shi_load!15,15,15!30,25,20
check_freshness 1
notification_interval 300
freshness_threshold 86400
register 1
notifications_enabled 1
contact_groups nagiosadmin
}
submit_hostcheck_result
阅读(4130) | 评论(0) | 转发(0) |