[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: collect_information.py
File is not writable. Editing disabled.
#!/opt/alt/python37/bin/python3 # coding=utf-8 # # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENCE.TXT # import json import argparse import os import logging from clwpos.logsetup import setup_logging from clwpos.feature_suites import ( get_allowed_modules, get_admin_config_directory, get_admin_config_permissions, ) from clwpos.utils import acquire_lock, user_uid, get_pw, is_wpos_supported from clwpos.cl_wpos_exceptions import WposError from clwpos.daemon import whmapi1, WposDaemon from clcommon.cpapi import cpusers, get_installed_php_versions _logger = setup_logging( caller_name='collect_information', file_level=logging.INFO, logfile_path='/var/log/clwpos/collect_information.log', ) def php_get_vhost_versions(): """ @return: [ { "account": "rm3", "documentroot": "/home/example/public_html", "version": "ea-php72", "handler": "php-fpm", "vhost": "otherchars.rm3.tld" } ] or empty list if command fails somehow """ try: return WposDaemon._php_get_vhost_versions() except Exception as e: raise WposError(e) if __name__ == '__main__' and is_wpos_supported(): with acquire_lock(os.path.join('/var/run/collect_information.lock',), attempts=None): parser = argparse.ArgumentParser(description="Utility to collect information about user for AccelerateWP") parser.add_argument("user", type=str, nargs="?") args = parser.parse_args() installed_versions = get_installed_php_versions() try: vhost_versions = php_get_vhost_versions() except WposError as e: _logger.exception("No vhosts collected due to: %s", e) vhost_versions = list() for username in cpusers(): if args.user is not None and username != args.user: # per user processing, skipping all other users continue pw = get_pw(username=username) if not get_allowed_modules(pw.pw_uid): # no features allowed for user, skipping user continue filtered_vhost_versions = [version for version in vhost_versions if version["account"] == username] try: admin_config_dir = get_admin_config_directory(pw.pw_uid) info_json = os.path.join(admin_config_dir, "info.json") with open(info_json, "w") as f: json.dump( {"installed_versions": installed_versions, "vhost_versions": filtered_vhost_versions}, f, ) owner, group, mode = get_admin_config_permissions(pw.pw_gid) os.chown(info_json, owner, group) os.chmod(info_json, mode) except Exception as e: _logger.exception("Error during collecting information for %s: %s", username, e) continue
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