Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sat Apr 29, 2017 6:24 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Speedtest graph/data template available
PostPosted: Wed Dec 24, 2014 4:01 pm 
Offline

Joined: Wed Dec 24, 2014 2:37 pm
Posts: 7
I had the same problem. First time I didn't have the script created, and the poller error log pointed that out. Putting my speedtest-cli command in /usr/local/share/cacti/scripts/speedtest.sh with appropriate permissions fixed that. I still didn't have data in the graphs. As per a previous post, bumping the script timeout within cacti fixed that and I now have data. I hope that can help someone else.

My bandwidth suffers during prime hours and weekends, but gets the full 100mb during business hours when people are generally at work. This is what drove me to begin this graphing.


Attachments:
graph_image.php.png
graph_image.php.png [ 14.88 KiB | Viewed 2576 times ]
Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Tue Feb 24, 2015 1:12 pm 
Offline

Joined: Sat Apr 16, 2011 4:22 am
Posts: 9
I want to congratulate the author of this great template. Thank you!!!

In CentOS I had to add EPEL repo, install python-pip, install speedtest-cli, put my speedtest-cli command in /usr/local/share/cacti/scripts/speedtest.sh, chmod +x speedtest.sh, install Speedtest templates and in Cacti>Configuration>Settings under Pooler change Script and Script Server Timeout Valuo to 50 seconds.
And thank you all for posting details in this thread.


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Tue Feb 24, 2015 3:02 pm 
Offline

Joined: Sat Apr 16, 2011 4:22 am
Posts: 9
I actually realised that speedtest is bandwidth hog, it downloaded and uploaded 40GB (20GB up, 20 GB down) in last 6 hours.

Can I somehow set the graph not to execute so often?


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Tue Aug 11, 2015 12:06 pm 
Offline

Joined: Thu Aug 20, 2009 6:52 am
Posts: 6
You can use this modified script and specify custom update interval
Code:
#!/bin/bash
RESFILE="/var/tmp/speedtestresults"
INTERVAL=1200

if  ((`stat -c %Y /var/tmp/speedtestresults`+$INTERVAL<$(date +%s))); then
        # get fresh data
        RES=`/usr/local/bin/speedtest-cli --simple | cut -d" " -f1,2 | sed -e 's/ //g'| tr '\n' ' '`
        echo $RES > $RESFILE
else
        # get fake results from last run
        RES=`cat $RESFILE`
fi

echo $RES


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Wed Aug 26, 2015 7:43 am 
Offline

Joined: Wed Aug 26, 2015 6:57 am
Posts: 2
Hi guys,

I'm new to Cacti and require some help with the above script as I'm not receiving any data on my Bandwidth measurement: Speedtest.net graph.
I think my issue exists within "Data Input Methods" - "Input String" for SpeedTest script, but I'm not sure why it's not working and what it needs to be.

The setting are as follows:
Code:
Name: SpeedTest script
Input Type: Script/Command
Input String: /usr/local/share/cacti/scripts/speedtest-cli --simple | cut -d" " -f1,2 | sed -e 's/ //g'| tr '\n' ' '
Intput Fields: <blank>
Output Field: Download, Ping, Upload (pre-set)


Cacti.log Output:
Code:
SYSTEM STATS: Time:64.2104 Method:spine Processes:1 Threads:1 Hosts:9 HostsPerProcess:9 DataSources:6 RRDsProcessed:6
SPINE: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: '/usr/local/share/cacti/scripts/speedtest-cli --simple | cut -d\" \" -f1,2 | sed -e \'s/ //g\'| tr \'\\n\' \' \''


By looking at my log output I can definitely see a difference between what has been set at "Input String" for script and what is being Output by Cacti.

