MSV FM

[email protected]: ~ $
Path : /lib/fm-agent/library/
File Upload :
Current < : //lib/fm-agent/library/iperf3.py

import json
import logging
import os
import subprocess
import requests

class Iperf3Runner:
    default_start_url = 'https://speed.fortisase.com/start_iperf'
    cached_start_info = None
    def __init__(self, iperf3_bin, start_url=None):
        if start_url is None:
            start_url = self.default_start_url
        self.start_url = start_url
        self.iperf_bin = iperf3_bin
        stat = os.stat(self.iperf_bin)
        perms = oct(stat.st_mode)[-3:]
        if '744' != perms:
            os.chmod(iperf3_bin, 0o744)
        self.log = logging.getLogger('Agent')

    def _fetch_info(self):
        if self.cached_start_info is not None:
            return self.cached_start_info
        r = requests.get(
            self.start_url,
            timeout=10
        )
        if 200 != r.status_code:
            raise Exception(f'Start_perf failure: {r.status_code}')
        self.cached_start_info = r.json()
        return self.cached_start_info

    def _run_test(self, iperf_args, response_key):
        p = subprocess.run(
            iperf_args,
            shell=True,
            capture_output=True,
            check=True,
            encoding='utf-8'
        )
        response = json.loads(p.stdout)
        bps = response['end']['streams'][0][response_key]['bits_per_second']
        metric_name = 'download speed'
        if response_key == 'sender':
            metric_name = 'upload speed'
        self.log.info('Metric {} args {} -> {} bits/s'.format(
            metric_name,
            iperf_args,
            bps
        ))
        return bps
            
    def get_download_speed(self):
        info = self._fetch_info()
        args = '{} -c {} -p {} -t 10 -R --json'.format(
            self.iperf_bin,
            info['ip'],
            info['upload_port']
        )
        return self._run_test(iperf_args=args, response_key='receiver')

    def get_upload_speed(self):
        info = self._fetch_info()
        args = '{} -c {} -p {} -t 10 --json'.format(
            self.iperf_bin,
            info['ip'],
            info['download_port']
        )
        return self._run_test(iperf_args=args, response_key='sender')


   
Bethany
Bethany
0%

THE FINEST HOTEL NEAR LAKE KIVU

The Perfect Base For You

Required fields are followed by *





EC1A68011

About Us

Delicious Interior With The Pinch Of Everything

Bethany Investment group is Presbyterian church in Rwanda(EPR) company that manage Hotel and Guest house in Karongi (Bethany Hotel), ISANO branch in GIKONDO(Kigali), Kiyovu branch(Kigali), AMIZERO branch(Nyagatare-East) and Gisenyi Branch(Rubavu).

Accomodation

Get a Comfortable Room
Feel The Comfort

Get a comfortable room and feel our hotel’s comfort. Bethany Hotel features a variety of fully furnished rooms with extra space, Executive rooms, Deluxe rooms with a beautiful lake view and garden space, Deluxe rooms, comfort rooms, family rooms and standard rooms at your service.

Standard Single

Services

We Provide Top Class Facility
Especially For You

Beach BBQ Party

Kick back on the beach& and enjoy our berbecue from our masterchef

Breakfast

Kick back at our hotels& enjoy our breakfast from our masterchef

Conference Hall

Kick back at our hotels& enjoy our conference halls from all bethany branches

Enjoy with your partner

Honeymoon Package

80%

Get In Touch

Don’t Miss Any Update

    +

    Search your Room

    Required fields are followed by *