Server IP : 184.154.167.98 / Your IP : 3.145.196.141 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/web-monitoring-tool/ |
Upload File : |
#!/opt/cloudlinux/venv/bin/python3 -bb # 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 # import csv import urllib.parse from clcommon import cpapi from sentry import init_wmt_sentry_client, setup_logger domains_path = "/var/lve/wmt/domains.csv" def write_domains(): logger = setup_logger('write_domains') try: with open(domains_path, 'w', newline='') as csvfile: writer = csv.writer(csvfile) if cpapi.CP_NAME == cpapi.PLESK_NAME: users = [_cpinfo[0] for _cpinfo in cpapi.cpinfo(keyls=('cplogin',))] else: users = cpapi.cpusers() if not users: return domain_set = set() for user in users: try: for domain, _ in cpapi.userdomains(user): # Convert domain name to http://www.domain.com format # https://stackoverflow.com/questions/21659044/how-can-i-prepend-http-to-a-url-if-it-doesnt-begin-with-http p = urllib.parse.urlparse(domain, 'http') netloc = p.netloc or p.path path = p.path if p.netloc else '' # Uncomment for http only # p = urllib.parse.ParseResult('http', netloc, path, *p[3:]) p = urllib.parse.ParseResult(p.scheme, netloc, path, *p[3:]) url = p.geturl() if url not in domain_set: domain_set.add(url) writer.writerow([url]) except Exception as e: logger.exception(e) except Exception as e: logger.exception(e) if __name__ == "__main__": # execute only if run as a script init_wmt_sentry_client() write_domains()