Here is a breakdown of what I have done so far:
    - Downloaded the script from: https://github.com/sivel/speedtest-cli
    - Copied the script to /usr/local/share/cacti/scripts/
    - Made script executable: Chmod 777 speedtest-cli
    - Tested script from command-line and it works (Provides: Ping, Download and Upload data.)
    - Imported both Templates
    - Created the graph for localhost
    - Updated Poller Settings
    "Poller Type" to spine
    "Script and Script Server Timeout Value" to 300
    - Updated Data Input Methods for SpeedTest script
    Input String: /usr/local/share/cacti/scripts/speedtest-cli --simple | cut -d" " -f1,2 | sed -e 's/ //g'| tr '\n' ' '


Any help would be much appreciated.

Thanks in advance,
Ruan


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Wed Sep 09, 2015 4:23 am 
Offline

Joined: Wed Aug 26, 2015 6:57 am
Posts: 2
Ignore my previous response, I got it to work following @ursal suggestion.

Thanks @ursal


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Fri Mar 11, 2016 4:31 pm 
Offline

Joined: Mon Dec 06, 2010 10:09 am
Posts: 19
Just a heads up the speedtest-cli does not provide accurate upload speed results. I have installed it on three separate Ubuntu hosts and all of them give a slow upload result, usually slow by a factor of 10x. I wish there was a fix because this really is a cool tool.

For example:

$ speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from XXX...
Selecting best server based on latency...
Hosted by T-Mobile (Beltsville, MD) [38.30 km]: 6.999 ms
Testing download speed........................................
Download: 366.94 Mbit/s
Testing upload speed..................................................
Upload: 31.62 Mbit/s

Where as in the browser client I get:
Download
477.42Mb/s
Upload
441.65Mb/s


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Mon Aug 01, 2016 8:03 am 
Offline

Joined: Thu Mar 10, 2016 3:26 am
Posts: 4
Hey

i use the .sh script from ursal. But in my graphs there are only "NaN"

rrdtool info says:

Code:
root@raspberrypi:~# rrdtool info /var/lib/cacti/rra/hp_switch_ping_118.rrd
filename = "/var/lib/cacti/rra/hp_switch_ping_118.rrd"
rrd_version = "0003"
step = 600
last_update = 1470056042
header_size = 3672
ds[Ping].index = 0
ds[Ping].type = "GAUGE"
ds[Ping].minimal_heartbeat = 120
ds[Ping].min = 0,0000000000e+00
ds[Ping].max = 1,0000000000e+03
ds[Ping].last_ds = "22.781"
ds[Ping].value = NaN
ds[Ping].unknown_sec = 242
ds[Download].index = 1
ds[Download].type = "GAUGE"
ds[Download].minimal_heartbeat = 120
ds[Download].min = 0,0000000000e+00
ds[Download].max = 1,0000000000e+03
ds[Download].last_ds = "25.49"
ds[Download].value = NaN
ds[Download].unknown_sec = 242
ds[Upload].index = 2
ds[Upload].type = "GAUGE"
ds[Upload].minimal_heartbeat = 120
ds[Upload].min = 0,0000000000e+00
ds[Upload].max = 1,0000000000e+03
ds[Upload].last_ds = "5.21"
ds[Upload].value = NaN
ds[Upload].unknown_sec = 242
rra[0].cf = "AVERAGE"
rra[0].rows = 600
rra[0].cur_row = 121
rra[0].pdp_per_row = 1
rra[0].xff = 0,0000000000e+00
rra[0].cdp_prep[0].value = NaN
rra[0].cdp_prep[0].unknown_datapoints = 0
rra[0].cdp_prep[1].value = NaN
rra[0].cdp_prep[1].unknown_datapoints = 0
rra[0].cdp_prep[2].value = NaN
rra[0].cdp_prep[2].unknown_datapoints = 0


why are my values NaN?

Can somebody help me?


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Fri Jan 13, 2017 5:03 am 
Offline

Joined: Tue Jul 15, 2014 3:39 am
Posts: 33
I need to change the interval that it polls but not sure what to do with this snippet of code.
I am using the speedtest-cli that got installed using pip.
Any help greatly aprreciated.

ursal wrote:
You can use this modified script and specify custom update interval
Code:
#!/bin/bash
RESFILE="/var/tmp/speedtestresults"
INTERVAL=1200

