XavierBerger / RPi-Monitor

Real time monitoring for embedded devices
https://xavierberger.github.io/RPi-Monitor-docs/index.html
GNU General Public License v3.0
1.17k stars 176 forks source link

Configuratyion for speedtest-cli #383

Open Scoperius opened 3 years ago

Scoperius commented 3 years ago

Hi I tried to make a running configuration for speedtest-cli (https://github.com/sivel/speedtest-cli). But without any success. Can you please point me the right way? May proposed conf does not display anything:

dynamic.101.name=Ping dynamic.101.source=/home/pi/speedtest-cli/speedtest.py --simple | grep "Ping: " dynamic.101.regexp=(.*)

web.status.1.content.10.line.2="Internet Ping: " + data.Ping

although /home/pi/speedtest-cli/speedtest.py --simple | grep "Ping: " returns Ping value properly

Thanks for help,

Petr

dirdled commented 3 years ago

Hi Scoperius, I'm not sure if it has to be this way, but I had the best luck when I put just the command for the source, and then did the filtering using the regexp line, so for your config I would try something like

dynamic.101.name=Ping dynamic.101.source=/home/pi/speedtest-cli/speedtest.py --simple dynamic.101.regexp=(Ping:.*) dynamic.101.postprocess=$1

Also there may be a better way to do this, but when I wanted to monitor my internet stats using speedtest-cli and rpimonitor, I built a wrapper for the speedtest command, because it takes so long to run. I think you can also use the interval and timeout values to do it, but I had other reasons why I wanted to use a wrapper. Basically what my wrapper does is checks the age (and existence) of the previous output file, and only runs the speedtest if the file is older than a certain age. Then rpimonitor is able to read that output file as often as it likes without having to worry about a) Creating a lot of extra bandwidth and b) How long the command takes to run.

Like I said there may be better ways to do all of this, but that is what worked for me

sgrayban commented 3 years ago

@dirdled Care to share your wrapper?

dirdled commented 3 years ago

Hi sgrayban,

I can share, but I'm not sure my code is suitable for mass consumption. I tend to do Quick and dirty stuff, with the intention of going back and polishing it if I ever run out of projects and have spare time...So far that hasn't happened

sgrayban commented 3 years ago

@dirdled

Well I was just wondering how you managed to remove the text out of the speedtest results.

Currently I have a cron running every 10 minutes that saves the results to a file which is pulled by the software.

cat /root/speedtest.txt

Ping: 29.792 ms Download: 113.56 Mbit/s Upload: 17.67 Mbit/s

Have you been able to clean that up to only get the numbers?

dirdled commented 3 years ago

The output that I save is just exactly like that, but when RPIMonitor reads the file it runs it though this line

cat $speedTestOut|sed -n "/$dataType/Is/.: (.) .*/\1/p"
Where
$speedTestOut is the name of the output file (it looks like /root/speedtest.txt in your case)
and
$datatype is either ping, download, or upload

sgrayban commented 3 years ago

@dirdled thanks !!!

image

My script has this now....

#!/bin/bash
# file: /root/speedtest.sh

speedtest --simple > /root/speedtest.txt
cat /root/speedtest.txt|sed -n "/ping/Is/.*: \(.*\) .*/\1/p" > /root/ping.txt
cat /root/speedtest.txt|sed -n "/download/Is/.*: \(.*\) .*/\1/p" > /root/download.txt
cat /root/speedtest.txt|sed -n "/upload/Is/.*: \(.*\) .*/\1/p" > /root/upload.txt

Now to get that into the graph stats!!

dirdled commented 3 years ago

@sgrayban Nice... If I can figure out how to to a private message on here, I can share the whole script and also show you what I have for a configuration to use the script...But I'm not sure my fragile ego can handle having people who really know what they're doing critique my code (I guess I'm assuming that you're OK to show because you're asking me questions :) )

sgrayban commented 3 years ago

@dirdled no PM's here. Are you on Facebook?

sgrayban commented 3 years ago

@dirdled and just to tease you more

image

Got the icons working

dirdled commented 3 years ago

@sgrayban Yeah, I'm on facebook (same ID), I don't login often, but I have an account

Here's what mine looks like

image

Looks like they bumped my upload speed, so I should adjust my gauge settings

Ajimaru commented 3 years ago

No worries, poste your script, we are curious.

sgrayban commented 3 years ago

@Ajimaru @dirdled did send it to me and it's a nifty bit of code. I don't know why he doesn't wasn't to share it publicly. Maybe he will reconsider with my praise??

dirdled commented 3 years ago

Ok, Ok, Since it sounds like @sgrayban doesn't think the code is a dumpster fire I'll share... Here are 2 files one is the speedtest Wrapper (in bash), and the other is the config file for Rpi-Monitor. SpeedChk.txt internet.conf.txt

sgrayban commented 3 years ago

image

xgenosis commented 8 months ago

Ok, Ok, Since it sounds like @sgrayban doesn't think the code is a dumpster fire I'll share... Here are 2 files one is the speedtest Wrapper (in bash), and the other is the config file for Rpi-Monitor. SpeedChk.txt internet.conf.txt

So this is pretty old but I'm trrying to get this up and running and i cannot. I have setup both files but does the speedchk need to run on a timer?