VimUnDoו�8¨��+�@פ1�Z=��½g�1K¹¢ב¦Bl¾Z! {"error": e},O\�לB_�68����\�pץ57WJ logger.warn("could not form json response e={}".format(e))5_�68����\�qץ57W8 logger.warn("could not form json respons5_�6D����\�vץ57WE logger.warn("could not form json response", {"error"}5_� 6H����\�wץ57WH logger.warn("could not form json response", {"error": e}5_� :$����\�µץ9;W: "{} {} status={} resp_json={}".format(5_� ;K����\�¸ץ:<WV self.operation, self.full_url, response.status_code, resp_json5_� <����\�÷ץ;=W )5_� <����\�¾ץWimport jsonimport requests from utils import CoinmineLogger!logger = CoinmineLogger(__name__)!OK_STATUS_CODES = [200, 201, 204]class RequestFactory:C def __init__(self, full_url, operation, json=None, token=None): self.full_url = full_url" self.operation = operation self.json = json self.token = token if token is None: self.headers = None else:E self.headers = {"Authorization": "Token %s" % self.token} def make_request(self): response = None request = {! "TEST_GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 10)) ), "GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 10)) ), "DELETE": lambda: (U requests.delete(self.full_url, headers=self.headers, timeout=(5, 10)) ), "PUT": lambda: ( requests.put(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 10) ) ), "POST": lambda: ( requests.post(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 10) ) ), } try:I response = self._sanitize_response(request[self.operation]()) try:+ resp_json = response.json()5 except json.decoder.JSONDecodeError as e: resp_json = NoneI logger.warn("could not form json response", {"error": e})7 if response.status_code in OK_STATUS_CODES: logger.debug(- "{} {} status={}".format(K self.operation, self.full_url, response.status_code ), resp_json ) else: logger.warn(: "{} {} status={} resp_json={}".format(V self.operation, self.full_url, response.status_code, resp_json ) ) except Exception as e:, if self.operation == "TEST_GET":J logger.warn("{} {}".format(self.operation, self.full_url)) else: logger.error(8 "e={} {} {} request_json={}".format(C e, self.operation, self.full_url, self.json ) ) raise e return response # helpers/ def _sanitize_response(self, raw_response):. # clean up xmr-stak invalid charactersS raw_response.__text = raw_response.text.replace("\n", "").replace("\r", "") return raw_response5_� C����\��ץCEXץCDX5_�C����\��ץBDY )5_�A$����\��ץ@BY: "{} {} status={} resp_json={}".format(5_�BK����\��ץACYV self.operation, self.full_url, response.status_code, resp_json5_�M����\��ץLNYC e, self.operation, self.full_url, self.json5_�L����\��ץKMY8 "e={} {} {} request_json={}".format(5_�N����\�דץMOY )5_�N����\�זץMOY ), {"error"}5_�N!����\�טץYimport jsonimport requests from utils import CoinmineLogger!logger = CoinmineLogger(__name__)!OK_STATUS_CODES = [200, 201, 204]class RequestFactory:C def __init__(self, full_url, operation, json=None, token=None): self.full_url = full_url" self.operation = operation self.json = json self.token = token if token is None: self.headers = None else:E self.headers = {"Authorization": "Token %s" % self.token} def make_request(self): response = None request = {! "TEST_GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 10)) ), "GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 10)) ), "DELETE": lambda: (U requests.delete(self.full_url, headers=self.headers, timeout=(5, 10)) ), "PUT": lambda: ( requests.put(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 10) ) ), "POST": lambda: ( requests.post(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 10) ) ), } try:I response = self._sanitize_response(request[self.operation]()) try:+ resp_json = response.json()5 except json.decoder.JSONDecodeError as e: resp_json = NoneI logger.warn("could not form json response", {"error": e})7 if response.status_code in OK_STATUS_CODES: logger.debug(- "{} {} status={}".format(K self.operation, self.full_url, response.status_code ), resp_json, ) else: logger.warn(- "{} {} status={}".format(K self.operation, self.full_url, response.status_code ), resp_json, ) except Exception as e:, if self.operation == "TEST_GET":J logger.warn("{} {}".format(self.operation, self.full_url)) else: logger.error(3 "{} {} request_json={}".format(@ self.operation, self.full_url, self.json# ), {"error": e} ) raise e return response # helpers/ def _sanitize_response(self, raw_response):. # clean up xmr-stak invalid charactersS raw_response.__text = raw_response.text.replace("\n", "").replace("\r", "") return raw_response5_�6E����\�ל:ץ57ZI logger.warn("could not form json response", {"error": e})ץ67Z5_�6K����\�ל;ץ57ZM logger.warn("could not form json response", {"error": str(e})5_�O����\�ל@ץNPZ! {"error": e},ץOPZ5_�O#����\�לAץNPZ% {"error": str(e},5_�A$����\��ץ@BY& "{} {} status={}t(5_� =����\��ץ<>5_� :$����\�×ץ9;W< "{} {} status={}"" resp_json={}".format(5_� :%����\�¬ץ9;W; "{} {} status={}" resp_json={}".format(5_� :%����\�®ץ9;W< "{} {} status={}", resp_json={}".format(5_�:����\�ץ9;W; "{} {}" status={} resp_json={}".format(5_�68����\�kץ67Wץ57W[ logger.warn("could not form json response e={}".format(e)) e={}".format(e))5ח×
Vim�UnDo�f0�C<?�'��Gz��㤓:o<e2Tn~���pMC logger.warn("could not get memory info e={}".format(e))L^q7_�����^a4~� <<<<<<< HEAD5�_�����V^a4�� O info["version"] = re.findall(r"Version: (.*)", output, re.MULTILINE)[0]O info["voltage"] = re.findall(r"Voltage: (.*)", output, re.MULTILINE)[0]W info["num_of_cores"] = re.findall(r"Core Count: (.*)", output, re.MULTILINE)[0], info["num_of_threads"] = re.findall(7 r"Thread Count: (.*)", output, re.MULTILINE )[0]W info["max_frequency"] = re.findall(r"Max Speed: (.*)", output, re.MULTILINE)[0]/ info["current_frequency"] = re.findall(8 r"Current Speed: (.*)", output, re.MULTILINE )[0]5�_�����V^a4��I�I�H5�_�����V^a4��S O info["version"] = re.findall(r"Version: (.*)", output, re.MULTILINE)[0]O info["voltage"] = re.findall(r"Voltage: (.*)", output, re.MULTILINE)[0]W info["num_of_cores"] = re.findall(r"Core Count: (.*)", output, re.MULTILINE)[0], info["num_of_threads"] = re.findall(7 r"Thread Count: (.*)", output, re.MULTILINE )[0]W info["max_frequency"] = re.findall(r"Max Speed: (.*)", output, re.MULTILINE)[0]/ info["current_frequency"] = re.findall(8 r"Current Speed: (.*)", output, re.MULTILINE )[0]5�_�����%V^a4��S info["version"] = re.findall(r"Version: (.*)", output, re.MULTILINE)[0]S info["voltage"] = re.findall(r"Voltage: (.*)", output, re.MULTILINE)[0]. info["num_of_cores"] = re.findall(9 r"Core Count: (.*)", output, re.MULTILINE )[0]0 info["num_of_threads"] = re.findall(; r"Thread Count: (.*)", output, re.MULTILINE )[0]5�_� ����V^a4�� 0>>>>>>> a12a311df8e785e8097c59ca61a1fae694685f985�_�����V^a4�� =======5�_� ����V^a4��I import re,from utils import CoinmineLogger, Converters!logger = CoinmineLogger(__name__)class Dmidecode:= def __init__(self, dmidecode_path="/usr/sbin/dmidecode"):, self.dmidecode_path = dmidecode_path def get_cpu_info(self): info = {} arg = "processor"9 cmd = "{} -t {}".format(self.dmidecode_path, arg) try:2 output = Converters.cmd_to_string(cmd)S info["version"] = re.findall(r"Version: (.*)", output, re.MULTILINE)[0]S info["voltage"] = re.findall(r"Voltage: (.*)", output, re.MULTILINE)[0][ info["num_of_cores"] = re.findall(r"Core Count: (.*)", output, re.MULTILINE)[0]0 info["num_of_threads"] = re.findall(; r"Thread Count: (.*)", output, re.MULTILINE )[0][ info["max_frequency"] = re.findall(r"Max Speed: (.*)", output, re.MULTILINE)[0]3 info["current_frequency"] = re.findall(< r"Current Speed: (.*)", output, re.MULTILINE )[0] except Exception as e:@ logger.warn("could not get cpu info e={}".format(e)) return info# def get_motherboard_info(self): info = {} arg = "system"9 cmd = "{} -t {}".format(self.dmidecode_path, arg) try:2 output = Converters.cmd_to_string(cmd). info["manufacturer"] = re.findall(; r"Manufacturer: (.*)", output, re.MULTILINE )[0]. info["product_name"] = re.findall(; r"Product Name: (.*)", output, re.MULTILINE )[0] except Exception as e:H logger.warn("could not get motherboard info e={}".format(e)) return info def get_memory_info(self): info = {} arg = "memory"9 cmd = "{} -t {}".format(self.dmidecode_path, arg) try:2 output = Converters.cmd_to_string(cmd)D size = re.findall(r"\tSize: (.*)", output, re.MULTILINE)D type = re.findall(r"\tType: (.*)", output, re.MULTILINE)F speed = re.findall(r"\tSpeed: (.*)", output, re.MULTILINE)D rank = re.findall(r"\tRank: (.*)", output, re.MULTILINE)S voltage = re.findall(r"Configured Voltage: (.*)", output, re.MULTILINE)$ num_of_banks = len(size)/ for bank in range(0, num_of_banks):0 info["bank_{}".format(bank)] = {' "size": size[bank],' "type": type[bank],) "speed": speed[bank],' "rank": rank[bank],- "voltage": voltage[bank], } except Exception as e:C logger.warn("could not get memory info e={}".format(e)) return info5�_� "����^q7 �!#M@ logger.warn("could not get cpu info e={}".format(e))5�_� 2����^q7�13MH logger.warn("could not get motherboard info e={}".format(e))5�_� L����^q7�KMMC logger.warn("could not get memory info e={}".format(e))5��
VimUnDoεhγ0βθέϊΕW w-WPy0?Έ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ηͺ
Vim�UnDo�b�ΩAx'�P@�r.���.���e"��M5<��hJ logger.warn("{} {}".format(self.operation, self.full_url))X....^q8o_�P����]�B�WR requests.get(self.full_url, headers=self.headers, timeout=(5, 10))5�_�P����]�G�WR requests.get(self.full_url, headers=self.headers, timeout=(5, 10))5�_�!S����]�J� "WU requests.delete(self.full_url, headers=self.headers, timeout=(5, 10))5�_�%W����]�M�$&WX self.full_url, json=self.json, headers=self.headers, timeout=(5, 10)5�_�*W����]�O�)+WX self.full_url, json=self.json, headers=self.headers, timeout=(5, 10)5�_� ����]��� X� W5�_� 5����]��� X5REQUEST_TIMEOUT = os.environ[REQUEST_TIMEOUT_CONNECT]5�_� 6����]��� X6REQUEST_TIMEOUT = os.environ[REQUEST_TIMEOUT_CONNECT])5�_� Z����]��� XZREQUEST_TIMEOUT = os.environ[REQUEST_TIMEOUT_CONNECT]), os,environ["REQUEST_TIMEOUT_READ"]5�_� 8����]��� X\REQUEST_TIMEOUT = os.environ[REQUEST_TIMEOUT_CONNECT]), os,environ["REQUEST_TIMEOUT_READ"]))5�_� ����]��� X`REQUEST_TIMEOUT = os.environ[REQUEST_TIMEOUT_CONNECT]), int(os,environ["REQUEST_TIMEOUT_READ"]))5�_� ����]���Ximport jsonimport requests from utils import CoinmineLogger!logger = CoinmineLogger(__name__)!OK_STATUS_CODES = [200, 201, 204]eREQUEST_TIMEOUT = (int(os.environ[REQUEST_TIMEOUT_CONNECT]), int(os,environ["REQUEST_TIMEOUT_READ"]))class RequestFactory:C def __init__(self, full_url, operation, json=None, token=None): self.full_url = full_url" self.operation = operation self.json = json self.token = token if token is None: self.headers = None else:E self.headers = {"Authorization": "Token %s" % self.token} def make_request(self): response = None request = {! "TEST_GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 25)) ), "GET": lambda: (R requests.get(self.full_url, headers=self.headers, timeout=(5, 25)) ), "DELETE": lambda: (U requests.delete(self.full_url, headers=self.headers, timeout=(5, 25)) ), "PUT": lambda: ( requests.put(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 25) ) ), "POST": lambda: ( requests.post(X self.full_url, json=self.json, headers=self.headers, timeout=(5, 25) ) ), } try:I response = self._sanitize_response(request[self.operation]()) try:+ resp_json = response.json()5 except json.decoder.JSONDecodeError as e: resp_json = NoneJ logger.warn("could not form json response e={}".format(e))7 if response.status_code in OK_STATUS_CODES: logger.debug(: "{} {} status={} resp_json={}".format(V self.operation, self.full_url, response.status_code, resp_json ) ) else: logger.warn(: "{} {} status={} resp_json={}".format(V self.operation, self.full_url, response.status_code, resp_json ) ) except Exception as e:, if self.operation == "TEST_GET":J logger.warn("{} {}".format(self.operation, self.full_url)) else: logger.error(8 "e={} {} {} request_json={}".format(C e, self.operation, self.full_url, self.json ) ) raise e return response # helpers/ def _sanitize_response(self, raw_response):. # clean up xmr-stak invalid charactersS raw_response.__text = raw_response.text.replace("\n", "").replace("\r", "") return raw_response5�_�����]��� [- int(os, environ["REQUEST_TIMEOUT_READ"]),5�_� ����]���\�[5�_�����]��� \- int(os.environ[REQUEST_TIMEOUT_CONNECT]),5�_�+����]��� \. int(os.environ["REQUEST_TIMEOUT_CONNECT]),5�_� Q����]� �!\R requests.get(self.full_url, headers=self.headers, timeout=(5, 25))5�_�#Q����]� �"$\R requests.get(self.full_url, headers=self.headers, timeout=(5, 25))5�_�&T����]� �%'\U requests.delete(self.full_url, headers=self.headers, timeout=(5, 25))5�_�*X����]� �)+\X self.full_url, json=self.json, headers=self.headers, timeout=(5, 25)5�_�/X����]� �.0\X self.full_url, json=self.json, headers=self.headers, timeout=(5, 25)5�_�\����]� �\ import osimport jsonimport requests from utils import CoinmineLogger!logger = CoinmineLogger(__name__)!OK_STATUS_CODES = [200, 201, 204]REQUEST_TIMEOUT = (/ int(os.environ["REQUEST_TIMEOUT_CONNECT"]),, int(os.environ["REQUEST_TIMEOUT_READ"]),)class RequestFactory:C def __init__(self, full_url, operation, json=None, token=None): self.full_url = full_url" self.operation = operation self.json = json self.token = token if token is None: self.headers = None else:E self.headers = {"Authorization": "Token %s" % self.token} def make_request(self): response = None request = {! "TEST_GET": lambda: (Z requests.get(self.full_url, headers=self.headers, timeout=REQUEST_TIMEOUT) ), "GET": lambda: (Z requests.get(self.full_url, headers=self.headers, timeout=REQUEST_TIMEOUT) ), "DELETE": lambda: (] requests.delete(self.full_url, headers=self.headers, timeout=REQUEST_TIMEOUT) ), "PUT": lambda: ( requests.put(` self.full_url, json=self.json, headers=self.headers, timeout=REQUEST_TIMEOUT ) ), "POST": lambda: ( requests.post(` self.full_url, json=self.json, headers=self.headers, timeout=REQUEST_TIMEOUT ) ), } try:I response = self._sanitize_response(request[self.operation]()) try:+ resp_json = response.json()5 except json.decoder.JSONDecodeError as e: resp_json = NoneJ logger.warn("could not form json response e={}".format(e))7 if response.status_code in OK_STATUS_CODES: logger.debug(: "{} {} status={} resp_json={}".format(V self.operation, self.full_url, response.status_code, resp_json ) ) else: logger.warn(: "{} {} status={} resp_json={}".format(V self.operation, self.full_url, response.status_code, resp_json ) ) except Exception as e:, if self.operation == "TEST_GET":J logger.warn("{} {}".format(self.operation, self.full_url)) else: logger.error(8 "e={} {} {} request_json={}".format(C e, self.operation, self.full_url, self.json ) ) raise e return response # helpers/ def _sanitize_response(self, raw_response):. # clean up xmr-stak invalid charactersS raw_response.__text = raw_response.text.replace("\n", "").replace("\r", "") return raw_response5�_�����V]���� h/ int(os.environ["REQUEST_TIMEOUT_CONNECT"]),5�_�����V]���� h, int(os.environ["REQUEST_TIMEOUT_READ"]),5�_�,����V]���� h. int(os.getenv["REQUEST_TIMEOUT_CONNECT"]),5�_�)����V]���� h+ int(os.getenv["REQUEST_TIMEOUT_READ"]),5�_�.����V]���� h/ int(os.getenv["REQUEST_TIMEOUT_READ"], 30),5�_� /����V]���� h1 int(os.getenv["REQUEST_TIMEOUT_CONNECT"], 5),5�_�! 0����V]���� h1 int(os.getenv["REQUEST_TIMEOUT_CONNECT"], 5),5�_� "!)����V]����
Vim�UnDo�G�B�v$���{P�&ub&��0#p�D logger.warn("could not get wifi device info from lspci")QQQQ^q7_�����^b���5�_�����^b����5�_�����^b���5�_�����^b���5�_�����^b���"�5�_�"����")V^b���!" def get_cpu_info(self):. cpus = Converters.json_string_to_dict(; Converters.cmd_to_string(self.detailed_cpu_cmd) )["cpus"] for cpu in cpus:. cpu["max_mhz"] = cpu.pop("maxmhz"). cpu["min_mhz"] = cpu.pop("minmhz") return cpus5�_�����""V^b��� ! base_cmd = "lscpu"5�_� ����""V^b���!class Lscpu:5�_� %����""V^b���"�!5�_� ����##V^b���" import re]5�_� ����##V^b���"5�_� ����$$V^b�� ; cpu_columns = "--extended=CPU,SOCKET,MAXMHZ,MINMHZ"5�_� ����##V^b�� "L self.detailed_cpu_cmd = "{} --json {}".format(base_cmd, cpu_columns)5�_� ����##V^b�� "< self. = "{} --json {}".format(base_cmd, cpu_columns)5�_�����##V^b�� "? self.cmd = "{} --json {}".format(base_cmd, cpu_columns)5�_�����##V^b�� " self.cmd = 5�_�����##V^b�� self.cmd = bas5�_� ����""V^b�� ! base_cmd = "lsusb"5�_�����""V^b�'�" �!5�_� ����##V^b�1� " Converters.cmd_to_string()5�_�����""V^b�2�" �!5�_�����##V^b�4�"�"5�_�����V^b�5�#" Converters.cmd_to_string()5�_�����V^b�6� 5�_�%����V^b�>�"& Converters.cmd_to_string()5�_�����V^b�B�0 output = self._get_detailed_output()5�_�����V^b�C�!. Converters.cmd_to_string(self.cmd)5�_�����V^b�;�!5�_�����V^b�<�"�"5�_� ����V^b�=�" r"Bus (.*)\n"5�_�! ����V^b�=�" r"Bus (.*)\n"5�_� "!����V^b�=�" r"Bus (.*)\n"5�_�!#"����V^b�=�" r"Bus (.*)\n"5�_�"$#����V^b�@�/ r"Class:.*Network controller\n"! "Vendor:\t(.*)\n"! "Device:\t(.*)\n"" "SVendor:\t(.*)\n"! "SDevice:\t(.*)",5�_�#%$����V^b�@� re.MULTILINE,5�_�$&%����V^b�C� r"Bus (.*)\n"5�_�%'&����V^b�D � import re,from utils import CoinmineLogger, Converters!logger = CoinmineLogger(__name__)class Lsusb: def __init__(self): self.cmd = "lsusb"# def get_wifi_device_info(self): info = {} try:7 output = Converters.cmd_to_string(self.cmd)! matches = re.findall( r"Bus (.*)\n", output, ) info = {( "vendor": matches[0][0],( "device": matches[0][1],, "sub_vendor": matches[0][2],, "sub_device": matches[0][3], } except Exception:D logger.warn("could not get wifi device info from lspci") return info5�_�&('����V^b�G� �5�_�')( ����V^b�N� �5�_�(*) ����V^b�R� � 5�_�)+*"����V^b�Y� # self.keywords = ["Network"]5�_�*,+#����V^b�r� % self.keywords = ["Network", ]5�_�+-,.����V^b�v� 0 self.keywords = ["Network", "Wireless" ]5�_�,.-����V^b�{ � if 5�_�-/.����V^b�~� if5�_�.0/
VimUnDoוa_®�±¢±7�פM²�¨F~ך�°כ�+W�¯DIJ 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;����\�עץ02Y "attempting to connect to claymore rpc" " {}".format(claymore_socket)5_� 1<����\�ףץ02L "attempting to connect to claymore rpc"(claymore_socket)5_� 1=����\�רץ02N "attempting to connect to claymore rpc", "claymore_socket)5_�1?����\�שץ02P "attempting to connect to claymore rpc", {}"claymore_socket)5_�1N����\��ץ02O "attempting to connect to claymore rpc", {"claymore_socket)ץ125_�1a����\�ץ02b "attempting to connect to claymore rpc", {"claymore_socket": claymore_socket))5_�1b����\�ץ02b "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#����\�ץTVC logger.debug("claymore socket stats: {}".format(stats))5_�U#����\�ץTVC logger.debug("claymore socket stats: {}".format(stats))5_�U����\�ץTVC logger.debug("claymore socket stats: {}".format(stats))5_�U9����\� ץTVL logger.debug("recieved claymore socket stats: {}".format(stats))5_�U9����\�!ץTVL logger.debug("recieved claymore socket stats" {}".format(stats))5_�U9����\�"ץTV9 logger.debug("recieved claymore socket stats"5_�YB����\�.ץXZT "could not handle sending or receiving from socket:" " {}".format(e)5_�YB����\�0ץXZB "could not handle sending or receiving from socket5_�YM����\�4ץXZN "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����\�ל+ץXZQ "could not handle sending or receiving from socket", {"error": e}ץYZ5_�')(YT����\�ל,ץXZU "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ץXZB "could not handle sending or receiving from socket5_�1?����\�תץ02? "attempting to connect to claymore rpc", {"5ח×
Vim�UnDo��8�o� ϖ�(����6��_v�8���,�(+9 logger.warn("No teensy device detected! Exiting")^q8�_�����^q8��+9 logger.warn("No teensy device detected! Exiting")5�_� =����++v]���+@ minary_ambiance_server_url = os.environ["MINARY_SERVER_URL"]5�_� 4����++v]���+D minary_ambiance_server_url = os.environ["MINARY_API_SERVER_URL"]5�_� ����++v]���+? minary_api_server_url = os.environ["MINARY_API_SERVER_URL"]5�_�>����++v]���+N "waiting for connection: {}/{}".format(minary_api_server_url, "state")5�_�9����++v]���+I lambda: CoinmineRequests.test_get(minary_api_server_url, "state")5�_�0����++v]��� +@ state = CoinmineRequests.get(minary_api_server_url, "state")5�_� "0����++v]���!#+G teensy_interface, state, minary_api_server_url, animation_queue5�_� "*����v]� �,) import os import sysDfrom thunder_and_lightning.utils import SerialUtils, TeensyInterfacePfrom thunder_and_lightning.controllers import AmbianceController, AnimationQueue<from utils import SystemHelpers, CoinmineLogger, sentry_init+from utils.requests import CoinmineRequests sentry_init()if __name__ == "__main__":% logger = CoinmineLogger(__name__)? minary_api_server_url = os.environ["MINARY_API_SERVER_URL"]5 script_path = os.environ["MINARY_TL_SCRIPT_PATH"]2 logger.info("Starting Light and Sound Worker")/ teensy_path = SerialUtils.get_teensy_port() if not teensy_path:9 logger.warn("No teensy device detected! Exiting") sys.exit(1)@ teensy_interface = TeensyInterface(teensy_path, script_path)& teensy_interface.set_serial_port()W logger.info("waiting for connection: {}/{}".format(minary_api_server_url, "state"))& SystemHelpers.wait_for_connection(I lambda: CoinmineRequests.test_get(minary_api_server_url, "state") )@ state = CoinmineRequests.get(minary_api_server_url, "state")& animation_queue = AnimationQueue()" ambiance = AmbianceController(G teensy_interface, state, minary_api_server_url, animation_queue ) try: while True:) ambiance.run_animation_step() except Exception as e:L logger.error("Could not run light and sound service e={}".format(e)) sys.exit(1)5�_� >����v]�"��)G state = CoinmineRequests.get(minary_api_server_url, "miner_status")5�_� G����v]�"��)P lambda: CoinmineRequests.test_get(minary_api_server_url, "miner_status")5��