(No output returned from plugin)

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
markoz88
Posts: 8
Joined: Wed Jun 26, 2019 7:38 am

(No output returned from plugin)

Post by markoz88 »

Hi everyone,

i got a little issue with a Script that made on PHP, thes cript works fine in te command line but when i put in Nagios i retrieve the message in the descripción: (No output returned from plugin), but the script works perfectly and shows the information that needed, what could be the problem here?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: (No output returned from plugin)

Post by ssax »

Please post your service and command definitions, attach the plugin as well so that we can debug further.

Thank you
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: (No output returned from plugin)

Post by cdienger »

It could be a misconfiguration of the service or command definition. What do those look like? What does the full command look like when you run the script from the command line?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
markoz88
Posts: 8
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Post by markoz88 »

ssax wrote:Please post your service and command definitions, attach the plugin as well so that we can debug further.

Thank you
Command:

define command {
command_name check_springboot
command_line $USER1$/check_springboot.php --url $ARG1$
}

Service:


define service {
use local-service
host_name localhost
service_description Servicios Cobro QR
check_command check_springboot!192.168.2.196:8080/actuator/health
#register 0
}
markoz88
Posts: 8
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Post by markoz88 »

cdienger wrote:It could be a misconfiguration of the service or command definition. What do those look like? What does the full command look like when you run the script from the command line?
The pluggin is designed to Monitoring springboot actuator health services by cURL and get the Json response; that have the status of services.

Code: Select all

#!/usr/bin/php

<?php

define('STATE_OK', 0);
define('STATE_WARNING', 1);
define('STATE_CRITICAL', 2);
define('STATE_UNKNOWN', 3);


$url_aux = getopt(null, ["url:"]);

if ($url_aux == NULL){
    echo "Error no has agregado la URL";
$url = NULL;
exit (STATE_UNKNOWN);
}

$url = $url_aux['url'];

$ch = curl_init($url);

#curl_setopt($ch, CURLOPT_URL, '$url');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Accept: application/json'
));

$result = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

$info = curl_getinfo ($ch);
$code = $info['http_code'];


curl_close($ch);

#$json = json_decode($result, true);
#print_r($json);

echo "\nEstado de Servicios\n";

class JSON {
    public static function prettify($json)
    {
        $array = json_decode($json, true);
        $json = json_encode($array, JSON_PRETTY_PRINT);
        return $json;
    }

}


$jsonString = $result;

echo JSON::prettify($jsonString);


if ( $code !== NULL ) {
        switch($code){
                case 200:
                    $text = "Servicios OK";
                    echo "\n$text\n";
                    exit(STATE_OK);
                case 503:
                    $text = "Servicio DOWN";
                    echo "$text\n";
                    exit(STATE_CRITICAL);
                default:
                    $text = "UKNOWN";
                    echo "$text\n";
                    exit(STATE_UNKNOWN);
                    break;
                }
}

?>
markoz88
Posts: 8
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Post by markoz88 »

This is the view in Nagios Service:


Current Status: OK (for 0d 1h 3m 46s)
Status Information: (No output returned from plugin)

Estado de Servicios
{
"status": "UP",
"components": {
"diskSpace": {
"status": "UP",
"details": {
"total": 499462959104,
"free": 340257636352,
"threshold": 10485760
}
},
"ping": {
"status": "UP"
}
}
}
Servicios OK
maexware-dennis
Posts: 3
Joined: Wed Jun 10, 2020 7:07 am

Re: (No output returned from plugin)

Post by maexware-dennis »

Hello,

I got the exact same issue in my php script. Have you found any solution for it yet?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: (No output returned from plugin)

Post by scottwilkerson »

I haven't dug into your full script, but I see this right at the top

Code: Select all

#!/usr/bin/php

<?php
the blank line is going to give you a blank line of output right at the beginning of the script which is what Nagios will see as the first link of output and CANNOT be blank

I would recommend changing that to

Code: Select all

#!/usr/bin/php
<?php
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
maexware-dennis
Posts: 3
Joined: Wed Jun 10, 2020 7:07 am

Re: (No output returned from plugin)

Post by maexware-dennis »

scottwilkerson wrote:I haven't dug into your full script, but I see this right at the top

Code: Select all

#!/usr/bin/php

<?php
the blank line is going to give you a blank line of output right at the beginning of the script which is what Nagios will see as the first link of output and CANNOT be blank

I would recommend changing that to

Code: Select all

#!/usr/bin/php
<?php

This fixed it for me. Thank you :)
maexware-dennis
Posts: 3
Joined: Wed Jun 10, 2020 7:07 am

Re: (No output returned from plugin)

Post by maexware-dennis »

scottwilkerson wrote:I haven't dug into your full script, but I see this right at the top

Code: Select all

#!/usr/bin/php

<?php
the blank line is going to give you a blank line of output right at the beginning of the script which is what Nagios will see as the first link of output and CANNOT be blank

I would recommend changing that to

Code: Select all

#!/usr/bin/php
<?php
This fixed it for me. Thank you :)
Locked