设为首页 收藏本站
查看: 778|回复: 0

Nagios: How to Enable check_nrpe Command Line Arguments

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2019-1-16 12:25:16 | 显示全部楼层 |阅读模式
  Question: When I execute check_nrpe command with some arguments, I get the message “CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.”. How do I fix this issue?
  Answer: The issue is very straight forward. check_nrpe doesn’t take any arguments by default. You should enable the command line arguments for check_nrpe as shown below.
  

  


Verify the check_nrpe error message
  Just for testing purpose, let us assume that you are execuing the following check_nrpe command that displays the “CHECK_NRPE: Received 0 bytes from daemon.” error message.
  

$ /usr/local/nagios/libexec/check_nrpe -H 192.168.1.20 -c check_disk -a 60 80 /dev/sdb1  
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
  

  

  If you view the /var/log/messages on the remote host, (in the above example, that is 192.168.1.20), you’ll see the nrpe error “Error: Request contained command arguments!” as shown below, indicating that check_nrpe is not enabled to take the command arguments.
  

$ tail -f /var/log/messages  
Dec 5 11:11:52 dev-db xinetd[2536]: START: nrpe pid=24187 from=192.168.101.108
  
Dec 5 11:11:52 dev-db nrpe[24187]: Error: Request contained command arguments!
  
Dec 5 11:11:52 dev-db nrpe[24187]: Client request was invalid, bailing out...
  
Dec 5 11:11:52 dev-db xinetd[2536]: EXIT: nrpe status=0 pid=24187 duration=0(sec)
  

  

Enable check_nrpe command arguments
  To enable command arguments in NRPE, you should do the following two things.

1. Configure NRPE with –enable-command-args
  Typically when you install NRPE on the remote host, you’ll do ./configure without any arguments. To enable support for command arguments in the NRPE daemon, you should install it with –enable-command-args as shown below.
  

[remotehost]# tar xvfz nrpe-2.12.tar.gz  
[remotehost]# cd nrpe-2.12
  

  
[remotehost]# ./configure --enable-command-args
  

  
[remotehost]# make all
  
[remotehost]# make install-plugin
  
[remotehost]# make install-daemon
  
[remotehost]# make install-daemon-config
  
[remotehost]# make install-xinetd
  

  

2. Modify nrpe.cfg and set dont_blame_nrpe
  Modify the /usr/local/nagios/etc/nrpe.cfg on the remote server and set the dont_blame_nrpe directive to 1 as shown below.
  

$ /usr/local/nagios/etc/nrpe.cfg  
dont_blame_nrpe=1
  

  

Execute check_nrpe with command arguments
  After the above two changes, if you execute the check_nrpe for this particular remote host, you’ll not see the error message anymore as shown below.
  

$ /usr/local/nagios/libexec/check_nrpe -H 192.168.1.20 -c check_disk -a 60 80 /dev/sdb1  
DISK OK - free space: / 111199 MB (92% inode=99%);| /=9319MB;101662;114370;0;127078
  

  

Security Warning
  Enabling NRPE command line arguments is a security risk. If you don’t know what you are doing, don’t enable this.
  Probably by now you’ve already figured out that you can’t blame NRPE if something goes wrong. After all you did set dont_blame_nrpe to 1.
  注意:启用了NRPE的命令行参数功能可能会带来严重的安全问题(如果你没有做足工作的话),有一篇文章比较清楚地说明了这个问题,转贴如下:
  Imagine you have this command in your nrpe.cfg file:
  command[check_disk]=/usr/local/nagios/libexec/chec_disk -p $ARG1$
  and you want to pass "/usr" as the parameter to check the disk space available to the /usr directory.
  Now, imagine some rogue has discovered you're running NRPE on your server, connects to it, and sends the command check_disk with "/usr && rm -rf /" as the argument.
  NRPE will pass out to the shell the command "/usr/local/nagios/libexec/chec_disk -p /usr && rm -rf /" which will cause it to run the plugin, then erase the entire contents of your server's file system.
  To be fair, I think it's only a risk if your server is wide open in other ways, such as:
  - NRPE allowing any host to connect to it
  - No firewall restrictions
  - sudo security really permissive
  etc.  So if you know that only your Nagios server can connect to Nagios (restricted by firewalls and allowed_hosts in nrpe.cfg) I think, with a bit of extra attention paid to command definitions, you'll be OK.  But that's just my opinion.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-663997-1-1.html 上篇帖子: Nagios安装、配置记录 下篇帖子: nagios报警不发邮件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表