External Command: Malformed Command

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Re: External Command: Malformed Command

Postby shekharalle » Tue Dec 11, 2018 11:02 pm

And I changed the hostname from localhost to jumphost as of now and have service defined as well.
Do I need to define a command as well.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Wed Dec 12, 2018 1:21 am

Now I am not getting any service not found error and I am able to see it on dashboard but the following error is still there.

Code: Select all
[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Informational Message[12-12-2018 06:13:40] External command error: Malformed command
Passive Service Check[12-12-2018 06:13:40] PASSIVE SERVICE CHECK: jumphost;memory;0;52.05% used
External Command[12-12-2018 06:13:40] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;jumphost;memory;0;52.11% used



What can be the reason for this error as I have service and host definitions as per my host name jumphost.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby npolovenko » Thu Dec 13, 2018 5:20 pm

@shekharalle, Looks like you're using the "passive-service" service check as a template. However, you set the register option to 1 meaning that nagios will try to register it as an actual service. If it's not a template, you need to add the host_name directive to the passive service definition itself. Or if it is a template only, I recommend setting register to 0.
define service{
use generic-service
name passive_service
active_checks_enabled 0
passive_checks_enabled 1 # We want only passive checking
flap_detection_enabled 0
register 1 # This is a template, not a real service
is_volatile 0
check_period 24x7
max_check_attempts 1
normal_check_interval 5
retry_check_interval 1
check_freshness 0
check_command check_dummy!0
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
stalking_options w,c,u
}


Now I am not getting any service not found error and I am able to see it on dashboard

Where are you getting this error? Can you show a screenshot or upload a log file?

On the nagios server please run the following command to verify the configuration and show me the output:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


Informational Message[12-12-2018 06:13:40] External command error: Malformed command

Is this from the nagios log? Can you upload the whole nagios.log file?

Finally, open the /usr/local/nagios/etc/nagios.cfg and make sure that these options are set to 1:
accept_passive_host_checks=1
accept_passive_service_checks=1
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
 
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: External Command: Malformed Command

Postby shekharalle » Fri Dec 21, 2018 1:52 am

@npolovenko So below is my service.config with register set to 0.

define service{
use generic-service
name passive_service
active_checks_enabled 0
passive_checks_enabled 1 # We want only passive checking
flap_detection_enabled 0
register 0 # This is a template, not a real service
is_volatile 0
check_period 24x7
max_check_attempts 1
normal_check_interval 5
retry_check_interval 1
check_freshness 0
check_command check_dummy!0!"Initial OK"
notification_interval 60
notification_period 24x7
notification_options w,u,c,r
stalking_options w,c,u
}


Following is the Nagios log:
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Informational Message[12-21-2018 06:06:44] External command error: Malformed command
Passive Service Check[12-21-2018 06:06:44] PASSIVE SERVICE CHECK: concourse-ubuntu;cpu;0;2.27% user+nice+system
External Command[12-21-2018 06:06:44] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;concourse-ubuntu;cpu;0;0.95% user+nice+system
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Passive Service Check[12-21-2018 06:06:43] PASSIVE SERVICE CHECK: jumphost;cpu;0;27.39% user+nice+system
External Command[12-21-2018 06:06:43] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;jumphost;cpu;0;26.96% user+nice+system
Passive Service Check[12-21-2018 06:06:43] PASSIVE SERVICE CHECK: ubuntu-test;disk /;0;7% used
External Command[12-21-2018 06:06:43] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;ubuntu-test;disk /;0;7% used
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Passive Service Check[12-21-2018 06:06:43] PASSIVE SERVICE CHECK: ubuntu-test;memory;0;15.30% used
External Command[12-21-2018 06:06:43] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;ubuntu-test;memory;0;15.30% used
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Informational Message[12-21-2018 06:06:43] External command error: Malformed command
Passive Service Check[12-21-2018 06:06:43] PASSIVE SERVICE CHECK: ubuntu-test;cpu;0;0.60% user+nice+system
External Command[12-21-2018 06:06:43] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;ubuntu-test;cpu;0;0.00% user+nice+system
Service Critical[12-21-2018 06:06:42] SERVICE ALERT: concourse-ubuntu;memory;CRITICAL;SOFT;1;CRITICAL: Didn't got the response from Passive Check (Please Check)
Informational Message[12-21-2018 06:06:39] External command error: Malformed command


I am still getting the external command:malformed error don't know why.

So after running the command as said by you:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


I am getting the following which shows everything is working:
[cloud-user@jumphost objects]$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.4.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-06-25
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Checked 20 services.
Checked 4 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 25 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 4 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check
[cloud-user@jumphost objects]$


And yes the following error:
Informational Message[12-12-2018 06:13:40] External command error: Malformed command


This error is from Nagios log file.


accept_passive_host_checks=1
accept_passive_service_checks=1

And yes both of these are enabled i.e set to 1
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Wed Dec 26, 2018 1:37 am

So can anyone help with the above problem?
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby ssax » Wed Dec 26, 2018 3:10 pm

Please edit your /usr/local/nagios/etc/nagios.cfg and set:

Code: Select all
log_external_commands=1
debug=-1
debug_level=2


Edit: Edited after posting, for future readers: I had an wrong variable name, use this instead:

Code: Select all
log_external_commands=1
debug_level=-1
debug_verbosity=2


Then restart the nagios service:

Code: Select all
service nagios restart


Then submit the passive result and once you see the passive result name in your /usr/local/nagios/var/nagios.debug file please send us your nagios.log and your nagios.debug files from /usr/local/nagios/var so that we can review what is occurring.

Once you have generated the debug data, change the nagios.cfg debug settings back and then restart the nagios service:

Code: Select all
service nagios restart


Thank you
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4439
Joined: Wed Feb 11, 2015 12:54 pm

Re: External Command: Malformed Command

Postby shekharalle » Wed Dec 26, 2018 11:20 pm

I have set the log_external_commands=1 and debug_level=2 in the nagios.cfg file.
But there is no debug option in the nagios.cfg file and if I try to set debug=-1 it gives me an error.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Thu Dec 27, 2018 10:35 am

Following is the error I get if I set the debug=1:

Code: Select all
sudo systemctl status nagios.service
● nagios.service - Nagios Core 4.4.1
   Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2018-12-27 15:28:51 UTC; 28s ago
     Docs: https://www.nagios.org/documentation
  Process: 4384 ExecStopPost=/usr/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS)
  Process: 4363 ExecStop=/usr/bin/kill -s TERM ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 4387 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=1/FAILURE)
