Vim�UnDo��H)U
�Hoۡ����(y�wi[A�ɢA#            logger.warn(5555^q6�_�<����V].@�1P                "docker health check reported unhealthy, " "restarting services"5�_�8����V].@�1import subprocessimport shlex from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class DockerHealthChecker:;    def __init__(self, docker, docker_compose, remedy_cmd):        self.docker = docker,        self.docker_compose = docker_compose$        self.remedy_cmd = remedy_cmd    def check(self):        if self._is_healthy():@            logger.debug("docker health check reported healthy")
        else:            logger.error(M                "docker health check reported unhealthy, restarting services"
            )H            DockerHealthChecker._restart_minary_compose(self.remedy_cmd)    def _is_healthy(self):J        running_containers = self.docker.get_names_of_running_containers()>        services = self.docker_compose.get_names_of_services():        healthy = len(running_containers) == len(services)        if not healthy:            logger.warn(3                "some containers are not running, "/                "running containers={}".format(V                    DockerHealthChecker._diff_containers(running_containers, services)                )
            )        logger.debug(T            "running_containers={} services={}".format(running_containers, services)	        )        return healthy    @staticmethod)    def _restart_minary_compose(command):,        subprocess.run(shlex.split(command))    @staticmethod7    def _diff_containers(running_containers, services):        running_containers = [F            s.replace("satoshi_", "")[:-2] for s in running_containers	        ]<        return list(set(services) - set(running_containers))5�_�	����V].C%�
/class DockerHealthChecker:5�_�	����V].C/�
/class DockerHealthChecker():5�_�����V].C��/5�_�����V].C��	1�	05�_�	����V].C��	1from health_check import Bas[]�
15�_�	)����V].C��0import subprocessimport shlex from utils import CoinmineLogger!logger = CoinmineLogger(__name__)*from health_check import BaseHealthChecker-class DockerHealthChecker(BaseHealthChecker):;    def __init__(self, docker, docker_compose, remedy_cmd):        self.docker = docker,        self.docker_compose = docker_compose$        self.remedy_cmd = remedy_cmd    def check(self):        if self._is_healthy():@            logger.debug("docker health check reported healthy")
        else:W            logger.error("docker health check reported unhealthy, restarting services")H            DockerHealthChecker._restart_minary_compose(self.remedy_cmd)    def _is_healthy(self):J        running_containers = self.docker.get_names_of_running_containers()>        services = self.docker_compose.get_names_of_services():        healthy = len(running_containers) == len(services)        if not healthy:            logger.warn(3                "some containers are not running, "/                "running containers={}".format(V                    DockerHealthChecker._diff_containers(running_containers, services)                )
            )        logger.debug(T            "running_containers={} services={}".format(running_containers, services)	        )        return healthy    @staticmethod)    def _restart_minary_compose(command):,        subprocess.run(shlex.split(command))    @staticmethod7    def _diff_containers(running_containers, services):        running_containers = [F            s.replace("satoshi_", "")[:-2] for s in running_containers	        ]<        return list(set(services) - set(running_containers))5�_�
	����V].C��	1*from health_check import BaseHealthChecker5�_�	
����V].C��    def check(self):        if self._is_healthy():@            logger.debug("docker health check reported healthy")
        else:W            logger.error("docker health check reported unhealthy, restarting services")H            DockerHealthChecker._restart_minary_compose(self.remedy_cmd)5�_�
"����"$V].D�!"    @staticmethod)    def _restart_minary_compose(command):,        subprocess.run(shlex.split(command))5�_�
"����""V].D�(import subprocessimport shlex from utils import CoinmineLogger!logger = CoinmineLogger(__name__),from health_monitor import BaseHealthChecker-class DockerHealthChecker(BaseHealthChecker):;    def __init__(self, docker, docker_compose, remedy_cmd):        self.docker = docker,        self.docker_compose = docker_compose$        self.remedy_cmd = remedy_cmd    def _is_healthy(self):J        running_containers = self.docker.get_names_of_running_containers()>        services = self.docker_compose.get_names_of_services():        healthy = len(running_containers) == len(services)        if not healthy:            logger.warn(3                "some containers are not running, "/                "running containers={}".format(V                    DockerHealthChecker._diff_containers(running_containers, services)                )
            )        logger.debug(T            "running_containers={} services={}".format(running_containers, services)	        )        return healthy    @staticmethod7    def _diff_containers(running_containers, services):        running_containers = [F            s.replace("satoshi_", "")[:-2] for s in running_containers	        ]<        return list(set(services) - set(running_containers))5�_�
����V].D	�import subprocessimport shlex5�_�
����V].D�,from health_monitor import BaseHealthChecker5�_�����V].D
�#�#5�_�����V].D�5�_�����V].D�5�_�����V].DR�
"$        self.remedy_cmd = remedy_cmd5�_�'����V].DU�
"(        self.remedy_command = remedy_cmd5�_�9����V].DZ�	";    def __init__(self, docker, docker_compose, remedy_cmd):5�_�����]�k�	�#        �"5�_�&����&]�m�
�$        �#5�_�����&]�n/�$)        services.pop("bootup_controller")5�_�����&]�n�!%    �$5�_� ����&]�n��!'3    def _remove_oneshot(services, oneshot_services)5�_� @����&]�n��!'@    def _remove_oneshot(long_running_services, oneshot_services)5�_� @����&]�n�� "(        � "'5�_�!'����&]�n��!#)            �!#(5�_�����&]�n��*        �)5�_�
����&]�n��*
        self.5�_� ����&+V9]�n��        print(services),        services.remove("bootup_controller")5�_�! ����&!V]�p��    @staticmethodA    def _remove_oneshot(long_running_services, oneshot_services):(        for service in oneshot_services:1            long_running_services.remove(service)5�_� "!'����&V]�qE�#=        self._remove_oneshot(services, ["bootup_controller"])5�_�!$"����&V]�qQ
