コード例 #1
0
ファイル: worker.py プロジェクト: dmend/meniscus
 def __init__(self, **kwargs):
     if kwargs:
         self.cpu_cores = kwargs['cpu_cores']
         self.os_type = kwargs['os_type']
         self.memory_mb = kwargs['memory_mb']
         self.architecture = kwargs['architecture']
         self.load_average = kwargs['load_average']
         self.disk_usage = kwargs['disk_usage']
     else:
         self.cpu_cores = sys_assist.get_cpu_core_count()
         self.os_type = platform.platform()
         self.memory_mb = sys_assist.get_sys_mem_total_MB()
         self.architecture = platform.machine()
         self.load_average = sys_assist.get_load_average()
         self.disk_usage = sys_assist.get_disk_usage()
コード例 #2
0
 def __init__(self, **kwargs):
     if kwargs:
         self.cpu_cores = kwargs['cpu_cores']
         self.os_type = kwargs['os_type']
         self.memory_mb = kwargs['memory_mb']
         self.architecture = kwargs['architecture']
         self.load_average = kwargs['load_average']
         self.disk_usage = kwargs['disk_usage']
         self.timestamp = kwargs['timestamp']
     else:
         self.cpu_cores = sys_assist.get_cpu_core_count()
         self.os_type = platform.platform()
         self.memory_mb = sys_assist.get_sys_mem_total_MB()
         self.architecture = platform.machine()
         self.load_average = sys_assist.get_load_average()
         self.disk_usage = sys_assist.get_disk_usage()
         self.timestamp = timeutils.utcnow()
コード例 #3
0
ファイル: publish_stats.py プロジェクト: dmend/meniscus
    def _send_stats(self, load_ave_interval, disk_usage_interval):
        """
        send system usage data to the coordinator on specified intervals
        """

        time_lapsed = 0

        while True:
            sleep(load_ave_interval)
            time_lapsed += load_ave_interval

            cache = ConfigCache()
            config = cache.get_config()
            if config:
                token_header = {
                    "WORKER-ID": config.worker_id,
                    "WORKER-TOKEN": config.worker_token
                }

                request_uri = "{0}/worker/{1}/status".format(
                    config.coordinator_uri, config.worker_id)

                req_body = {'load_average': sys_assist.get_load_average()}

                if time_lapsed == disk_usage_interval:
                    time_lapsed = 0
                    req_body.update(
                        {'disk_usage': sys_assist.get_disk_usage()})

                try:
                    http_request(request_uri, token_header,
                                 jsonutils.dumps(req_body),
                                 http_verb='PUT')

                except requests.RequestException:
                    pass

            if self.run_once:
                break
コード例 #4
0
ファイル: worker.py プロジェクト: isabella232/meniscus
 def __init__(self, **kwargs):
     """
     An object can be initialized by passing in a dictionary representation
     of the data as **kwargs.  Otherwise the constructor will retrieve
     system stats from the machine it is executing on.
     """
     if kwargs:
         self.cpu_cores = kwargs['cpu_cores']
         self.os_type = kwargs['os_type']
         self.memory_mb = kwargs['memory_mb']
         self.architecture = kwargs['architecture']
         self.load_average = kwargs['load_average']
         self.disk_usage = kwargs['disk_usage']
         self.timestamp = kwargs['timestamp']
     else:
         self.cpu_cores = sys_assist.get_cpu_core_count()
         self.os_type = platform.platform()
         self.memory_mb = sys_assist.get_sys_mem_total_MB()
         self.architecture = platform.machine()
         self.load_average = sys_assist.get_load_average()
         self.disk_usage = sys_assist.get_disk_usage()
         self.timestamp = str(timeutils.utcnow())
コード例 #5
0
ファイル: worker.py プロジェクト: zinic/meniscus
 def __init__(self, **kwargs):
     """
     An object can be initialized by passing in a dictionary representation
     of the data as **kwargs.  Otherwise the constructor will retrieve
     system stats from the machine it is executing on.
     """
     if kwargs:
         self.cpu_cores = kwargs['cpu_cores']
         self.os_type = kwargs['os_type']
         self.memory_mb = kwargs['memory_mb']
         self.architecture = kwargs['architecture']
         self.load_average = kwargs['load_average']
         self.disk_usage = kwargs['disk_usage']
         self.timestamp = kwargs['timestamp']
     else:
         self.cpu_cores = sys_assist.get_cpu_core_count()
         self.os_type = platform.platform()
         self.memory_mb = sys_assist.get_sys_mem_total_MB()
         self.architecture = platform.machine()
         self.load_average = sys_assist.get_load_average()
         self.disk_usage = sys_assist.get_disk_usage()
         self.timestamp = timeutils.utcnow()
コード例 #6
0
ファイル: sys_assist_test.py プロジェクト: dmend/meniscus
 def test_get_load_avergae(self):
     ave = sys_assist.get_load_average()
     self.assertTrue('1'in ave)
     self.assertTrue('5'in ave)
     self.assertTrue('15'in ave)
コード例 #7
0
ファイル: sys_assist_test.py プロジェクト: thomdixon/meniscus
 def test_get_load_avergae(self):
     ave = sys_assist.get_load_average()
     self.assertTrue('1'in ave)
     self.assertTrue('5'in ave)
     self.assertTrue('15'in ave)