Main PID: 944 (code=exited, status=0/SUCCESS)

Dec 27 15:28:51 jumphost nagios[4387]: Copyright (c) 1999-200...
Dec 27 15:28:51 jumphost nagios[4387]: Last Modified: 2018-06-25
Dec 27 15:28:51 jumphost nagios[4387]: License: GPL
Dec 27 15:28:51 jumphost nagios[4387]: Website: https://www.n...
Dec 27 15:28:51 jumphost nagios[4387]: Reading configuration ...
Dec 27 15:28:51 jumphost nagios[4387]: Error in configuration...
Dec 27 15:28:51 jumphost nagios[4387]: Error processing main ...
Dec 27 15:28:51 jumphost systemd[1]: Failed to start Nagios C...
Dec 27 15:28:51 jumphost systemd[1]: Unit nagios.service ente...
Dec 27 15:28:51 jumphost systemd[1]: nagios.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby ssax » Thu Dec 27, 2018 11:53 am

What is the output of this command:

Code: Select all
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4439
Joined: Wed Feb 11, 2015 12:54 pm

Re: External Command: Malformed Command

Postby shekharalle » Thu Dec 27, 2018 12:25 pm

Earlier it wasn't giving any error but now it is giving this error which looks like a permission:

Code: Select all
sudo /usr/local/nagios/bin/nagios -v /usr/local/etc/nagios.cfg

Nagios Core 4.4.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-06-25
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Error: Cannot open main configuration file '/usr/local/etc/nagios.cfg' for reading!
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

PreviousNext

Return to Community Support

Who is online

Users browsing this forum: Majestic-12 [Bot], Piorin, stefanet and 48 guests