Sunday, February 7, 2016

Getting Bandwidth Data into Home Monitor App version 4.4.2

Super Bowl 50 is in the books and so I decided to update the Home Monitor app to include average bandwidth for your home network.  I got the idea after reading the post about the Comcast customer that was tweeting  their complaints each time their bandwidth fell below certain rate.  I decided to add this feature to the app to help show users their average Download, Upload and Ping rates.

First, I downloaded the scripts necessary to get the speedtest data, found here : https://github.com/sivel/speedtest-cli

Next, I tweaked the python script so that it displayed everything as a Name = Value pair, making it easy to Splunk :

Download=85 Mbps
Upload=60 Mbps
Ping=8ms

speedtest_cli.py

Changed Download: to Download=, Upload: to Upload= and Ping: to Ping=

Once that was done, I created the inputs for both Windows and Linux :

# Bandwidth Input for Linux Machines
[script://$SPLUNK_HOME/etc/apps/homemonitor/bin/speedtest.sh]
disabled = true
interval = 1800.0
sourcetype = bandwidth_test

# Bandwidth Input for Windows Machines
[script://$SPLUNK_HOME\etc\apps\homemonitor\bin\speedtest_cli.py --simple]
disabled = false
interval = 1800.00
source = bandwidth_test
sourcetype = bandwidth_test

Now, all you have to do is go into Settings -> Data Inputs -> Scripts and enable the proper script for your OS.  I would keep it to 15 minutes (1,800 seconds) since you don't want to be running a speedtest on a high frequency which could degrade your networks performance.

Thanks and enjoy,
Kam


4 comments:

  1. I used what you did here and morphed it a little bit into a Twitter alert. I took the serverlist xml file and redid it some to only show hosts that I knew had good bandwidth numbers for me in the past to ensure I was getting the best numbers that I could. Then I rehosted it and pointed the script to that file instead of the default SpeedTest server list. Then I set an alert to let me know when my speed fell below 150mbps (half of what I pay for) and set a Twitter alert action to tag me and my ISP when the speed fell below the threshold. Thank you for the inspiration to do this!

    ReplyDelete
  2. I love this idea and have some ideas for some good dashboards for it if I can get it working :(
    When you say 'Now, all you have to do is go into Settings -> Data Inputs -> Scripts and enable the proper script for your OS. ' I assume that means that i do NOT have to get or edit scripts or python scripts because you've already done it and all we have to do is Enable the Data Input for my OS - which is on a Mac El Capitan, so I'm enabling the Linux machine Bandwidth input. unfortunately this isn't populating the dashboard.....not sure whats wrong here....thanks again for your help. great dashboard

    ReplyDelete
  3. In order to get this working on OSX 10.10.5 I had to edit the speedtest.sh shell file to use the correct path to the speedtest_cli.py python script.

    #!/bin/sh
    python /Applications/splunk/etc/apps/homemonitor/bin/speedtest_cli.py --simple

    ReplyDelete
  4. 1800 seconds is 30 minutes, not 15. :-)

    ReplyDelete