External Command: Malformed Command

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

External Command: Malformed Command

Postby shekharalle » Mon Dec 10, 2018 4:04 am

Hi I have a RHEL(Red Hat Enterprise Linux) instance in which I have Nagios Core-4.4.1 and NSCA installed and I have Riemann installed and configured which is sending events to NSCA.
But in the logs I see that when Riemann is sending events it is showing me External Command: Command Malformed and also External command failed and it shows an entry of that event in the log.
And do I need to define a service to process the passive check.
Any help would be really appreciated.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby cdienger » Mon Dec 10, 2018 5:52 pm

Do you have info on which command it is trying to run?

The below have info regarding Core external commands:

https://assets.nagios.com/downloads/nag ... mands.html
https://assets.nagios.com/downloads/nag ... ernalcmds/

The first link in particular will have some things to check to make sure external commands are accepted.

A service does need to be configured to properly work with the incoming data. See "Configuring Nagios" in http://nagios.sourceforge.net/download/ ... _Setup.pdf. The errors may be occur if a service isn't configured so you will want to make sure that one is.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
cdienger
Support Tech
 
Posts: 3335
Joined: Tue Feb 07, 2017 11:26 am

Re: External Command: Malformed Command

Postby shekharalle » Mon Dec 10, 2018 10:13 pm

This is what I get:

[12-10-2018 10:54:04] External command error: Command failed
Informational Message[12-10-2018 10:54:04] Error: External command failed -> PROCESS_SERVICE_CHECK_RESULT;jumphost;memory;0;59.49% used
Informational Message[12-10-2018 10:54:04] Warning: Passive check result was received for service 'memory' on host 'jumphost', but the service could not be found!
External Command[12-10-2018 10:54:04] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;jumphost;memory;0;59.49% used
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Mon Dec 10, 2018 11:56 pm

So this is what I am getting in the logs:

Code: Select all
External command error: Command failed
Error: External command failed -> PROCESS_SERVICE_CHECK_RESULT;jumphost;cpu;0;11.75% user+nice+system
Warning: Passive check result was received for service 'cpu' on host 'jumphost, but the service could not be found!
EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;jumphost;cpu;0;11.75% user+nice+system
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby mcapra » Tue Dec 11, 2018 12:06 pm

The Nagios Core daemon tried to find a service with description "cpu" under host "jumphost" and was unable to do so.

For this command to correctly resolve, you would need a service definition that looks something like this:

Code: Select all
define service{
    host_name    jumphost
    service_description    cpu
    ...
    ...
}


And a corresponding "jumphost" host definition. Nagios Core cannot accept check results for objects it does not have configured (third party intervention notwithstanding).

Do you have all of that? If so, can you share the corresponding host and service object definitions?
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3561
Joined: Thu May 05, 2016 3:54 pm

Re: External Command: Malformed Command

Postby shekharalle » Tue Dec 11, 2018 12:10 pm

I am using localhost so Nagios core and NSCA is on the same machine and so the host definition was already there.
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Tue Dec 11, 2018 1:05 pm

This is my localhost.cfg file which was there by default after installing Nagios core:




Code: Select all
[cloud-user@jumphost ~]$ cat /usr/local/nagios/etc/objects/localhost.cfg
###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
#
# NOTE: This config file is intended to serve as an *extremely* simple
#       example of how you can create configuration entries to monitor
#       the local (Linux) machine.
#
###############################################################################



###############################################################################
#
# HOST DEFINITION
#
###############################################################################

# Define a host for the local machine

define host {

    use                     linux-server            ; Name of host template to use
                                                    ; This host definition will inherit all variables that are defined
                                                    ; in (or inherited by) the linux-server host template definition.
    host_name               localhost
    alias                   localhost
    address                 127.0.0.1
}



###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup {

    hostgroup_name          linux-servers           ; The name of the hostgroup
    alias                   Linux Servers           ; Long name of the group
    members                 localhost               ; Comma separated list of hosts that belong to this group
}



###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################

# Define a service to "ping" the local machine

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     PING
    check_command           check_ping!100.0,20%!500.0,60%
}



# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     Root Partition
    check_command           check_local_disk!20%!10%!/
}



# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     Current Users
    check_command           check_local_users!20!50
}



# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 processes.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     Total Processes
    check_command           check_local_procs!250!400!RSZDT
}



# Define a service to check the load on the local machine.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     Current Load
    check_command           check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}



# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     Swap Usage
    check_command           check_local_swap!20%!10%
}



# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     SSH
    check_command           check_ssh
    notifications_enabled   0
}



# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service {

    use                     local-service           ; Name of service template to use
    host_name               localhost
    service_description     HTTP
    check_command           check_http
    notifications_enabled   0
}
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby shekharalle » Tue Dec 11, 2018 1:12 pm

And this is my services.cfg file:

Code: Select all
[cloud-user@jumphost ~]$ cat /usr/local/nagios/etc/objects/services.cfg
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
   }

define service{
       use                                     passive_service
       service_description                     cpu
       host_name                               localhost
   }
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Re: External Command: Malformed Command

Postby cdienger » Tue Dec 11, 2018 5:03 pm

I'm not familiar with Riemann or configuring it, but if it is sending the command:

PROCESS_SERVICE_CHECK_RESULT;jumphost;cpu;0;11.75% user+nice+system

then a host and sevice will need to be configured as @mcapra pointed out OR Riemann would need to be configured to send data like:

PROCESS_SERVICE_CHECK_RESULT;localhost;cpu;0;11.75% user+nice+system
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
cdienger
Support Tech
 
Posts: 3335
Joined: Tue Feb 07, 2017 11:26 am

Re: External Command: Malformed Command

Postby shekharalle » Tue Dec 11, 2018 9:05 pm

It is giving output with FQDN and I'm doing this on the same machine so host and service definitions are already configured/defined.
So do I need to create another host definition jumphost.cfg and service definition for this FQDN?
Also do I need to add a command in commands.cfg for it as it is not an active check?
shekharalle
 
Posts: 22
Joined: Mon Dec 10, 2018 3:52 am

Next

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 10 guests