�(        self._remove_oneshot(services, )5�_�"%#$<����&V]�q��">        services = self.docker_compose.get_names_of_services()�"5�_�$&%
+����&V]�v�
#        �
"5�_�%'&.����&V]�v�	#?    def __init__(self, docker, docker_compose, remedy_command):5�_�&('����&V]�v"�
#.        self.oneshot_servies = oneshot_servies5�_�')(-����&V]�v%�
#/        self.oneshot_services = oneshot_servies5�_�(*)=����&V]�v*�#S        services = self.docker_compose.get_names_of_services(["bootup_controller"])5�_�)+*=����&V]�v*�#>        services = self.docker_compose.get_names_of_services()5�_�*,+����&V]�v8�
#    def _is_healthy(self):5�_�+2,B����&V]�v=�#S        services = self.docker_compose.get_names_of_services(self.oneshot_services)5�_�,3-2����&V]�v��
Пример #2
0
Vim�UnDo�L��ϸ�x�/�6
��ub\������5���?1                logger.error("{} e={}".format(e));.'''']/h�_�����]/`���5�_�����]/`��5�_�����]/`��4from coinmine.worker.utils import make_error_message5�_�����]/`��]�]5�_�����]/`��^�^5�_�����]/`��import logging5�_�����]/`��1logger = logging.getLogger("worker.grinmint.api")5�_�	����]/`��]import requests;from requests.exceptions import RequestException, HTTPError from utils import CoinmineLogger!logger = CoinmineLogger(__name__)def user_stats(username):    return UserStatsGateway(X        Connection.get("https://api.grinmint.com/v1/user/{}/userStats".format(username))    )#def worker_stats(username, worker):    return WorkerStatsGateway(        Connection.get(O            "https://api.grinmint.com/v1/user/{}/worker/{}/workerStats".format(                 username, worker
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError:E            logger.warning("FAILURE {}".format(make_error_message()))         except RequestException:O            logger.error("FAILURE {} url={}".format(make_error_message(), url))        return responseclass Gateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data class UserStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                balance = (V                    float(self.data["unpaid_balance"] + self.data["immature_balance"])                     / 1000000000                )K                return {"amount_mined": balance, "unpaid_balance": balance}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}"class WorkerStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                return {K                    "accepted_shares": self.data["worker"]["valid_shares"],(                    "rejected_shares": (=                        self.data["worker"]["invalid_shares"]=                        + self.data["worker"]["stale_shares"]                    ),                }"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}5�_�
	 ����]/`��!]        except HTTPError:5�_�	
!/����]/`�� "]E            logger.warning("FAILURE {}".format(make_error_message()))5�_�
!0����]/`�� "]2            logger.warning("FAILURE {}".format()))5�_�
!2����]/`�� "]2            logger.warning("FAILURE {}".format(e))5�_�
!1����]/`�� "]1            logger.warning("FAILURE {}".format(e)5�_�
$4����]/`��#%]O            logger.error("FAILURE {} url={}".format(make_error_message(), url))5�_�$6����]/`��#%]<            logger.error("FAILURE {} url={}".format(), url))5�_�$5����]/`��#%];            logger.error("FAILURE {} url={}".format(e url))5�_�#����]/`��"$]         except RequestException:5�_�E.����]/`��DF]G                logger.error("{} e={}".format(make_error_message(), e))5�_�E1����]/`��DF]4                logger.error("{} e={}".format(), e))5�_�E/����]/`��DF]2                logger.error("{} e={}".format()e))5�_�Y.����]/`��XZ]G                logger.error("{} e={}".format(make_error_message(), e))5�_�Y1����]/`��XZ]4                logger.error("{} e={}".format(), e))5�_�	����
	V]/a��	def user_stats(username):    return UserStatsGateway(X        Connection.get("https://api.grinmint.com/v1/user/{}/userStats".format(username))    )5�_�	����		V]/a��Ximport requests;from requests.exceptions import RequestException, HTTPError from utils import CoinmineLogger!logger = CoinmineLogger(__name__)#def worker_stats(username, worker):    return WorkerStatsGateway(        Connection.get(O            "https://api.grinmint.com/v1/user/{}/worker/{}/workerStats".format(                 username, worker
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError as e:2            logger.warning("FAILURE {}".format(e))%        except RequestException as e:<            logger.error("FAILURE {} url={}".format(e, url))        return responseclass Gateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data class UserStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                balance = (V                    float(self.data["unpaid_balance"] + self.data["immature_balance"])                     / 1000000000                )K                return {"amount_mined": balance, "unpaid_balance": balance}"            except Exception as e:1                logger.error("{} e={}".format(e))                return {}
        else:            return {}"class WorkerStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                return {K                    "accepted_shares": self.data["worker"]["valid_shares"],(                    "rejected_shares": (=                        self.data["worker"]["invalid_shares"]=                        + self.data["worker"]["stale_shares"]                    ),                }"            except Exception as e:1                logger.error("{} e={}".format(e))                return {}
        else:            return {}5�_�4����C4V]/a��34 class UserStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                balance = (V                    float(self.data["unpaid_balance"] + self.data["immature_balance"])                     / 1000000000                )K                return {"amount_mined": balance, "unpaid_balance": balance}"            except Exception as e:1                logger.error("{} e={}".format(e))                return {}
        else:            return {}5�_�4����44V]/a��Gimport requests;from requests.exceptions import RequestException, HTTPError from utils import CoinmineLogger!logger = CoinmineLogger(__name__)#def worker_stats(username, worker):    return WorkerStatsGateway(        Connection.get(O            "https://api.grinmint.com/v1/user/{}/worker/{}/workerStats".format(                 username, worker
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError as e:2            logger.warning("FAILURE {}".format(e))%        except RequestException as e:<            logger.error("FAILURE {} url={}".format(e, url))        return responseclass Gateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data"class WorkerStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                return {K                    "accepted_shares": self.data["worker"]["valid_shares"],(                    "rejected_shares": (=                        self.data["worker"]["invalid_shares"]=                        + self.data["worker"]["stale_shares"]                    ),                }"            except Exception as e:1                logger.error("{} e={}".format(e))                return {}
        else:            return {}5�_�9����V]/a��8:EK                    "accepted_shares": self.data["worker"]["valid_shares"],5�_�9/����V]/a��8:Ee                    "current_secondary_hashrateaccepted_shares": self.data["worker"]["valid_shares"],5�_�:����:'</V/]/a�	�9:(                    "rejected_shares": (=                        self.data["worker"]["invalid_shares"]=                        + self.data["worker"]["stale_shares"]5�_�9'����:':/V/]/a��8:BV                    "current_secondary_hashrate": self.data["worker"]["valid_shares"],5�_� 9����:':/V/]/a��8:BF                    "cuhashrate": self.data["worker"]["valid_shares"],5�_�! 95����:':/V/]/a��8:BD                    "hashrate": self.data["worker"]["valid_shares"],5�_� "!9O����:':/V/]/a�
�8:B^                    "hashrate": self.data["worker"]["current_secondary_hashratevalid_shares"],5�_�!#":����:':/V/]/a��9:                    ),5�_�"$#9R����:':/V/]/a��8:AR                    "hashrate": self.data["worker"]["current_secondary_hashrate"],5�_�#%$9P����:':/V/]/a��Aimport requests;from requests.exceptions import RequestException, HTTPError from utils import CoinmineLogger!logger = CoinmineLogger(__name__)#def worker_stats(username, worker):    return WorkerStatsGateway(        Connection.get(O            "https://api.grinmint.com/v1/user/{}/worker/{}/workerStats".format(                 username, worker
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError as e:2            logger.warning("FAILURE {}".format(e))%        except RequestException as e:<            logger.error("FAILURE {} url={}".format(e, url))        return responseclass Gateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data"class WorkerStatsGateway(Gateway):    def to_dict(self):!        if self.status() is True:            try:                return {Q                    "hashrate": self.data["worker"]["current_secondary_hashrate"]                }"            except Exception as e:1                logger.error("{} e={}".format(e))                return {}
        else:            return {}5�_�$&%����'/V/]/c��?    )5�_�%'&;.����'/V/]/h��:<?1                logger.error("{} e={}".format(e))5�_�&';.����'/V/]/h��:<?3                logger.error("{} e={}".format(, e))5��
Пример #3
0
Vim�UnDo��a�K�*���߸��UV��W�1��5q�7class RedisPubSub(PubSub):	]��
_�
����]�M�57from coinmine.pubsub.services.pubsub_base import PubSub5�_�
����]�Q�56from coinmin.pubsub.services.pubsub_base import PubSub5�_�����]�X�54from minarypubsub.services.pubsub_base import PubSub5�_�����]�\�5;from minary.pubsubpubsub.services.pubsub_base import PubSub5�_� ����]�a�5 from minary.pubsub import PubSub5�_�	����]�j�
5class RedisPubSub(PubSub):5�_�	����]�"�55�_�
	����]�'�6�65�_�	
����]�(�$logger = logging.getLogger(__name__)5�_�
����]�*�import logging5�_�
����]�-�5�55�_�
����]����76�	65�_�
7����7dV]����67.class RedisPubSub(PubSubBase):    def initialize(self):        try:C            self.redis = self.connection = redis.from_url(self.url)K            self.pubsub = self.redis.pubsub(ignore_subscribe_messages=True)0        except redis.exceptions.ConnectionError:A            logger.error("Could not connect to Redis for pubsub")        return self+    def publish(self, channel_id, message):        try:I            self.redis.publish(self.key(channel_id), json.dumps(message))        except Exception as e:            logger.error(P                "Could not publish to pubsub uuid={} e={}".format(channel_id, e)
            )$    def subscribe(self, channel_id):&        channel = self.key(channel_id)        if "*" in channel:            try:<                self.pubsub.psubscribe(self.key(channel_id))"            except Exception as e:                logger.error(L                    "Could not psubscribe to pubsub pattern={} e={}".format(%                        channel_id, e                    )                )
        else:            try:.                self.pubsub.subscribe(channel)"            except Exception as e:                logger.error(V                    "Could not subscribe to pubsub uuid={} e={}".format(channel_id, e)                )    def get_message(self):        message = None        try:/            message = self.pubsub.get_message():            if message["type"] in ["message", "pmessage"]:2                return json.loads(message["data"])        except TypeError:            pass        return message5�_�6����77V]����6import jsonimport redis.from minary.pubsub import PubSub as PubSubBase from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class RedisPubSub(PubSub):    def configure(self):        try:C            self.redis = self.connection = redis.from_url(self.url)K            self.pubsub = self.redis.pubsub(ignore_subscribe_messages=True)0        except redis.exceptions.ConnectionError:A            logger.error("Could not connect to Redis for pubsub")    def publish(self, message):        try:?            self.redis.publish(self.key(), json.dumps(message))        except Exception as e:            logger.error(U                "Could not publish to pubsub uuid={} e={}".format(self.channel_id, e)
            )    def subscribe(self):        channel = self.key()        if "*" in channel:            try:/                self.pubsub.psubscribe(channel)"            except Exception as e:                logger.error(L                    "Could not psubscribe to pubsub pattern={} e={}".format(*                        self.channel_id, e                    )                )
        else:            try:.                self.pubsub.subscribe(channel)"            except Exception as e:                logger.error(H                    "Could not subscribe to pubsub uuid={} e={}".format(*                        self.channel_id, e                    )                )    def get_message(self):        message = None        try:/            message = self.pubsub.get_message():            if message["type"] in ["message", "pmessage"]:2                return json.loads(message["data"])        except TypeError:            pass        return message5�_�����88V]����5�_�	����77V]��
�
6class RedisPubSub(PubSub):5�_�	����77V]���6import jsonimport redis.from minary.pubsub import PubSub as PubSubBase from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class RedisPubSub(PubSubBase):    def configure(self):        try:C            self.redis = self.connection = redis.from_url(self.url)K            self.pubsub = self.redis.pubsub(ignore_subscribe_messages=True)0        except redis.exceptions.ConnectionError:A            logger.error("Could not connect to Redis for pubsub")    def publish(self, message):        try:?            self.redis.publish(self.key(), json.dumps(message))        except Exception as e:            logger.error(U                "Could not publish to pubsub uuid={} e={}".format(self.channel_id, e)
            )    def subscribe(self):        channel = self.key()        if "*" in channel:            try:/                self.pubsub.psubscribe(channel)"            except Exception as e:                logger.error(L                    "Could not psubscribe to pubsub pattern={} e={}".format(*                        self.channel_id, e                    )                )
        else:            try:.                self.pubsub.subscribe(channel)"            except Exception as e:                logger.error(H                    "Could not subscribe to pubsub uuid={} e={}".format(*                        self.channel_id, e                    )                )    def get_message(self):        message = None        try:/            message = self.pubsub.get_message():            if message["type"] in ["message", "pmessage"]:2                return json.loads(message["data"])        except TypeError:            pass        return message5�_�	����]�i�
5(class RedisPubSub(PubSub): as PubSubBase5��
Пример #4
0
Vim�UnDo��	����|6�d!�+}�0�6��v^����<ͿB            logger.error("could not connect to redis", connection)7    \���
_�0����\����2                "successfully connected to redis "5�_�0����\����0                "successfully connected to redis5�_�0����\����1                "successfully connected to redis">                "host={} port={}".format(self.host, self.port)5�_�1����\����`                "successfully connected to redis" "host={} port={}".format(self.host, self.port)5�_�2����\����G                "successfully connected to redis"(self.host, self.port)5�_�	F����\����Q                "successfully connected to redis", {"host": self.host, self.port)5�_�	M����\����X                "successfully connected to redis", {"host": self.host, "port" self.port)5�_�	
X����\����Y                "successfully connected to redis", {"host": self.host, "port": self.port)5�_�
Y����\����Z                "successfully connected to redis", {"host": self.host, "port": self.port})5�_�
X����\����import redis from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class MinaryRedis:#    def __init__(self, host, port):        self.host = host        self.port = port    def init_redis(self):        try:S            self.r = redis.StrictRedis(self.host, self.port, decode_responses=True)            logger.info(Y                "successfully connected to redis", {"host": self.host, "port": self.port}
            )            return self.r        except Exception as e:            logger.error(-                "could not connect to redis "?                "host={} port={} ".format(self.host, self.port)
            )            raise e5�_�
,����\�����5�_�+����\����-                "could not connect to redis "5�_�,����\����,                "could not connect to redis"5�_�����\����?                "host={} port={} ".format(self.host, self.port)5�_�����\����import redis from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class MinaryRedis:#    def __init__(self, host, port):        self.host = host        self.port = port    def init_redis(self):        try:S            self.r = redis.StrictRedis(self.host, self.port, decode_responses=True)            logger.info(2                "successfully connected to redis",7                {"host": self.host, "port": self.port},
            )            return self.r        except Exception as e:            logger.error(-                "could not connect to redis",7                {"host": self.host, "port": self.port},
            )            raise e5�_�����\����
        �
5�_�����\����
        self.connection =�
5�_�@����\����
@        self.connection ={"host": self.host, "port": self.port},5�_�����\����
?        self.connection ={"host": self.host, "port": self.port}5�_�����\����7                {"host": self.host, "port": self.port},5�_�2����\����2                "successfully connected to redis",5�_�A����\����import redis from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class MinaryRedis:#    def __init__(self, host, port):        self.host = host        self.port = port@        self.connection = {"host": self.host, "port": self.port}    def init_redis(self):        try:S            self.r = redis.StrictRedis(self.host, self.port, decode_responses=True)            logger.info(B                "successfully connected to redis", self.connection
            )            return self.r        except Exception as e:            logger.error(T                "could not connect to redis", {"host": self.host, "port": self.port}
            )            raise e5�_�.����\����T                "could not connect to redis", {"host": self.host, "port": self.port}5�_�.����\����.                "could not connect to redis", 5�_�7����\����import redis from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class MinaryRedis:#    def __init__(self, host, port):        self.host = host        self.port = port@        self.connection = {"host": self.host, "port": self.port}    def init_redis(self):        try:S            self.r = redis.StrictRedis(self.host, self.port, decode_responses=True)K            logger.info("successfully connected to redis", self.connection)            return self.r        except Exception as e:            logger.error(8                "could not connect to redis", connection
            )            raise e5�_� 7����\���	�B            logger.error("could not connect to redis", connection)5�_� 7����\���
�G            logger.error("could not connect to redis", self.connection)5�_�����\����                5�_�����\����5�_�	
Y����\����Z                "successfully connected to redis", {"host": self.host, "port": self.port)}5�_�1����\����1                "successfully connected to redis"5�_�1����\����3                "successfully connected to redis", 5��
Vim�UnDoεjUυΈ'†©`a€+
Ν_eG�uΛ―Ω'¶σΜ	>ώάUGD            logger.error("could not run amdmeminfo! e={}".format(e))++++^‚{ξ_Π.����]Mά�υ-.<<<<<<< HEAD5�_Π.(����]Mά§υ-/E>        amd_types = ["RX 580", "RX 570", "Vega 56", "Vega 64"]5�_Π19����]Mά�υ02E;        amd_types = ["RX 580", "Coinmine RX 580", "RX 570"]υ12E5�_Π1:����]Mά­υ02EP        amd_types = ["RX 580", "Coinmine RX 580", "RX 570" "Vega 56", "Vega 64"]5�_Π.����.(/V:]Mά±υ-.)        amd_types = ["RX 580", "RX 570",]=======5�_Π0����.(.V:]Mάµυ/00>>>>>>> 430daa9af71a140786e15634a6d3ecfb507628c45�_Π/P����]–Xiυ.0BQ        amd_types = ["RX 580", "Coinmine RX 580", "RX 570", "Vega 56", "Vega 64"]5�_Π	/\����]–XvυB	import reimport shleximport subprocess from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class AmdMemInfo:(    def __init__(self, amdmeminfo_path):.        self.amdmeminfo_path = amdmeminfo_path    def get_all_gpu_info(self):        all_gpu_info = []        try:1            amdmeminfo = subprocess.check_output(G                shlex.split("{} --opencl".format(self.amdmeminfo_path))            ).decode("utf-8")T            split_info = amdmeminfo.split("-----------------------------------")[1:]            adapter_num = 0#            for line in split_info:9                gpu_info = AmdMemInfo._get_gpu_info(line)                if gpu_info:                     logger.info(F                        "AMD GPU found adapter_num={} type={}".format(1                            adapter_num, gpu_info                        )                    )1                    all_gpu_info.append(gpu_info)        except Exception as e:D            logger.error("could not run amdmeminfo! e={}".format(e))        if not all_gpu_info:-            logger.error("No AMD GPUs found")        return all_gpu_info    def get_num_of_gpus(self):+        return len(self.get_all_gpu_info())
    # helpers    @staticmethod"    def _get_gpu_info(amdmeminfo):        gpu_info = {},        # least specific to more specific ->_        amd_types = ["RX 580", "Coinmine RX 580", "RX 570", "Vega 56", "Vega 64", "Radeon VII"]?        memory_types = ["Hynix", "Samsung", "Micron", "Elpida"]        for gpu in amd_types:8            if re.search(gpu, amdmeminfo, re.MULTILINE):'                gpu_info["model"] = gpu         for gpu in memory_types:8            if re.search(gpu, amdmeminfo, re.MULTILINE):-                gpu_info["memory_type"] = gpu/        gpu_info["memory_serial"] = re.findall(7            r"Memory Model.*", amdmeminfo, re.MULTILINE        )[0].split()[-1]W        gpu_info["adapter_num"] = re.findall(r"OpenCL ID.*", amdmeminfo, re.MULTILINE)[
            0        ].split()[-1].        gpu_info["bios_version"] = re.findall(7            r"BIOS Version.*", amdmeminfo, re.MULTILINE        )[0].split()[-1]        return gpu_info5�_Π
	5����]³φtυ57Iυ56I5�_Π	
6
����]³φvυ57J            "Radeon VII",5�_Π
6
����]³φ|υ57J            "",5�_Π
6
����]³φ�υ57J            "5700 XT",5�_Π
6����]³ωκυ68K            υ68J5�_Π
7����]³ωμυK	import reimport shleximport subprocess from utils import CoinmineLogger!logger = CoinmineLogger(__name__)class AmdMemInfo:(    def __init__(self, amdmeminfo_path):.        self.amdmeminfo_path = amdmeminfo_path    def get_all_gpu_info(self):        all_gpu_info = []        try:1            amdmeminfo = subprocess.check_output(G                shlex.split("{} --opencl".format(self.amdmeminfo_path))            ).decode("utf-8")T            split_info = amdmeminfo.split("-----------------------------------")[1:]            adapter_num = 0#            for line in split_info:9                gpu_info = AmdMemInfo._get_gpu_info(line)                if gpu_info:                     logger.info(F                        "AMD GPU found adapter_num={} type={}".format(1                            adapter_num, gpu_info                        )                    )1                    all_gpu_info.append(gpu_info)        except Exception as e:D            logger.error("could not run amdmeminfo! e={}".format(e))        if not all_gpu_info:-            logger.error("No AMD GPUs found")        return all_gpu_info    def get_num_of_gpus(self):+        return len(self.get_all_gpu_info())
    # helpers    @staticmethod"    def _get_gpu_info(amdmeminfo):        gpu_info = {},        # least specific to more specific ->        amd_types = [            "RX 580",            "Coinmine RX 580",            "RX 570",            "Vega 56",            "Vega 64",            "Radeon VII",            "RX 5700 XT",            "Radeon Rx 5700 XT"	        ]?        memory_types = ["Hynix", "Samsung", "Micron", "Elpida"]        for gpu in amd_types:8            if re.search(gpu, amdmeminfo, re.MULTILINE):'                gpu_info["model"] = gpu         for gpu in memory_types:8            if re.search(gpu, amdmeminfo, re.MULTILINE):-                gpu_info["memory_type"] = gpu/        gpu_info["memory_serial"] = re.findall(7            r"Memory Model.*", amdmeminfo, re.MULTILINE        )[0].split()[-1]W        gpu_info["adapter_num"] = re.findall(r"OpenCL ID.*", amdmeminfo, re.MULTILINE)[
            0        ].split()[-1].        gpu_info["bios_version"] = re.findall(7            r"BIOS Version.*", amdmeminfo, re.MULTILINE        )[0].split()[-1]        return gpu_info5�_Π7����]³ωρυ68K             "Radeon Rx 5700 XT",5�_Π6����]³ωτ	υ56            "RX 5700 XT",5�_Π6����]³ωώυ57J            "Rx 5700 XT",5�_Π8>����]ΐΘ§
υ79J?        memory_types = ["Hynix", "Samsung", "Micron", "Elpida"]5�_Π8>����88 v ]Σfυ79JJ        memory_types = ["Hynix", "Samsung", "Micron", "Elpida", "Unknown"]5�_Π8����88 v ]Σiυ79J?        memory_types = ["Hynix", "Samsung", "Micron", "Elpida"]υ89J5�_Π8#����88 v ]Σjυ79JJ        memory_types = [, "Unknown""Hynix", "Samsung", "Micron", "Elpida"]5�_Π 8����88 v ]Σlυ79JL        memory_types = [, "Unknown", "Hynix", "Samsung", "Micron", "Elpida"]5�_Π! ����^X!8υK            υJ5�_Π "!����^X!>υKG                shlex.split("{} --opencl".format(self.amdmeminfo_path))5�_Π!#"����^X!?υK            cmd = υK5�_Π"$#=����^X!?υK=            cmd = "{} --opencl".format(self.amdmeminfo_path))5�_Π#%$ ����^X!HυK from utils import CoinmineLogger5�_Π$&%����^X!UυK1            amdmeminfo = subprocess.check_output(5�_Π%'&5����^X!`υKM            amdmeminfo = Converter.cmd_to_string(cmd)subprocess.check_output(5�_Π&('����V4^X!aυ                shlex.split(            ).decode("utf-8")5�_Π')(����V^X!dυimport shleximport subprocess5�_Π(*)"����V^X!iυG5            amdmeminfo = Converter.cmd_to_string(cmd)5�_Π)+*!����^‚{ζυ "G-            logger.error("No AMD GPUs found")5�_Π*+����^‚{νυGD            logger.error("could not run amdmeminfo! e={}".format(e))5�_Π8>����88 v ]Σ`υ89Jυ79JU        memory_types = ["Hynix", "Samsung", "Micron", "Elpida",, "Unknown" "Unknown"]5�_Π8I����88 v ]Σ`υ89Jυ79J`        memory_types = ["Hynix", "Samsung", "Micron", "Elpida",, "Unknown", "Unknown" "Unknown"]5�_Π8>����]Σ!υ79J?        memory_types = ["Hynix", "Samsung", "Micron", "Elpida"]5�_Π8����]Σ$υ89Jυ79JJ        memory_types = [, "Unknown""Hynix", "Samsung", "Micron", "Elpida"]5�_Π8#����]Σ%υ79JL        memory_types = [, "Unknown", "Hynix", "Samsung", "Micron", "Elpida"]5�_Π8����]Σ'υ79JI        memory_types = "Unknown", "Hynix", "Samsung", "Micron", "Elpida"]5�_Π8����]Σ(υ79JK        memory_types = []"Unknown", "Hynix", "Samsung", "Micron", "Elpida"]5�_Π8����]Σ)υ79JJ        memory_types = ["Unknown", "Hynix", "Samsung", "Micron", "Elpida"]5�_Π6����]³ωϊυ57J            Rx 5700 XT",5�η�
Пример #6
0
VimŸUnDoεhγ0βθέϊΕW…w-•‹WŒPy0‡?ΈG{L7ΎQ<            "zcash": nanopool_hashrate("zec", self.address),:LLLL]9ξ�_Π����]/[ύυ        υ5_Π����]/\υ
        {}5_Π����]/\υ        hashrate = {}5_Π����]/\υ        hashrate = {"ethereum"}5_Π����]/\Œυυ5_Π ����]/\«υ/from health_monitor.pool import HashrateGateway5_Π ����]/\«υ from health_monitor.pool import 5_Π	(����]/\±υ(from health_monitor.pool import hashrate5_Π
	 ����]/\Γυ!        hashrate = {"ethereum": }5_Π	
7����]/\Μυ9        hashrate = {"ethereum": nanopool_hashrate('eth')}5_Π

D����]/\�υ,from health_monitor import BaseHealthChecker from utils import CoinmineLogger=from health_monitor.pool import hashrate as nanopool_hashrate!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):&    def __init__(self, coin, address):        self.coin = coin        self.address = address    def _is_healthy(self):'        hashrate = self._get_hashrate()        if hashrate:            return True
        else:            return False    def _get_hashrate(self):G        hashrate = {"ethereum": nanopool_hashrate('eth', self.address)}        pass5_Π
F����]/\ΪυG        hashrate = {"ethereum": nanopool_hashrate("eth", self.address)}5_Π
����]/\άυυυ5_Π����22V2]/\έυ3"ethereum": nanopool_hashrate("eth", self.address)}5_Π����22V2]/\έυ7    "ethereum": nanopool_hashrate("eth", self.address)}5_Π����22V2]/\έυ;        "ethereum": nanopool_hashrate("eth", self.address)}5_Π����22V2]/\ήυ?            "ethereum": nanopool_hashrate("eth", self.address)}5_Π����22V2]/\ήυC                "ethereum": nanopool_hashrate("eth", self.address)}5_Π����22V2]/\ΰυG                    "ethereum": nanopool_hashrate("eth", self.address)}5_Π4����22V2]/\δυE                    "monero": nanopool_hashrate("eth", self.address)}5_Π3����22V2]/\ηυυ5_Π����22V2]/\ιυE                    "monero": nanopool_hashrate("xmr", self.address)}5_Π����22V2]/\μυυ5_Π����22V2]/\νυE                    "monero": nanopool_hashrate("xmr", self.address)}5_Π3����22V2]/\ρυD                    "zcash": nanopool_hashrate("xmr", self.address)}5_Π2����22V2]/\χυC                    "grin": nanopool_hashrate("xmr", self.address)}5_ΠD����22V2]/\ύυD                    "zcash": nanopool_hashrate("zec", self.address)}5_ΠE����22V2]/]υE                    "monero": nanopool_hashrate("xmr", self.address)}5_ΠD����22V2]/]υD                    "grin": nanopool_hashrate("grin", self.address)}5_Π C����22V2]/]υC                    "grin": nanopool_hashrate("grin", self.address)5_Π! C����22V2]/]υ,from health_monitor import BaseHealthChecker from utils import CoinmineLogger=from health_monitor.pool import hashrate as nanopool_hashrate!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):&    def __init__(self, coin, address):        self.coin = coin        self.address = address    def _is_healthy(self):'        hashrate = self._get_hashrate()        if hashrate:            return True
        else:            return False    def _get_hashrate(self):G        hashrate = {"ethereum": nanopool_hashrate("eth", self.address),E                    "monero": nanopool_hashrate("xmr", self.address),D                    "zcash": nanopool_hashrate("zec", self.address),D                    "grin": nanopool_hashrate("grin", self.address),                    }        pass5_Π "!����22V2]/]υ        υ5_Π!#"����22V2]/]
υ        hashrate[]5_Π"$#����22V2]/]υ        pass5_Π#%$����22V2]/]υ        return hashrate[]5_Π$&% ����22V2]/]~υ=from health_monitor.pool import hashrate as nanopool_hashrate5_Π%'& ����22V2]/]~υ5from health_monitor.pool import  as nanopool_hashrate5_Π&(' ����22V2]/]	υ,from health_monitor import BaseHealthChecker from utils import CoinmineLogger2from health_monitor.pool import  nanopool_hashrate!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):&    def __init__(self, coin, address):        self.coin = coin        self.address = address    def _is_healthy(self):'        hashrate = self._get_hashrate()        if hashrate:            return True
        else:            return False    def _get_hashrate(self):        hashrate = {?            "ethereum": nanopool_hashrate("eth", self.address),=            "monero": nanopool_hashrate("xmr", self.address),<            "zcash": nanopool_hashrate("zec", self.address),<            "grin": nanopool_hashrate("grin", self.address),	        }"        return hashrate[self.coin]5_Π')(����22V2]/]ηυ            υ5_Π(*)/����22V2]/]ϋυ0            logger.info("Pool side hashrate={}")5_Π)+*����22V2]/^υυ5_Π*,+����22V2]/^υA            logger.info("Pool side hashrate={}".format(hashrate))5_Π+-,����22V2]/^
υA            logger.warn("Pool side hashrate={}".format(hashrate))5_Π,.-����22V2]/^bυA            logger.warn("Pool side hashrate={}".format(hashrate))5_Π-/.!����22V2]/_ϋ
υ        υ5_Π.0/"����22V2]/`Zυ"        return hashrate[self.coin]5_Π/10����22V2]/`zυ        print(hashrate)5_Π021#����22V2]/aΩυ.        return hashrate[self.coin]["hashrate"]5_Π132(����22V2]/aΫυ3        return hashrate[self.coin].get()"hashrate"]5_Π2432����22V2]/aάυ2        return hashrate[self.coin].get("hashrate"]5_Π354����22V2]/erυυ5_Π465����22V2]/evυ1from health_monitor.pool import nanopool_hashrate5_Π5761����22V2]/evυ1from health_monitor.pool import nanopool_hashrate5_Π687����22V2]/e|υ<            "grin": nanopool_hashrate("grin", self.address),5_Π798����]/l
υ        υ5_Π8:9
$����]/lυ	&    def __init__(self, coin, address):5_Π9;:����]/{υJ            logger.warn("Warning! Pool side hashrate={}".format(hashrate))5_Π:<;!����]/{υK            logger.error("Warning! Pool side hashrate={}".format(hashrate))5_Π;><!����]/{υJ            logger.error("Warnin! Pool side hashrate={}".format(hashrate))5_Π<?=>����]/{2υ         υ5_Π>@?����]/{:υ            return False5_Π?A@����]/{;υ            return True5_Π@BA.����]/•Eυ<            "grin": grinmint_hashrate("grin", self.address),5_ΠACB2����]/•Iυ4            "grin": grinmint_hashrate(self.address),5_ΠBDC����]/•Nυ        υ5_ΠCED
����]/•Pυ        self.uuid5_ΠDFE

����]/•Tυ        self.uuid = uuid5_ΠEGF
����]/•Wυ        self.short_uuid = uuid5_ΠFHG
%����]/•Zυ	6    def __init__(self, coin, address, remedy_command):5_ΠGIH
0����]/•]υ	A    def __init__(self, coin, address, short_uuid remedy_command):5_ΠHJI9����]/•ύυ?            "grin": grinmint_hashrate(self.address, self.uuid),5_ΠIKJ=����]9ξ€υ?            "ethereum": nanopool_hashrate("eth", self.address),5_ΠJLK;����]9ξ¬υ=            "monero": nanopool_hashrate("xmr", self.address),5_ΠKL:����]9ξ­υ<            "zcash": nanopool_hashrate("zec", self.address),5_Π<>=����]/{*υ5_Π
����]/\Ωυ        hashrate = {5ηͺ
Пример #7
0
Vim�UnDo��
�����\��=*mA�/��uN,
D׌ f?$    return EstimatedEarningsGateway(
####]/S-
_�����]/RC��5�_�����]/RD�5�_�����V]/RI�+def load_account(coin_short_name, address):    return LoadAccountGateway(        Connection.get(D            "https://{}.nanopool.org/api/v1/load_account/{}".format((                coin_short_name, address
            )	        )    )'def payments(coin_short_name, address):    return PaymentsGateway(        Connection.get(@            "https://{}.nanopool.org/api/v1/payments/{}".format((                coin_short_name, address
            )	        )    )5�_�����V]/RI�5�_�����V]/Rm�\2def estimated_earnings(coin_short_name, hashrate):5�_�&����V]/R�\(def hashrate(coin_short_name, hashrate):5�_�$����V]/R��\'def hashrate(coin_short_name, address):$    return EstimatedEarningsGateway(        Connection.get(M            "https://api.nanopool.org/v1/{}/approximated_earnings/{}".format()                coin_short_name, hashrate
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError:E            logger.warning("FAILURE {}".format(make_error_message()))         except RequestException:O            logger.error("FAILURE {} url={}".format(make_error_message(), url))        return responseclass NanopoolGateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data*class LoadAccountGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:                return {W                    "unpaid_balance": float(self.data["data"]["userParams"]["balance"])                }"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}'class PaymentsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:W                return {"balance": float(self._parse_payments_dict(self.data["data"]))}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}2    def _parse_payments_dict(self, payments_dict):        total = 0*        for payment_dict in payments_dict:+            total += payment_dict["amount"]        return total0class EstimatedEarningsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:@                return {"estimated_earnings": self.data["data"]}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}5�_�	)����V]/R��[)                coin_short_name, hashrate5�_�
	,����V]/R��[M            "https://api.nanopool.org/v1/{}/approximated_earnings/{}".format(5�_�	
,����V]/R��[8            "https://api.nanopool.org/v1/{}//{}".format(5�_�
����V]/R��\�[5�_�
����V]/R��\import requests'def hashrate(coin_short_name, address):$    return EstimatedEarningsGateway(        Connection.get(@            "https://api.nanopool.org/v1/{}/hashrate/{}".format((                coin_short_name, address
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError:E            logger.warning("FAILURE {}".format(make_error_message()))         except RequestException:O            logger.error("FAILURE {} url={}".format(make_error_message(), url))        return responseclass NanopoolGateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data*class LoadAccountGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:                return {W                    "unpaid_balance": float(self.data["data"]["userParams"]["balance"])                }"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}'class PaymentsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:W                return {"balance": float(self._parse_payments_dict(self.data["data"]))}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}2    def _parse_payments_dict(self, payments_dict):        total = 0*        for payment_dict in payments_dict:+            total += payment_dict["amount"]        return total0class EstimatedEarningsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:@                return {"estimated_earnings": self.data["data"]}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}5�_�
����V]/R��^�^5�_�
����V]/R��aimport requests from utils import CoinmineLogger!logger = CoinmineLogger(__name__)'def hashrate(coin_short_name, address):$    return EstimatedEarningsGateway(        Connection.get(@            "https://api.nanopool.org/v1/{}/hashrate/{}".format((                coin_short_name, address
            )	        )    )class Connection:    def get(url):        response = None        try:(            response = requests.get(url)'            response.raise_for_status()        except HTTPError:E            logger.warning("FAILURE {}".format(make_error_message()))         except RequestException:O            logger.error("FAILURE {} url={}".format(make_error_message(), url))        return responseclass NanopoolGateway:&    def __init__(self, response_json):        try:,            self.data = response_json.json()        except Exception:            self.data = {}    def status(self):-        return self.data.get("status", False)    def error(self):+        return self.data.get("error", None)    def to_dict(self):        return self.data*class LoadAccountGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:                return {W                    "unpaid_balance": float(self.data["data"]["userParams"]["balance"])                }"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}'class PaymentsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:W                return {"balance": float(self._parse_payments_dict(self.data["data"]))}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}2    def _parse_payments_dict(self, payments_dict):        total = 0*        for payment_dict in payments_dict:+            total += payment_dict["amount"]        return total0class EstimatedEarningsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:@                return {"estimated_earnings": self.data["data"]}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}5�_�����v]/R��b        except HTTPError:5�_�/����v]/R��bE            logger.warning("FAILURE {}".format(make_error_message()))5�_�/����v]/R��b2            logger.warning("FAILURE {}".format()))5�_�����v]/R��b         except RequestException:5�_�4����v]/R��bO            logger.error("FAILURE {} url={}".format(make_error_message(), url))5�_�4����v]/R��b<            logger.error("FAILURE {} url={}".format(), url))5�_�6����v]/R��b=            logger.error("FAILURE {} url={}".format(e), url))5�_�3����v]/R��b3            logger.warning("FAILURE {}".format(e)))5�_�����v]/R�	�b�b5�_�4����4UV]/R��34"*class LoadAccountGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:                return {W                    "unpaid_balance": float(self.data["data"]["userParams"]["balance"])                }"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}'class PaymentsGateway(NanopoolGateway):    def to_dict(self):!        if self.status() is True:            try:W                return {"balance": float(self._parse_payments_dict(self.data["data"]))}"            except Exception as e:G                logger.error("{} e={}".format(make_error_message(), e))                return {}
        else:            return {}2    def _parse_payments_dict(self, payments_dict):        total = 0*        for payment_dict in payments_dict:+            total += payment_dict["amount"]        return total5�_�4����44V]/R��345�_�3����44V]/R��235�_�4����33V]/R��35?0class EstimatedEarningsGateway(NanopoolGateway):5�_�4����33V]/R�
�35?class Gateway(NanopoolGateway):5�_�8����33V]/R��79?@                return {"estimated_earnings": self.data["data"]}5�_�8����33V]/R��79?.                return {"": self.data["data"]}5�_� ;.����33V]/S�:<?G                logger.error("{} e={}".format(make_error_message(), e))5�_�! ;0����33V]/S�:<?4                logger.error("{} e={}".format(), e))5�_� "!;-����33V]/S�:<?1                logger.error("{} e={}".format e))5�_�!#";-����33V]/S�:<?0                logger.error("{} e={}".forma e))5�_�"#
����33V]/S,
�	?$    return EstimatedEarningsGateway(5��
Пример #8
0
Vim�UnDo���=�&%��V�nђ��ֶ���������F]/N�_�����]d��/�/5�_�����V]d��04    num_of_gpus = miner_status.get("num_of_gpus", 0)5�_�3����V]d��08        num_of_gpus = miner_status.get("num_of_gpus", 0)5�_�:����:v:]d��0<        mem_percent = CoinmineRequests.sanitize_redis_value(4            self.miner_status, "memory_util_percent"	        )5�_�����B:v:]d��.:        mem_percent = CoinmineRequests.sanitize_redis_valu5�_�����B:v:]d��.        mem_percent = @        num_of_gpus = miner_status.get("memory_util_percent", 0)5�_�����B:v:]d��-N        mem_percent = num_of_gpus = miner_status.get("memory_util_percent", 0)5�_�	����B:v:]d��-C        mem_percent =  = miner_status.get("memory_util_percent", 0)5�_�
	����B:v:]d��-import subprocessimport shlex from utils import CoinmineLogger+from utils.requests import CoinmineRequests!logger = CoinmineLogger(__name__)class SystemHealthChecker:H    def __init__(self, miner_status, mem_percent_threshold, remedy_cmd):(        self.miner_status = miner_status:        self.mem_percent_threshold = mem_percent_threshold$        self.remedy_cmd = remedy_cmd    def check(self):        if self._is_healthy():@            logger.debug("system health check reported healthy")
        else:U            logger.error("system health check reported unhealthy, " "hard rebooting")<            SystemHealthChecker._remedy_cmd(self.remedy_cmd)    def _is_healthy(self):A        mem_percent =  miner_status.get("memory_util_percent", 0)4        if mem_percent > self.mem_percent_threshold:            logger.error(A                "memory percent utilization reported unhealthy! "7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold                )
            )            return False
        else:            logger.debug(>                "memory percent utilization reported healthy "7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold                )
            )        return True    @staticmethod    def _remedy_cmd(command):,        subprocess.run(shlex.split(command))5�_�	
����B:v:]d��-@        mem_percent = miner_status.get("memory_util_percent", 0)5�_�
����B:v:]d��+from utils.requests import CoinmineRequests5�_�
����]/N��,�,5�_�
����V]/N��import subprocessimport shlex5�_�
����

V]/N��*class SystemHealthChecker:5�_�
����
*V*]/N��
    def check(self):        if self._is_healthy():@            logger.debug("system health check reported healthy")
        else:U            logger.error("system health check reported unhealthy, " "hard rebooting")<            SystemHealthChecker._remedy_cmd(self.remedy_cmd)5�_�����

*V*]/N��
$$        self.remedy_cmd = remedy_cmd5�_�����

*V*]/N��
$'        self.remedy_commad = remedy_cmd5�_�'����

*V*]/N��
$(        self.remedy_command = remedy_cmd5�_�(����

*V*]/N��
$)        self.remedy_command = remedy_cmnd5�_�*����

*V*]/N��$,from health_monitor import BaseHealthChecker from utils import CoinmineLogger!logger = CoinmineLogger(__name__)-class SystemHealthChecker(BaseHealthChecker):H    def __init__(self, miner_status, mem_percent_threshold, remedy_cmd):(        self.miner_status = miner_status:        self.mem_percent_threshold = mem_percent_threshold,        self.remedy_command = remedy_command    def _is_healthy(self):E        mem_percent = self.miner_status.get("memory_util_percent", 0)4        if mem_percent > self.mem_percent_threshold:            logger.error(A                "memory percent utilization reported unhealthy! "7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold                )
VimŸUnDoוa_ž®�±¢±7�פM²Š�¨F~ך�°כ�+W�¯DIŒJ            logger.warn("could not return grin miner stats", {"error": e})‡F,,,,\�ל5
_�$/����\��ץ#%ŒI            logger.debug("received miner status {}".format(miner_status))5_�$0����\��ץ#%Œ>            logger.debug("received miner status(miner_status))5_�$@����\��ץ#%Œ@            logger.debug("received miner status", miner_status))5_�&4����\��ץ%'ŒE            logger.error("failed to get miner status e={}".format(e))5_�&4����\��ץ%'Œ4            logger.error("failed to get miner status5_�&9����\��ץ%'Œ9            logger.error("failed to get miner status", ""5_�&?����\��ץ%'Œ@            logger.error("failed to get miner status", {"error"}5_�	&C����\��ץ%'ŒC            logger.error("failed to get miner status", {"error": e}5_�
	1:����\�מץ02Œ>                    "attempting to connect to claymore rpc on"5_�	
1:����\�ןץ02Œ:                    "attempting to connect to claymore rpc5_�
1:����\�סץ02Œ;                    "attempting to connect to claymore rpc"1                    " {}".format(claymore_socket)5_�
1;����\�עץ02‹Y                    "attempting to connect to claymore rpc" " {}".format(claymore_socket)5_�
1<����\�ףץ02‹L                    "attempting to connect to claymore rpc"(claymore_socket)5_�
1=����\�רץ02‹N                    "attempting to connect to claymore rpc", "claymore_socket)5_�1?����\�שץ02‹P                    "attempting to connect to claymore rpc", {}"claymore_socket)5_�1N����\��ץ02‹O                    "attempting to connect to claymore rpc", {"claymore_socket)ץ12‹5_�1a����\�žץ02‹b                    "attempting to connect to claymore rpc", {"claymore_socket": claymore_socket))5_�1b����\�žץ02‹b                    "attempting to connect to claymore rpc", {"claymore_socket": claymore_socket})5_�1`����\�žץ‹
import socketimport json from utils import CoinmineLogger+from utils.requests import CoinmineRequests!logger = CoinmineLogger(__name__)class MinerRequests:    @staticmethodN    def get_miner_status(coin, claymore_socket, xmr_stak_url, grin_miner_url):        # we assume not mining        miner_status = {            "uptime": 0,            "hashrate": 0,!            "hashrate_list": [0],!            "accepted_shares": 0,!            "rejected_shares": 0,            "fan_speed": 0,            "temp": 0,            "pool": "",            "errors": [],	        }        try:            miners = {V                "ethereum": lambda: MinerRequests.get_claymore_stats(claymore_socket),S                "zcash": lambda: MinerRequests.get_claymore_stats(claymore_socket),Q                "monero": lambda: MinerRequests.get_xmr_stak_stats(xmr_stak_url),S                "grin": lambda: MinerRequests.get_grin_miner_stats(grin_miner_url),K                None: lambda: {"errors": "missing coin value from config"},
            }=            miner_status = {**miner_status, **miners[coin]()}?            logger.debug("received miner status", miner_status)        except Exception as e:D            logger.error("failed to get miner status", {"error": e})X        miner_status["mining"] = MinerRequests._is_hashing(miner_status.get("hashrate"))        return miner_status    @staticmethod,    def get_claymore_stats(claymore_socket):        try:H            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:                logger.debug(a                    "attempting to connect to claymore rpc", {"claymore_socket": claymore_socket}                )*                s.connect(claymore_socket)9                logger.debug("connected to claymore rpc")                 s.settimeout(60)P                s.sendall(b'{"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}')C                logger.debug("sent json for stats to claymore rpc")#                data = s.recv(1024)?                logger.debug("received data from claymore rpc")'            string_data = data.decode()/            json_data = json.loads(string_data)-            result_list = json_data["result"]*            uptime_in_min = result_list[1]:            accepted_shares = result_list[2].split(";")[1]:            rejected_shares = result_list[2].split(";")[2]%            hashrate = result_list[3]            # multigpu            if ";" in hashrate:E                hashrate_list = list(map(float, hashrate.split(";")))-                hashrate = sum(hashrate_list)            else:1                hashrate_list = [float(hashrate)]4            fan_speed = result_list[6].split(";")[1]/            temp = result_list[6].split(";")[0]!            pool = result_list[7]            stats = {4                "uptime": int(float(uptime_in_min)),*                "hashrate": int(hashrate),/                "hashrate_list": hashrate_list,8                "accepted_shares": int(accepted_shares),8                "rejected_shares": int(rejected_shares),,                "fan_speed": int(fan_speed),"                "temp": int(temp),                "pool": pool,
            }C            logger.debug("claymore socket stats: {}".format(stats))            return stats        except Exception as e:            logger.warn(T                "could not handle sending or receiving from socket:" " {}".format(e)
            )B            return {"errors": "claymore http service unavailable"}    @staticmethod)    def get_xmr_stak_stats(xmr_stak_url):        try:B            stats = CoinmineRequests.get(xmr_stak_url, "api.json").            pool = stats["connection"]["pool"]9            uptime_in_sec = stats["connection"]["uptime"]4            # will report 0 if a single thread fails4            hashrate = stats["hashrate"]["total"][0]             if hashrate is None:                hashrate = 0=            accepted_shares = stats["results"]["shares_good"]P            rejected_shares = stats["results"]["shares_total"] - accepted_shares8            # None values come from failed gpus/threads,7            # we want to accurately report the hashrate$            # even if a thread fails8            hashrate_list = stats["hashrate"]["threads"]            # convert None to 0P            hashrate_list = [0 if i[0] is None else i[0] for i in hashrate_list]>            total_hashrate_threads = round(sum(hashrate_list))            return {2                "uptime": int(uptime_in_sec / 60),D                "hashrate": int(hashrate) or total_hashrate_threads,/                "hashrate_list": hashrate_list,8                "accepted_shares": int(accepted_shares),8                "rejected_shares": int(rejected_shares),                "pool": pool,
            }        except Exception as e:I            logger.warn("could not return xmr-stak stats e={}".format(e))B            return {"errors": "xmr-stak http service unavailable"}-    def get_grin_miner_stats(grin_miner_url):        try:A            stats = CoinmineRequests.get(grin_miner_url, "stats")5            hashrate = stats["results"]["graph_rate"]F            return {"hashrate": hashrate, "hashrate_list": [hashrate]}        except Exception as e:K            logger.warn("could not return grin miner stats e={}".format(e))D            return {"errors": "grin miner http service unavailable"}    @staticmethod    def _is_hashing(hashrate):)        return bool(int(float(hashrate)))5_�U#����\�žץTVŒC            logger.debug("claymore socket stats: {}".format(stats))5_�U#����\�žץTVŒC            logger.debug("claymore socket stats: {}".format(stats))5_�U����\�žץTVŒC            logger.debug("claymore socket stats: {}".format(stats))5_�U9����\�ž ץTVŒL            logger.debug("recieved claymore socket stats: {}".format(stats))5_�U9����\�ž!ץTVŒL            logger.debug("recieved claymore socket stats" {}".format(stats))5_�U9����\�ž"ץTVŒ9            logger.debug("recieved claymore socket stats"5_�YB����\�ž.ץXZŒT                "could not handle sending or receiving from socket:" " {}".format(e)5_�YB����\�ž0ץXZŒB                "could not handle sending or receiving from socket5_�YM����\�ž4ץXZŒN                "could not handle sending or receiving from socket", {"error"}5_� ~7����\�žEץ}ŒI            logger.warn("could not return xmr-stak stats e={}".format(e))ץ~Œ5_�! ~G����\�žFץ}ŒX            logger.warn("could not return xmr-stak stats", {"error": e} e={}".format(e))5_� #!~G����\�žJץ}ŒG            logger.warn("could not return xmr-stak stats", {"error": e}5_�!$"#‡9����\�žUץ†ˆŒK            logger.warn("could not return grin miner stats e={}".format(e))ץ‡ˆŒ5_�#%$‡J����\�žV	ץ†ˆŒ[            logger.warn("could not return grin miner stats", {"error": e}) e={}".format(e))5_�$&%&@����\�ל'ץ%'ŒD            logger.error("failed to get miner status", {"error": e})ץ&'Œ5_�%'&&F����\�ל(
ץ%'ŒH            logger.error("failed to get miner status", {"error": str(e})5_�&('YN����\�ל+ץXZŒQ                "could not handle sending or receiving from socket", {"error": e}ץYZŒ5_�')(YT����\�ל,ץXZŒU                "could not handle sending or receiving from socket", {"error": str(e}5_�(*)~D����\�ל/ץ}ŒH            logger.warn("could not return xmr-stak stats", {"error": e})ץ~Œ5_�)+*~J����\�ל0ץ}ŒL            logger.warn("could not return xmr-stak stats", {"error": str(e})5_�*,+‡F����\�ל3ץ†ˆŒJ            logger.warn("could not return grin miner stats", {"error": e})ץ‡ˆŒ5_�+,‡L����\�ל4
ץ†ˆŒN            logger.warn("could not return grin miner stats", {"error": str(e})5_�!#"~8����\�žQץ}Œ8            logger.warn("could not return xmr-stak stats5_�YB����\�žAץXZŒB                "could not handle sending or receiving from socket5_�1?����\�תץ02‹?                    "attempting to connect to claymore rpc", {"5ח×
Пример #10
0
Vim�UnDo�s��r�Zq�O��S�E������=`6�c�        ####]/S�_�����]/P+��5�_�����]/P8��5�_�����]/PA�class PoolHealthChecker()5�_�����]/PG��5�_�*����]/PN�*class PoolHealthChecker(BaseHealthChecker)5�_�'����]/PT�    �5�_�����]/Pn�    def _is_healthy(self)5�_�	����]/Pu�        �5�_�
	����]/P��        5�_�	
����]/P��        pss5�_�
����]/P��,from health_monitor import BaseHealthChecker!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):    def _is_healthy(self):        pass5�_�
����]/P���5�_�
����]/P��	,from health_monitor import BaseHealthChecker from utils import CoinmineLogger!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):    def _is_healthy(self):        pass5�_�
����]/P��
    �

5�_�	����]/P��
    def __init__(self)5�_�	����]/P��	5�_�	����]/P��	5�_�	����]/Q�

    def __init__(self):5�_�	����]/Q �	        �	
5�_�
����]/Q$�,from health_monitor import BaseHealthChecker from utils import CoinmineLogger!logger = CoinmineLogger(__name__)+class PoolHealthChecker(BaseHealthChecker):    def __init__(self, coin):        self.coin = coin    def _is_healthy(self):        pass5�_�
����]/Q%�
        �

5�_�	����]/Q.�
    def __init__(self, coin):5�_�	����]/Q/�
    def __init__(self, coin):5�_�����	V	]/SP�    �5�_�����	V	]/SY�    def _get_hashrate(self)5�_�
����	V	]/S[�
        �
5�_�����	V	]/Sa�
        if self5�_�
����	V	]/Sa�
        �
5�_�%����	V	]/Sn�        �5�_�!����	V	]/Sr�        �5�_�" !
����	V	]/S}�
            r5�_�!#"����	V	]/S��        pass5�_�"#����	V	]/S��        �5�_�! ����	V	]/Sx�
        self._get_hashrate()5�_�����]/R5�    ���o+def load_account(coin_short_name, address):    return LoadAccountGateway(        Connection.get(D            "https://{}.nanopool.org/api/v1/load_account/{}".format((                coin_short_name, address
Vim�UnDo��M�O���5���f����N���S#n�i��'
    ^���_�����^X6���5�_�����^X6��if __nam5�_�����^X6��if __name__ == ""5�_�����^X7�if __name__ == "__main__"5�_�����^X7�    �5�_�����^X7��5�_�����^X7�5�_�	����^X7��5�_�
	����^X7�"from adapters import SystemHelpers5�_�	
����^X7�from  import SystemHelpers5�_�
����^X7!�from utils import SystemHelpers5�_�

����^X7#�	    �5�_�
2����^X7C�	4    Converters.dict_to_json_file("/etc/system_spec")5�_�

����^X7K�
    �	5�_�!����^X7c�
5    Converters.dict_to_json_file("/etc/system_specs")5�_�&����^X7e�
+from utils import SystemHelpers, Convertersdef main():+    json = SystemHelpers.get_system_specs();    Converters.dict_to_json_file(json, "/etc/system_specs")if __name__ == "__main__":
    main()5�_�����^`���    �
5�_�����V^`���+    json = SystemHelpers.get_system_specs();    Converters.dict_to_json_file(json, "/etc/system_specs")5�_�����V^`���	        �	5�_�����V^`���

        �
5�_�+����^a.��
+from utils import SystemHelpers, Converters5�_�����^a.��
�
5�_�����^a.��;from utils import SystemHelpers, Converters, CoinmineLogger!logger = CoinmineLogger(__name__)def main():    try:/        json = SystemHelpers.get_system_specs()?        Converters.dict_to_json_file(json, "/etc/system_specs")    except Exception:-        print("could not write system specs")if __name__ == "__main__":
    main()5�_�
����^a/
�
-        print("could not write system specs")5�_�����V^����;from utils import SystemHelpers, Converters, CoinmineLogger!logger = CoinmineLogger(__name__)5�_�����V^�����5�_�����V^����;from utils import SystemHelpers, Converters, CoinmineLogger!logger = CoinmineLogger(__name__)5�_� ����V^����?    from utils import SystemHelpers, Converters, CoinmineLogger%    logger = CoinmineLogger(__name__)5�_� ����V^����def main():    try:C        from utils import SystemHelpers, Converters, CoinmineLogger)        logger = CoinmineLogger(__name__)/        json = SystemHelpers.get_system_specs()?        Converters.dict_to_json_file(json, "/etc/system_specs")    except Exception:4        logger.error("could not write system specs")if __name__ == "__main__":
    main()5�_�����^����5�_�����^�����    try:5�_�����V^����try:5��
Пример #12
0
Vim�UnDo��C\�!T�ݾK����9�(LV��rRsޥ�+>                "memory percent utilization reported healthy "$>\���_�E����BDvD\��T�/U            logger.error("system health check reported unhealthy, " "hard rebooting")5�_�A����BDvD\��V�/Q            logger.error("system health check reported unhealthy,hard rebooting")5�_�?����BDvD\��`�/A                "memory percent utilization reported unhealthy! "5�_�@����BDvD\��a�/@                "memory percent utilization reported unhealthy!"5�_�A����BDvD\��d� /A                "memory percent utilization reported unhealthy!",5�_�����BDvD\��h� 0                {"memory"}5�_�����BDvD\��w�1        �05�_�	����BDvD\��|�2        string = "hj "5�_�
	����BDvD\����        string = "hj " " hjaa"5�_�	
����BDvD\����5�_�
6����BDvD\���� 08                {"memory": mem_percent, "memory_thresh"}5�_�
:����BDvD\���� 0;                {"memory": mem_percent, "memory_threshold"}5�_�
 ���� 6"VU\���� 7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold                )5�_�
 ���� 6 VU\����-import subprocessimport shlex from utils import CoinmineLogger+from utils.requests import CoinmineRequests!logger = CoinmineLogger(__name__)class SystemHealthChecker:H    def __init__(self, miner_status, mem_percent_threshold, remedy_cmd):(        self.miner_status = miner_status:        self.mem_percent_threshold = mem_percent_threshold$        self.remedy_cmd = remedy_cmd    def check(self):        if self._is_healthy():@            logger.debug("system health check reported healthy")
        else:R            logger.error("system health check reported unhealthy, hard rebooting")<            SystemHealthChecker._remedy_cmd(self.remedy_cmd)    def _is_healthy(self):<        mem_percent = CoinmineRequests.sanitize_redis_value(4            self.miner_status, "memory_util_percent"	        )4        if mem_percent > self.mem_percent_threshold:            logger.error(A                "memory percent utilization reported unhealthy!",W                {"memory": mem_percent, "memory_threshold": self.mem_percent_threshold}
            )            return False
        else:            logger.debug(>                "memory percent utilization reported healthy "7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold                )
            )        return True    @staticmethod    def _remedy_cmd(command):,        subprocess.run(shlex.split(command))5�_�$����6VU\����$&-�$%-5�_�&����&'V\����%&7                "memory={} memory_threshold={}".format(;                    mem_percent, self.mem_percent_threshold5�_�&����&&V\����%&                )5�_�$>����&&V\����#%+>                "memory percent utilization reported healthy "5�_�$<����&&V\����#%+?                "memory percent utilization reported healthy ",5��