1

Introduction

As /usr/local/nagios/etc/nsca.cfg is replaced by the default config if opsview has been restarted the reference to this file that resides in /etc/init.d/opsview was changed to /usr/local/nagios/etc/nsca_puppet.cfg and the latter is deployed using a Puppet ERB template.

Aim

The aim is to send passive checks using nsca to Opsview.

The hypothesis was that executing:

echo -e "HOST\tService\t0\tRemote File does not exist" | \
sudo /usr/local/nagios/bin/send_nsca -H host -c \
/usr/local/nagios/etc/send_nsca.cfg

would update the (passive) check that reside in Opsview.

Result

Tailing the /var/log/messages indicates the following:

Jan 24 14:27:37 host nsca[X]: 
Handling the connection for <ip>...
Jan 24 14:27:37 host nsca[X]: 
Command file '/usr/local/nagios/var/rw/nagios.cmd#015' 
does not exist, attempting to use alternate dump file 
'/dev/null' for output
Jan 24 14:27:37 host nsca[X]: 
SERVICE CHECK -> Host Name: 'HOST', Service Description: 
'Service', Return Code: '0', Output: 'Remote File does 
not exist' client <ip>
Jan 24 14:27:37 host nsca[X]: End of connection for <ip>...

Attempts to solve the issue

1) Perhaps the nsca command should be issued as the nagios user

sudo -u nagios /usr/local/nagios/bin/send_nsca

Does not solve the issue

2) does ncsa run?

Yes

user@host:~$ ps -ef | grep nsca
nagios   PID     1  0 13:38 ?        00:00:00 
/usr/local/nagios/bin/nsca -c 
/usr/local/nagios/etc/nsca.cfg --single

3) does it work to send ncsa commands from localhost

No, does not work either

4) Incorrect permissions nagios.cmd?

Seems to be ok

user@host:~$ ls -ltr /usr/local/nagios/var/rw/
total 4
-rw-rw-r--. 1 nagios nagios 1321 Jan 23 22:13 config_output.last_okay
srw-rw----. 1 nagios nagcmd    0 Jan 24 13:38 nagios.qh
prw-rw----. 1 nagios nagcmd    0 Jan 24 13:38 nagios.cmd
srw-rw----. 1 nagios nagcmd    0 Jan 24 13:38 opsviewd.cmd

5) Does it work to send other checks then the passive ones to Opsview using nsca

The issue occurs for all kind of checks

6) nagios.cmd#015 does not exist...? nagios.cmd was configured? Or not?

Yes this is correct

7) related bugs to this version of NSCA?

user@host:~$ sudo /usr/local/nagios/bin/nsca --version

NSCA - Nagios Service Check Acceptor
Copyright (c) 2000-2007 Ethan Galstad (www.nagios.org)
Version: 2.7.2
Last Modified: 07-03-2007
License: GPL v2
Encryption Routines: AVAILABLE

Seems to be ok as no issues were found on the internet.

8) Who is allowed to write to nagios.cmd?

User is not allowed to write:

user@host:~$ echo hello >> /usr/local/nagios/var/rw/nagios.cmd
-bash: /usr/local/nagios/var/rw/nagios.cmd: Permission denied

while nagios is:

user@host:~$ sudo su - nagios
nagios@host:~$ echo hello >> /usr/local/nagios/var/rw/nagios.cmd
nagios@host:~$

/usr/local/nagios/etc/nsca.cfg

command_file=/usr/local/nagios/var/rw/nagios.cmd

Questions

Several questions could be asked but the assumption at the moment is that the checks could not be processed as these are not written to nagios.cmd.

  1. Where does the #015 come from?
030
  • 5,731
  • 12
  • 61
  • 107

2 Answers2

0

According to this Q&A a #015 in the syslog corresponds to a \r.

The issue was caused because CRs were added by Puppet ERB templates.

Executing the following command:

sudo sed -i 's/\r//' /usr/local/nagios/etc/nsca.cfg 

and restarting opsview solved the issue.

In order to solve the CR template erb issue in Puppet, use content => regsubst(template("opsview/nsca.cfg.erb"), '\r', '', 'G'),.

030
  • 5,731
  • 12
  • 61
  • 107
-1

You don't mention running the nsca server. This is the most important piece.

Send_nsca needs data. Here your test is invalid:

1) Perhaps the nsca command should be issued as the nagios user

sudo -u nagios /usr/local/nagios/bin/send_nsca

Rather, you need to echo first and pipe the data in to send_nsca. Your nsca daemon on the server side is what needs to run as the nagios/nagcmd user/group.

Consult the following guide for more details on how to setup nsca:

http://munin.readthedocs.org/en/latest/tutorial/nagios.html

dmourati
  • 24,720
  • 2
  • 40
  • 69