title: python script to calc internet upload and download and jitter
body: <p>I have a Python script that runs by ping to determine the internet speed every 30 seconds, to see if a user can receive a call over the internet, ping is often not enough to know this so I want more information like download speed and network upload speed and so on.</p>
  <p><strong>How can this happen in Python without having a significant impact on the Internet so that it does not cause a slow internet</strong></p>
  <pre><code>`
  def check_ping(host):
      &quot;&quot;&quot;
      Returns formated min / avg / max / mdev if there is a vaild host
      Return None if host is not vaild
      &quot;&quot;&quot;
  
      # Option for the number of packets as a function of
      param = '-n' if platform.system().lower() == 'windows' else '-c'
  
      # Building the command. Ex: &quot;ping -c 1 $host&quot;
      command = ['ping', param, '3', host]
  
      # ask system to make ping and return output
      ping = subprocess.Popen(command, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
      out, error = ping.communicate()
      matcher = re.compile(
          &quot;(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)&quot;)
      # rtt min/avg/max/mdev =
      ping_list = r&quot;Minimum = (\d+)ms, Maximum = (\d+)ms, Average = (\d+)ms&quot;
  
      try:
          if(not error):
              if(platform.system().lower() == 'windows'):
                  response = re.findall(ping_list, out.decode())[0]
                  return response
              else:
                  response = matcher.search(out.decode()).group().split('/')
                  return response
      except Exception as e:
          logging.error(e)
          return None
  </code></pre>
  <p>`</p>