internet speed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
fsodah
Posts: 295
Joined: Thu Sep 12, 2019 1:19 am

internet speed

Post by fsodah »

My internet speed was running ... lately getting

Code: Select all

[root@nagios libexec]# ./check_internet_speed 10 14 19 20
./check_internet_speed: line 61: [: -lt: unary operator expected
./check_internet_speed: line 61: [: -lt: unary operator expected
./check_internet_speed: line 64: [: -lt: unary operator expected
./check_internet_speed: line 64: [: -lt: unary operator expected
OK - TestServer: sp1.wind.it Ping  ms Download  Mbit/s Upload  Mbit/s |Download=;Upload=
  • [root@nagios libexec]# cat check_internet_speed
    #!/bin/bash
    # Uses pyspeedtest or speedtest-cli to test internet speed and format for nagios
    # Felipe Ferreira 08/2016
    # Version 2.0 - allows use of two different tools now

    downw=$1
    downc=$2
    upw=$3
    upc=$4

    ## SOME OF THE SERVERS I USE
    #id="3837" sp1.wind.it:8080 DESC="Rome Italia Wind "
    #id="6512" speedtest.tecnoadsl.it:8080 DESC="Telecom Italia S.p.A. (Perugia, Italy) [23.00 km]"
    #id="5470" speedtestpg1.telecomitalia.it:8080
    #id="9636" speedtestfi1.telecomitalia.it:8080 DESC="Telecom Italia S.p.A. (Florence, Italy) [99.02 km]"
    #id="3676" speedtest-rma.clouditalia.com:8080 DESC="Clouditalia S p A (Rome, Italy) [142.40 km]"
    # There is a FULL list of servers here http://www.speedtest.net/speedtest-servers.php

    #TIP: Too make speedtest-cli work without opening outbound to any I downloaded set to local web folder 2 xml files
    # ://<MYSERVER>/speedtest-servers-static.xml
    # ://centreon/c/speedtest-config.xml
    ###########EDIT HERE##############
    SERVERID=3837
    SERVER="sp1.wind.it"
    TOUT=50 # only for speedtest-cli
    RUNS=8 # only for pyspeedtest


    TMP=".speedtest.$SERVER.$RANDOM"

    if [ -z $4 ]; then
    echo "UNOKNWN - Please pass all 4 paramateres $0 <download_warn> <download_crit> <upload_warn> <upload_crit>"
    exit 3
    fi

    PWD=$(pwd)
    PWD="/usr/lib/nagios/plugins"
    #SCRIPT="${PWD}/speedtest-cli"
    SCRIPT="/usr/bin/speedtest-cli"
    if [ -f $SCRIPT ]; then
    CMD="$SCRIPT --server $SERVERID --timeout $TOUT --simple > $TMP 2>&1"
    elif [[ $(command -v pyspeedtest >/dev/null 2>&1) ]]; then
    SCRIPT="/usr/bin//pyspeedtest"
    CMD="$SCRIPT -s $SERVER -r $RUNS > $TMP 2>&1"
    else
    echo "UNKONW - could not find requirements: speedtest-cli or pyspeedtest "
    echo "Download speedtest-cli https://github.com/sivel/speedtest-cli"
    echo "Download: pyspeedtest https://github.com/fopina/pyspeedtest"
    exit 3
    fi

    #echo $CMD
    R=$(eval $CMD)
    P=$(grep Ping $TMP |awk '{ print $(NF -1) }')
    D=$(grep Download $TMP |awk '{ print $(NF -1)}' |awk -F"." '{print $1}' )
    U=$(grep Upload $TMP |awk '{ print $(NF -1) }' |awk -F"." '{print $1}' )

    MSG="TestServer: $SERVER Ping $P ms Download $D Mbit/s Upload $U Mbit/s |Download=$D;Upload=$U"
    rm -f $TMP

    if [ $D -lt $downc ] || [ $U -lt $upc ]; then
    echo "CRITICAL - $MSG"
    exit 2
    elif [ $D -lt $downw ] || [ $U -lt $upw ]; then
    echo "WARNING - $MSG"
    exit 1
    else
    echo "OK - $MSG"
    exit 0
    fi
    [root@nagios libexec]#
https://github.com/xoroz/nagios_plugins ... rnet_speed
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: internet speed

Post by lmiltchev »

This is NOT one of our official (supported) plugins. I would recommend that you contact the plugin's owner in order to resolve your issue. Having said that, you could try to double quote the variables to see if this is going to help.

Example:

Code: Select all

if [ "$D" -lt "$downc" ] || [ "$U" -lt "$upc" ]; then
	echo "CRITICAL - $MSG"
	exit 2
elif [ "$D" -lt "$downw" ] || [ "$U" -lt "$upw" ]; then
	echo "WARNING - $MSG"
	exit 1
else
	echo "OK - $MSG"
	exit 0
fi
Be sure to check out our Knowledgebase for helpful articles and solutions!
fsodah
Posts: 295
Joined: Thu Sep 12, 2019 1:19 am

Re: internet speed

Post by fsodah »

i did the adjustment .. dint work.... i will check tomorrow ... if i can get around ... keep it open
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: internet speed

Post by lmiltchev »

Noted
Be sure to check out our Knowledgebase for helpful articles and solutions!
fsodah
Posts: 295
Joined: Thu Sep 12, 2019 1:19 am

Re: internet speed

Post by fsodah »

please close it ... went into a deadlock ... I will use another method to measure internet speed
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: internet speed

Post by lmiltchev »

I am closing the topic. If you have any further questions/issues, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked