Question

speedtest-cli command check -- HELP

  • 2 November 2023
  • 1 reply
  • 77 views

Badge +1

hi everyone i’m facing an issue with my own speedtest_centreon.pl script is executable and runs successfully from the command line, returning the expected output. However, within the Centreon interface, it's not producing the desired result and is resulting in a "process timeout" error.

here is the script:

************************************************************************************************************

#!/usr/bin/perl

use strict;
use warnings;
use Net::SNMP;

my $host = shift || die "Usage: $0 <host> <community> <test_type>\n";
my $community = shift || die "Usage: $0 <host> <community> <test_type>\n";
my $test_type = shift || die "Usage: $0 <host> <community> <test_type>\n";

my $session = Net::SNMP->session(
    -hostname  => $host,
    -community => $community,
);

unless (defined $session) {
    print "UNKNOWN: Failed to initialize SNMP session.\n";
    exit 3;
}


my $oid = '1.3.6.1.2.1.1.1.0';

my $result = $session->get_request(-varbindlist => [$oid]);

if (!defined $result) {
    $session->close;
    print "UNKNOWN: Unable to retrieve SNMP data.\n";
    exit 3;
}

my $system_description = $result->{$oid};


my $output = `speedtest-cli`;

if ($? == -1) {
    $session->close;
    print "UNKNOWN: Failed to execute speedtest command.\n";
    exit 3;
}

my ($ping_latency, $ping_jitter, $download, $upload);

if ($output =~ /Download: ([\d\.]+) Mbit\/s/) {
    $download = $1 * 1e6;
}

if ($output =~ /Upload: ([\d\.]+) Mbit\/s/) {
    $upload = $1 * 1e6;
}

if ($output =~ /Hosted by .*: (\d+\.\d+) ms/) {
    $ping_latency = $1;
}

unless (defined $ping_latency && defined $download && defined $upload) {
    $session->close;
    print "UNKNOWN: Unable to retrieve speedtest data.\n";
    exit 3;
}

print "OK: ping latency: $ping_latency ms, download: $download bits/s, upload: $upload bits/s | 'ping.latency.milliseconds'=$ping_latency ms;;;0; 'internet.bandwidth.download.bitspersecond'=$download;;;0; 'internet.bandwidth.upload.bitspersecond'=$upload;;;0; 'system.description'=$system_description;;;0;\n";

$session->close;
exit 0;
************************************************************************************************************

and this is the command check i’m using:

$CENTREONPLUGINS$/speedtest_centreon.pl $HOSTADDRESS$ $_HOSTSNMPCOMMUNITY$ -T $ARG1$

in the interface the status is “unknown” and the information is “process timeout”, but i have many other command check working fine and almost the same command, i don’t know if should i add something on my script or some config on centreon interface

************************************************************************************************************

and this is the out put of my script using the command line:

d@cent:/usr/lib/centreon/plugins# ./speedtest_centreon.pl 192.168.30.10 server2wls klos
OK: ping latency: 2527.964 ms, download: 2300000 bits/s, upload: 3180000 bits/s | 'ping.latency.milliseconds'=2527.964 ms;;;0; 'internet.bandwidth.download.bitspersecond'=2300000;;;0; 'internet.bandwidth.upload.bitspersecond'=3180000;;;0; 'system.description'=Linux cent 5.10.0-21-amd64 #1 SMP Debian 5.10.231-1 (2023-08-16) x86_64;;;0;
d@cent:/usr/lib/centreon/plugins#

**************************************************************************************************************

 

 


1 reply

Userlevel 4
Badge +13

Can you try to return your results with out the space as it might be causing a new set

🤞🙈

Reply