(No output returned from plugin)

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

(No output returned from plugin)

Postby markoz88 » Tue May 12, 2020 4:25 pm

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?
markoz88
 
Posts: 7
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Postby ssax » Tue May 12, 2020 4:48 pm

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

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

Re: (No output returned from plugin)

Postby cdienger » Tue May 12, 2020 4:53 pm

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.
User avatar
cdienger
Support Tech
 
Posts: 4599
Joined: Tue Feb 07, 2017 11:26 am

Re: (No output returned from plugin)

Postby markoz88 » Tue May 12, 2020 5:15 pm

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: 7
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Postby markoz88 » Tue May 12, 2020 5:19 pm

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: 7
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Postby markoz88 » Tue May 12, 2020 5:22 pm

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
markoz88
 
Posts: 7
Joined: Wed Jun 26, 2019 7:38 am

Re: (No output returned from plugin)

Postby maexware-dennis » Mon Jun 15, 2020 6:16 am

Hello,

I got the exact same issue in my php script. Have you found any solution for it yet?
maexware-dennis
 
Posts: 3
Joined: Wed Jun 10, 2020 7:07 am

Re: (No output returned from plugin)

Postby scottwilkerson » Mon Jul 06, 2020 3:51 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 18982
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: (No output returned from plugin)

Postby maexware-dennis » Fri Jul 17, 2020 9:20 am

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)

Postby maexware-dennis » Fri Jul 17, 2020 9:24 am

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

Next

Return to Community Support

Who is online

Users browsing this forum: No registered users and 26 guests