GOLDEN HOUR
DIR: /usr/local/lib/python3.9/site-packages/agent360/plugins
UP
UPLOAD
Name
Size
Action
__init__.py
0 B
DEL
[ __pycache__ ]
-
DEL
apt-updates.py
1.23 KB
DEL
asterisk.py
1012 B
DEL
bind.py
732 B
DEL
bird.py
841 B
DEL
bitninja.py
1.27 KB
DEL
cloudlinux-dbgov.py
1.04 KB
DEL
cloudlinux.py
1020 B
DEL
cpanel.py
1.41 KB
DEL
cpu.py
1.97 KB
DEL
cpu_freq.py
583 B
DEL
dirsize.py
617 B
DEL
diskinodes.py
652 B
DEL
diskstatus-nvme.py
1.58 KB
DEL
diskstatus.py
1.96 KB
DEL
diskusage.py
4.04 KB
DEL
docker.py
3.36 KB
DEL
dovecot.py
1.27 KB
DEL
elasticsearch.py
4.24 KB
DEL
exim.py
484 B
DEL
fail2ban.py
831 B
DEL
gpu.py
959 B
DEL
haproxy.py
4.17 KB
DEL
httpd.py
2.73 KB
DEL
iostat.py
5.1 KB
DEL
janus.py
705 B
DEL
kamailio.py
556 B
DEL
litespeed.py
3.04 KB
DEL
loadavg.py
332 B
DEL
loggedin.py
400 B
DEL
mailq.py
528 B
DEL
mdstat.py
1.36 KB
DEL
megacli.py
2.72 KB
DEL
memcached.py
3.09 KB
DEL
memory.py
932 B
DEL
minecraft.py
2.35 KB
DEL
mongodb.py
5.63 KB
DEL
mysql.py
5.13 KB
DEL
network.py
2.72 KB
DEL
nginx.py
3.2 KB
DEL
openvpn.py
2.17 KB
DEL
phpfpm.py
2.72 KB
DEL
ping.py
3.09 KB
DEL
plesk-cgroups.py
6.18 KB
DEL
plugins.py
2.48 KB
DEL
postfix.py
1.73 KB
DEL
powerdns.py
4.56 KB
DEL
process.py
4.26 KB
DEL
proftpd.py
1.1 KB
DEL
rabbitmq.py
3.49 KB
DEL
redis_stat.py
5.48 KB
DEL
sleeper.py
244 B
DEL
swap.py
364 B
DEL
system.py
5.67 KB
DEL
tcpports.py
1.08 KB
DEL
temp.py
1.45 KB
DEL
unbound.py
3.24 KB
DEL
vms.py
6.2 KB
DEL
wp-toolkit.py
1.8 KB
DEL
yum-updates.py
810 B
DEL
Edit: system.py
#!/usr/bin/env python # -*- coding: utf-8 -*- try: import netifaces except ImportError: netifaces = None import os import platform from subprocess import Popen, PIPE import sys import time import psutil import plugins try: import distro except ImportError: distro = None def systemCommand(Command, newlines=True): Output = "" Error = "" try: proc = Popen(Command.split(), stdout=PIPE) Output = proc.communicate()[0] except Exception: pass if Output: if newlines is True: Stdout = Output.split("\n") else: Stdout = Output else: Stdout = [] if Error: Stderr = Error.split("\n") else: Stderr = [] return (Stdout, Stderr) def linux_hardware_memory(): block_size = 0 try: with open("/sys/devices/system/memory/block_size_bytes", "r") as f: block_size = int(f.readline().strip(), 16) memory = 0 with os.scandir("/sys/devices/system/memory/") as it: for entry in it: if not entry.name.startswith("memory"): continue with open(entry.path + "/state", "r") as f: if "online" != f.readline().strip(): continue else: memory += block_size return memory except Exception: return 0 def ip_addresses(): ip_list = {} ip_list['v4'] = {} ip_list['v6'] = {} if netifaces is None: return ip_list for interface in netifaces.interfaces(): link = netifaces.ifaddresses(interface) if netifaces.AF_INET in link: if interface not in ip_list['v4']: ip_list['v4'][interface] = [] ip_list['v4'][interface].append(link[netifaces.AF_INET]) if netifaces.AF_INET6 in link: if interface not in ip_list['v6']: ip_list['v6'][interface] = [] ip_list['v6'][interface].append(link[netifaces.AF_INET6]) return ip_list class Plugin(plugins.BasePlugin): __name__ = 'system' def run(self, *unused): systeminfo = {} cpu = {} cpu['brand'] = "Unknown CPU" cpu['count'] = 0 if(os.path.isfile("/proc/cpuinfo")): f = open('/proc/cpuinfo') if f: for line in f: # Ignore the blank line separating the information between # details about two processing units if line.strip(): if "model name" == line.rstrip('\n').split(':')[0].strip(): cpu['brand'] = line.rstrip('\n').split(':')[1].strip() if "Processor" == line.rstrip('\n').split(':')[0].strip(): cpu['brand'] = line.rstrip('\n').split(':')[1].strip() if "processor" == line.rstrip('\n').split(':')[0].strip(): cpu['count'] = line.rstrip('\n').split(':')[1].strip() if cpu['brand'] == "Unknown CPU": f = os.popen('lscpu').read().split('\n') if f: for line in f: # Ignore the blank line separating the information between # details about two processing units if line.strip(): if "Model name" == line.rstrip('\n').split(':')[0].strip(): cpu['brand'] = line.rstrip('\n').split(':')[1].strip() if "Processor" == line.rstrip('\n').split(':')[0].strip(): cpu['brand'] = line.rstrip('\n').split(':')[1].strip() if "CPU(s)" == line.rstrip('\n').split(':')[0].strip(): cpu['count'] = line.rstrip('\n').split(':')[1].strip() mem = psutil.virtual_memory().total if sys.platform == "linux" or sys.platform == "linux2": hw_mem = linux_hardware_memory() if hw_mem != 0: mem = hw_mem if distro is None: systeminfo['os'] = str(' '.join(platform.linux_distribution())) else: systeminfo['os'] = str(' '.join(distro.linux_distribution(full_distribution_name=True))) elif sys.platform == "darwin": systeminfo['os'] = "Mac OS %s" % platform.mac_ver()[0] cpu['brand'] = str(systemCommand('sysctl machdep.cpu.brand_string', False)[0]).split(': ')[1] #cpu['count'] = systemCommand('sysctl hw.ncpu') elif sys.platform == "freebsd10" or sys.platform == "freebsd11": systeminfo['os'] = "FreeBSD %s" % platform.release() cpu['brand'] = str(systemCommand('sysctl hw.model', False)[0]).split(': ')[1] cpu['count'] = systemCommand('sysctl hw.ncpu') elif sys.platform == "win32": # https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information if sys.getwindowsversion().build >= 22000: systeminfo['os'] = "{} {}".format(platform.uname()[0], 11) else: systeminfo['os'] = "{} {}".format(platform.uname()[0], platform.uname()[2]) systeminfo['cpu'] = cpu['brand'] systeminfo['cores'] = cpu['count'] systeminfo['memory'] = mem systeminfo['psutil'] = '.'.join(map(str, psutil.version_info)) systeminfo['python_version'] = sys.version systeminfo['platform'] = platform.platform() systeminfo['uptime'] = int(time.time()-psutil.boot_time()) systeminfo['ip_addresses'] = ip_addresses() systeminfo['hostname'] = platform.node() return systeminfo if __name__ == '__main__': Plugin().execute()
SAVE FILE
TERMINAL
EXEC