if  ((`stat -c %Y /var/tmp/speedtestresults`+$INTERVAL<$(date +%s))); then
        # get fresh data
        RES=`/usr/local/bin/speedtest-cli --simple | cut -d" " -f1,2 | sed -e 's/ //g'| tr '\n' ' '`
        echo $RES > $RESFILE
else
        # get fake results from last run
        RES=`cat $RESFILE`
fi

echo $RES


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Fri Jan 13, 2017 1:27 pm 
Offline
Cacti User

Joined: Mon Sep 10, 2012 5:54 pm
Posts: 60
The interval is in seconds, so I've reduced my script interval to 300 (5 minutes) to match the cacti poller interval.

The interval in your script is separate from cacti's interval and will effectively cache the last results so cacti will see the same results for 20 minutes (4 polling cycles) the way you currently have it set.


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Mon Jan 16, 2017 6:52 am 
Offline

Joined: Tue Jul 15, 2014 3:39 am
Posts: 33
thank you for your reply smiles but I didn't explain myself properly.

the script I quoted above was from someone else and my question was what do i do with it. I tried replacing my speedtest-cli with it but kept getting errors in the log

SPINE: Poller[0] Host[13] Description[VM Manchester Speedtest Server] ERROR: Empty result [xxx.xxx.xxx.xxx]: '/usr/local/share/cacti/scripts/speedtest.sh/speedtest_cli --simple | cut -d" " -f1,2 | sed -e 's/ //g'| tr '\n' ' ''

below is the speedtest-cli i am using which got created when installing with pip and works fine but the polling time is way too frequent
Code:
#!/usr/bin/python

# -*- coding: utf-8 -*-
import re
import sys

from speedtest import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Thu Jan 19, 2017 10:58 am 
Offline

Joined: Tue Jul 15, 2014 3:39 am
Posts: 33
pilotMsk wrote:
evrenbey wrote:
Thanks for templates.

i just want to ask a question,

if i want to draw different graphs for different speedtest servers for example

graph for Turkey and graph for US for servers how can i do that?



check
speedtest-cli --list
then use server that you want....
/usr/bin/speedtest-cli --simple --server 3682|cut -d" " -f1,2 |sed -e 's/ //g'|tr '\n' ' '


I'm scratching my head trying to understand how to graph more than one speedtest because if I add the above in the data input method input string then that will be used for all subsequent graphs won't it?

Also if anyone could post their speedtest-cli script that has a polling interval in it that would be awesome :)


Top
 Profile  
 
 Post subject: Re: Speedtest graph/data template available
PostPosted: Mon Jan 23, 2017 9:59 pm 
Offline

Joined: Mon Jan 23, 2017 9:45 pm
Posts: 1
I can't quite figure out what is going wrong here for me:

The script works perfectly (formatted output, etc) when I call it directly from the terminal:

****@****:/usr/local/share/cacti/scripts$ ./speedtest.sh
Ping:12.212 Download:148.62 Upload:11.17

But when I check poller-error.log for Cacti I see this error:

/usr/local/share/cacti/scripts/speedtest.sh: line 2: speedtest-cli: command not found


I don't think there should be permission issues (I checked carefully to make sure it wasn't a missing +x or something) ... why is the command not found when calling the script from within Cacti but no issues from the terminal? Everything else seems to configured fine and I assume the graph will work as soon as I sort out why the poller cannot call "speedtest-cli" when executing the script.



For reference, here's the contents of speedtest.sh - I kept it exactly as the examples in this thread until I get it up and running:

#!/bin/bash
speedtest-cli --simple | cut -d" " -f1,2 | sed -e 's/ //g' | tr '\n' ' '



-edit -

I just removed #!/bin/bash and kept speedtest.sh as a single line ... and now I get this error from the poller:

/usr/local/share/cacti/scripts/speedtest.sh: 1: /usr/local/share/cacti/scripts/speedtest.sh: speedtest-cli: Permission denied



So maybe it is permissions? Why would it be different error without #!/bin/bash as the first line of the script? I'm now more confused than when I first posted.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group