/opt/dedrads
NameSizeModeActions
account_review/-0555rm
check_software_mods/-0555rm
cms_tools/-0555rm
etc/-0555rm
extras/-0555rm
mailparse/-0555rm
mysql/-0555rm
nlp_scripts/-0555rm
oldrads/-0555rm
perl/-0555rm
provision/-0555rm
python/-0555rm
suspended/-0555rm
__pycache__/-0555rm
account-review7990555editdlrm
allfw62590555editdlrm
alp.py165530555editdlrm
autossl_sync62670555editdlrm
check_apache92050555editdlrm
check_bandwidth45460555editdlrm
check_boxtrapper16840555editdlrm
check_cpu122120555editdlrm
check_crons18270555editdlrm
check_dcpumon19730555editdlrm
check_dns18270555editdlrm
check_domlogs610555editdlrm
check_exim37310555editdlrm
check_hacks226040555editdlrm
check_imap52490555editdlrm
check_io66350555editdlrm
check_max_children163410555editdlrm
check_mem16600555editdlrm
check_misc15100555editdlrm
check_pacct52010555editdlrm
check_php43440555editdlrm
check_pop322950555editdlrm
check_prov.py47140555editdlrm
check_server6960555editdlrm
check_size4900555editdlrm
check_software98490555editdlrm
check_spamd24260555editdlrm
check_traffic19330555editdlrm
check_user18870555editdlrm
clean_exim.py63900555editdlrm
clusterfix53430555editdlrm
cmspass.py39700555editdlrm
cms_check.py98250555editdlrm
cms_counter.py367340555editdlrm
cms_creds7130555editdlrm
cms_dumpdb44850555editdlrm
cms_pw14160555editdlrm
cpanel-api70400555editdlrm
cpanel_postgres_manager.py290040555editdlrm
cpmerge46310555editdlrm
cpumon21950555editdlrm
dcpumon.pl12390555editdlrm
dedcheck181270555editdlrm
dns-sync143860555editdlrm
docroot.py44250555editdlrm
du-tree74500555editdlrm
envinfo.py66330555editdlrm
exclude_rbl.py52490555editdlrm
extract-vhost26910555editdlrm
filescan35660555editdlrm
find_warez14600555editdlrm
first_setup.py191200555editdlrm
fixwpcron.py48220555editdlrm
fix_dns_cluster3530555editdlrm
goaccess12177200555editdlrm
hostsfilemods44670555editdlrm
imap_io23230555editdlrm
innodb_converter.py93430555editdlrm
killall9115300555editdlrm
killdns9410555editdlrm
lastcommcache.sh13740555editdlrm
legal_lock_down.sh74500555editdlrm
lil-cpanel520020555editdlrm
listacct45750555editdlrm
mailscan45440555editdlrm
mail_sources.py74070555editdlrm
megaclisas-status386640555editdlrm
migrate2central.sh144180555editdlrm
modify-account406310555editdlrm
modsec_disable.py114610555editdlrm
monarxctl89120555editdlrm
msp.pl277140555editdlrm
mysql_dstat4740555editdlrm
mysql_selector.py731020555editdlrm
nlp45820555editdlrm
procscrape18630555editdlrm
quarantine110830555editdlrm
radsfunctions.sh8630555editdlrm
recent-cp161480555editdlrm
remote_dump183470555editdlrm
reset_cpanel32050555editdlrm
server-load21920555editdlrm
show-conns201050555editdlrm
show-conns-adv.py546670555editdlrm
sparta.py3824980555editdlrm
sqltop271290555editdlrm
telcheck24110555editdlrm
temprootreset1860555editdlrm
unsuspend_user13070555editdlrm
unsusprunner.sh18400555editdlrm
updatednsadmin5260555editdlrm
update_spf149720555editdlrm
upgrade-check92160555editdlrm
vhost_data.py62210555editdlrm
wp-xray.sh858160555editdlrm
Edit: /opt/dedrads/envinfo.py (6633B)
#! /usr/lib/rads/venv/bin/python3 '''Gather information about system environment''' import os import sys import json from argparse import ArgumentParser __maintainer__ = "Daniel K" __email__ = "danielk@inmotionhosting.com" __version__ = "0.1.1" __date__ = "2016-09-22" # Globals DATA = {"status": 'uninitiated', "version": __version__} class EnvInfoError(Exception): '''Custom error class for module.''' def __init__(self, message): '''Init with call to base constructor.''' super().__init__(message) def get_data(min_version=None, max_version=None): ''' Main function for module, used to acquire environment information. min_version - If set, require envinfo.py to have a version greater than min_version max_version - If set, require envinfo.py to have a version less than max_version Returns dictionary of environment information. Currently, the only guaranteed entries are 'type', 'platform', and 'users'. The following are the keys that which may be present: type - General type of environment. Can be 'cpanel' or 'unknown' platform - Operating system information web_server - Type of webserver. Currently only 'apache' users - List of users. Apache related keys: easyapache - Version of EasyApache if present apache_conf - Location of httpd.conf for Apache apache_domlogs - Location of Apache domlogs On error will throw EnvInfoError. ''' if min_version is not None and min_version > __version__: raise EnvInfoError( 'Minimum version {} is greater than current version {}'.format( min_version, __version__ ) ) if max_version is not None and max_version < __version__: raise EnvInfoError( 'Maximum version {} is less than current version {}'.format( max_version, __version__ ) ) if os.path.isdir('/var/cpanel'): DATA['type'] = 'cpanel' else: DATA['type'] = 'unknown' if os.path.isfile('/etc/apache2/conf/httpd.conf'): DATA['apache_conf'] = '/etc/apache2/conf/httpd.conf' DATA['apache_domlogs'] = '/var/log/apache2/domlogs' DATA['web_server'] = 'apache' if DATA['type'] == 'cpanel': DATA['easyapache'] = '4' elif os.path.isfile('/usr/local/apache/conf/httpd.conf'): DATA['apache_conf'] = '/usr/local/apache/conf/httpd.conf' DATA['apache_domlogs'] = '/usr/local/apache/domlogs' DATA['web_server'] = 'apache' if DATA['type'] == 'cpanel': DATA['easyapache'] = '3' user_list = [] if DATA['type'] == 'cpanel': user_list = os.listdir('/var/cpanel/users/') elif os.path.isfile('/etc/passwd'): # If we don't know how else to find users, look to /etc/passwd if os.path.exists('/etc/passwd'): with open('/etc/passwd', encoding='utf-8') as file_handle: try: for line in file_handle: uid = int(line.split(':')[2]) if 500 <= uid < 32000: user_list.append(line.split(':')[0]) except OSError as e: # Catch, and throw back IOErrors. raise EnvInfoError('Could not read from /etc/passwd') from e else: # No known way to find users raise EnvInfoError("Unable to make user list for server type.") DATA['users'] = user_list DATA['status'] = 'initiated' return DATA def parse_args(): ''' Parse command line arguments ''' parser = ArgumentParser(description=__doc__) output_group = parser.add_argument_group("Output options") output_type_group = output_group.add_mutually_exclusive_group() output_type_group.add_argument( "-e", "--environment", action='store_const', dest='output_type', const='env', help=( "Print general system environment information." "This is the defualt." ), ) output_type_group.add_argument( "-u", "--users", action='store_const', dest='output_type', const='users', help="Print list of users rather than general environment.", ) output_type_group.add_argument( "--apache-conf", action='store_const', dest='output_type', const='apache_conf', help="Print location of Apache's httpd.conf.", ) output_group.add_argument( "-j", "--json", action='store_true', help="Print results in JSON" ) parser.add_argument( "-v", "-V", "--version", action='store_true', help="Print version information and exit.", ) args = parser.parse_args() if args.version: print(f"Environment Information tool version {__version__}") print(f"Last modified on {__date__}.") sys.exit(0) return (args.output_type, args.json) def main(): '''Function to be called when run from the command line''' (output_type, use_json) = parse_args() try: data = get_data() except EnvInfoError as error: print("Error:") print(error) if output_type == 'users': users = data['users'] if use_json: print( json.dumps( users, sort_keys=True, indent=4, separators=(',', ': ') ) ) else: print("\n".join(users)) elif output_type == 'apache_conf': if 'apache_conf' not in data: sys.stderr.write('No Apache configuration found\n') sys.exit(255) print(data['apache_conf']) else: if use_json: print( json.dumps( data, sort_keys=True, indent=4, separators=(',', ': ') ) ) else: print() print("Server Environment") print() print("Server Type: {}".format(data['type'])) print( "OS: {}".format(" ".join(data['platform'])) ) print("Web Server: {}".format(data['web_server'])) print("Apache configuration: {}".format(data['apache_conf'])) print("Apache domain logs: {}".format(data['apache_domlogs'])) print() print("Users:") print(" ".join(data['users'])) print() if __name__ == "__main__": main()