naemon / naemon-core

Networks, Applications and Event Monitor
http://www.naemon.io/
GNU General Public License v2.0
153 stars 63 forks source link

External command error: Invalid value #107

Closed mgadi closed 8 years ago

mgadi commented 9 years ago

Hi! Today I tried the lastest version of naemon v1.0.0 . Unfortunately, when naemon receive an SNMP trap, naemon sends in naemon.log : 1- Warning: External command parse error [1427256079] PROCESS_SERVICE_CHECK_RESULT;127.0.0.1;snmptrap-service;2;Link down on interface 2. Admin state: 1. Operational state: 1 (Invalid value) 2 - External command error: Invalid value 3- i have this in /var/log/snmptt/snmptt.log : Wed Mar 25 05:38:46 2015 .1.3.6.1.6.3.1.1.5.3 Normal "Status Events" naemonbox-standalone.localdomain - Link down on interface 2. Admin state: 1. Operational state: 1 (it doesn't work for me since Naemon 0.8.0 )

nook24 commented 9 years ago

Hi It Looks like you swaped $HOSTADDRESS& with $HOSTNAME$ inside of your PROCESS_SERVICE_CHECK_RESULT command.

So i know that the PROCESS_SERVICE_CHECK_RESULT command is working.

If you really name you hosts by ip addresses Check if passive_checks_enabled is set to 1 for your hosts

mgadi commented 9 years ago

Thank's for the reply i will add passive_checks_enabled is set to 1 for hosts

mgadi commented 9 years ago

Hi

It doesn't work either.

1- I do from naemonbox-server snmptrap -v2c -c public 127.0.0.1 '' .1.3.6.1.6.3.1.1.5.3 ifIndex i 2 ifadminStatus i 1 ifOperStatus i 1

2 - In naemon.log i have this

3 - but it is correct in /var/log/snmptt/snmptt.log

Wed Mar 25 19:22:45 2015 .1.3.6.1.6.3.1.1.5.3 OK "Status Events" naemonbox-standalone.localdomain - Link down on interface 2. Admin state: 1. Operational state: 1

4 - Maybe i do something wrong, but it was working with Naemon 0.8.0 ...

nook24 commented 9 years ago

PROCESS_SERVICE_CHECK_RESULT and PROCESS_HOST_CHECK_RESULT expect the hostname as first parameter. I guess this is naemonbox-standalone.localdomain in your case. But you submit 127.0.0.1 in your command.

mgadi commented 9 years ago

Hi

It doesn't work either.

1 - I install naemon with this https://github.com/mgadi/naemonbox/releases/download/0.0.6-RC1/naemonbox-0.0.6-RC1.tar.gz

2 - then i only upgrade naemon with http://labs.consol.de/naemon/release/v1.0.0/debian7/amd64/

3 - In my case host_name = naemonbox-standalone ($HOSTNAME$ macro); alias is the same for this host ($HOSTALIAS$ macro) and address = 127.0.0.1 (the $HOSTADDRESS$ macro).

4 - I clone this host and change those directives by host_name and alias = naemonbox-standalone-eth0; and address = 192.168.1.12.

5 - I do this command snmptrap -v2c -c public naemonbox-standalone.localdomain '' .1.3.6.1.6.3.1.1.5.3 ifIndex i 2 ifadminStatus i 1 ifOperStatus i 1

result =

6 - I do this command snmptrap -v2c -c public 192.168.1.12 '' .1.3.6.1.6.3.1.1.5.3 ifIndex i 2 ifadminStatus i 1 ifOperStatus i 1

result =

nook24 commented 9 years ago

I tested both commands right now with Naemon Core 1.0.0-source (current master.zip) and both are working on my system. May be your plugin uses NAGIOS_HOSTNAME out of the environment variables and you are a "victim" of issue #100 and your plugin use $HOSTADDRESS$ as fallback. Pass $HOSTNAME$ as parameter to your plugin and make sure that it submit the hostname and not the ip address to naemon.cmd inside of your external command PROCESS_SERVICE_CHECK_RESULT;192.168.1.12;snmptrap-service;2;Link down on interface 2

mgadi commented 9 years ago

1- I change my /etc/hosts file to 127.0.0.1 naemonbox-standalone naemonbox-standalone.localdomain 127.0.1.1 localhost localhost.localdomain ::1 localhost

2 - I change in /etc/snmp/snmptt.conf
$aA (Trap agent IP address) to $A (Trap agent host name)

3 - I will commit a new release of naemonbox https://github.com/mgadi/naemonbox/releases soon ...

THANKS !

oranki commented 9 years ago

I'm seeing the same error as well in my logs, but seemingly randomly. Exactly same input sometimes triggers it, and sometimes it doesn't. Additionally, a few times now (maybe every few days) it has caused NSCA daemon to not exit after fork, effectively resulting in a slow fork bomb.

Investigating.

oranki commented 9 years ago

It seems the Invalid value errors are not related and don't have a negative effect on naemon functionality. NSCA fork-bombing happens when naemon segfaults and NSCA continues accepting passive service check results, but blocks on write on the command file.

The segfault has been traced down to a problematic line in checks.c which returns NULL when a service check output only contains newline(s) (Courtesy of Simen Aasland).

catharsis commented 8 years ago

Note: @ozamosi commited a couple of patches a while back (which are now finally merged) which outputs more comprehensive error messages for external commands. That should make this type of issue easier to troubleshoot in the future.