[gelöst] speedtest-cli für Speedtest Abfrage über den check_mk_agent installieren

Wie kann man das Konfigurieren?
Post Reply
User avatar
Pablo78
Posts: 175
Joined: June 8th, 2014, 10:27 am
Location: Berlin

[gelöst] speedtest-cli für Speedtest Abfrage über den check_mk_agent installieren

Post by Pablo78 » June 4th, 2019, 8:01 am

Hallo zusammen,

ich würde gerne von meinem Monitoringserver mit check_mk eine Speedtest Abfrage auf dem ipfire Router (IPFire 2.23 (x86_64) - core131 ) ausführen.
Hierfür habe ich 2 Skripts (siehe unten) die ich testen würde aber der Aufruf lokal am Router bringt keine Reaktion.
Mir wurde vom check_mk Support gesagt es müsste speedtest-cli installiert werden und da komme ich nicht weiter.

- von python ist kein Modul auf dem ipfire installiert da ich nicht weis welches drauf muss
- das Setup wie im Link bringt einen Fehler

https://github.com/sivel/speedtest-cli


########## /usr/lib/check_mk_agent/local/1800/speedcheck.sh #############

Code: Select all

#!/bin/bash

if type speedtest-cli > /dev/null 2>&1 ; then
  CSV=$(speedtest-cli --csv)
  IFS=, VALUES=($CSV)
  PING=${VALUES[5]}
  DOWNLOAD=${VALUES[6]}
  UPLOAD=${VALUES[7]}
  SPONSOR=${VALUES[1]}
  SERVER=${VALUES[2]}
  echo "0 SpeedTest rta=$PING|if_out_bps=$UPLOAD|if_in_bps=$DOWNLOAD Connection to $SPONSOR $SERVER 
ping/upload/download: $PING/$UPLOAD/$DOWNLOAD"
fi
###################################################################

zweites Skript
########## /usr/lib/check_mk_agent/local/1800/speedtest.sh #############

Code: Select all

#!/bin/bash

#
# Track WAN connections in Check_MK
#
# (c) 2016 Stefan Heitmüller
#          stefan.heitmueller@gmx.com

# This is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  This file is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# ails.  You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.

# Requirements:
# - https://github.com/sivel/speedtest-cli inside $PATH
# - bc (to calculate MB/s)
#
# Installation:
# Put script inside Check_MK local plugins directory and make it executable.
# Best practice is to use the "Cached local checks" function: 
# https://mathias-kettner.de/checkmk_localchecks.html#Cached%20local%20checks%20(new%20in%20%3Cb%20class=new%3E1.2.3i1%3C/b%3E%20in%20the%20Linux%20agent)
# e.g. inside /usr/lib/check_mk_agent/local/1800/

# Warning/Critical Ranges:

PING_WARN=100 # if more than, in ms
PING_CRIT=500 # if more than, in ms
DOWNLOAD_WARN=25 # if less than, in MB/s
DOWNLOAD_CRIT=10 # if less than, in MB/s
UPLOAD_WARN=3 # if less than, in MB/s
UPLOAD_CRIT=2 # if less than, in MB/s

# Check Output:

# P WAN-PING ping=29.163;100;500 Ping time 29.163ms
# P WAN-UPLOAD upload=7.79;4:999;2:999 Upload speed 7.79Mb/s
# P WAN-DOWNLOAD download=34.73;25:999;10:999 Download speed 34.73Mb/s

if type speedtest-cli > /dev/null 2>&1 ; then
  LOGFILE="$(mktemp "/tmp/speedtest.XXXXXXXX")"
  speedtest-cli --csv > "$LOGFILE"
  CSV=$(cat "$LOGFILE")
  rm -f "$LOGFILE"
  IFS=, VALUES=($CSV)
  PING=${VALUES[5]}
  DOWNLOAD=$( bc -l <<< 'scale=2; '${VALUES[6]}'/1024/1024' )
  UPLOAD=$( bc -l <<< 'scale=2; '${VALUES[7]}'/1024/1024' )

  # Uncomment these 3 lines to get single services (unique perfdata per service), !COMMENT! the single service below
  #echo "P WAN-PING ping=${PING};${PING_WARN};${PING_CRIT} Ping time ${PING}ms"
  #echo "P WAN-UPLOAD upload=${UPLOAD};${UPLOAD_WARN}:999;${UPLOAD_CRIT}:999 Upload speed ${UPLOAD}Mb/s"
  #echo "P WAN-DOWNLOAD download=${DOWNLOAD};${DOWNLOAD_WARN}:999;${DOWNLOAD_CRIT}:999 Download speed ${DOWNLOAD}Mb/s"

  # One service including all perfdata
  echo "P WAN ping=${PING};${PING_WARN};${PING_CRIT}|upload=${UPLOAD};${UPLOAD_WARN}:999;${UPLOAD_CRIT}:999|download=${DOWNLOAD};${DOWNLOAD_WARN}:999;${DOWNLOAD_CRIT}:999 WAN 
ping/upload/download: ${PING}/${UPLOAD}/${DOWNLOAD}"
fi
###################################################################
Last edited by Pablo78 on June 5th, 2019, 8:14 pm, edited 2 times in total.
Mfg Paul

User avatar
Pablo78
Posts: 175
Joined: June 8th, 2014, 10:27 am
Location: Berlin

Re: speedtest-cli installieren für check_mk_agent

Post by Pablo78 » June 5th, 2019, 8:13 pm

Habe nun wieder den Weg gefunden wie ich den Speedtest ausführen kann.
Es fehlte speedtest-cli.

Wie folgt habe ich es installiert.

Code: Select all

cd /tmp

wget https://github.com/sivel/speedtest-cli/archive/master.zip

unzip master.zip

cd speedtest-cli-master/

chmod 755 speedtest.py

mv speedtest.py /usr/local/bin/speedtest-cli
Erfolg bei der Abfrage ;-)
erfolg.png
erfolg.png (3.9 KiB) Viewed 147 times
Mfg Paul

ummeegge
Community Developer
Community Developer
Posts: 4899
Joined: October 9th, 2010, 10:00 am

Re: [gelöst] speedtest-cli für Speedtest Abfrage über den check_mk_agent installieren

Post by ummeegge » June 6th, 2019, 6:34 pm

Kleiner reminder wegen speedtest --> viewtopic.php?f=36&t=18586 ;) .

Grüsse,

UE
Image
Image

Post Reply