在添加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.
凯发app官方网站的解决方案:
在被监控机nrpe.cfg中,增加监控主机的地址:
- #note: this option is ignored if nrpe is running under eitherinetd or xinetd
- allowed_hosts=127.0.0.1,ip
注意两个地址以逗号隔开,并关闭超级守护进程xinetd.
阅读(28393) | 评论(1) | 转发(2) |