在添加nagios客户端NRPE时,遇到NRPE: Unable to read output
- # /usr/local/nagios/libexec/check_nrpe -H 192.168.15.178 -c check_mysql_myisam_lock
- NRPE: Unable to read output
可以查看到客户端的nrpe信息,说明监控机与被监控机的nrpedaemon通信是正常。
手动运行监控脚本:
- # /usr/local/nagios//libexec/check_mysql_myisam_lock.sh -w 1 -c 1
- OK - mysql myisam lock is 0.04%,table_locks_waited is 1047362,table_locks_immediate is 2522055024|Keyh=0.0415281%;1047362;2522055024;0;0
获取是数据正常。
尝试用Naigos用户shell运行脚本:
- #usermod -s /bin/bash nagios
- #su - nagios
- [nagios@mysql ~]$ /usr/local/nagios/libexec/check_mysql_myisam_lock.sh
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/mysqldata/mysql.sock' (13)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/mysqldata/mysql.sock' (13)
awk: cmd. line:1: BEGIN{printf "%.2f%\n",(/)*100}
awk: cmd. line:1: ^ unterminated regexp
awk: cmd. line:2: BEGIN{printf "%.2f%\n",(/)*100}
awk: cmd. line:2: ^ unexpected newline or end of string
awk: cmd. line:1: BEGIN{printf (/)*100}
awk: cmd. line:1: ^ unterminated regexp
awk: cmd. line:2: BEGIN{printf (/)*100}
awk: cmd. line:2: ^ unexpected newline or end of string
(standard_in) 1: parse error
(standard_in) 1: parse error
提示运行监控脚本错误,无法连接数据库,那么获取的性能数据就错误,Naigos出现
NRPE: Unable to read output
可以判断是nagios运行脚本的权限不足引起的。尝试使用sudo 权限试试。
添加:
nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_mysql_myisam_lock
注意:为了安全起见,添加只允许运行的监控脚本即可,并且设置脚本不可写状态。
重新sudo运行
- #su - nagios
- [nagios@mysql ~]$/usr/bin/sudo /usr/local/nagios/libexec/check_mysql_myisam_lock.sh
- OK - mysql myisam lock is 0.04%,table_locks_waited is 1047377,table_locks_immediate is 2522087304|Keyh=0.0415282%;1047377;2522087304;0;0
找到了问题。
最后,编辑nrpe.cfg里面commands命令:
- #vim /usr/local/nagios/etc/nrpe.cfg
- command[check_mysql_myisam_lock]=/usr/bin/sudo /usr/local/nagios//libexec/check_mysql_myisam_lock.sh -w 1 -c 1
监控正常:
在网上也查找了相关资料,出现的问题可能有很多种。
根据问题查找得出一些分析的注意地方:
1、检查客户端nrpe的权限是否可读,可被nagios执行,如果nagios权限不够,需要提权。
2、检查nrpe.cfg里面commands命令路径是否正确。
3、在配置完nrpe.cfg,没有杀nrpe进程。
常见的一些nrpe的错误信息解决方法:
在监控机上,执行:
- #root@localhost libexec]#/usr/local/nagios/libexec/check_nrpe -H IP
- CHECK_NRPE: Error - Could not complete SSL handshake.
解决方案:
在被监控机nrpe.cfg中,增加监控主机的地址:
- #NOTE: This option is ignored if NRPE is running under eitherinetd or xinetd
- allowed_hosts=127.0.0.1,IP
注意两个地址以逗号隔开,并关闭超级守护进程xinetd.
阅读(1045) | 评论(0) | 转发(0) |