GoldyBot.system

 1import os
 2import psutil
 3import platform
 4
 5class System():
 6    """Goldy Bot class used to check how much Goldy is utilizing on the host system."""
 7    def __init__(self):
 8        self.process = psutil.Process(os.getpid())
 9
10    @property
11    def os(self) -> str:
12        return f"{platform.system()} {platform.release()}"
13
14    @property
15    def cpu(self) -> int:
16        """Returns amount of CPU Goldy Bot is using on this system."""
17        return self.process.cpu_percent(0)/psutil.cpu_count()
18
19    @property
20    def ram(self) -> int:
21        """Returns amount of ram Goldy Bot is using on this system."""
22        return self.convert_to_GB(self.process.memory_info().rss)
23
24    @property
25    def disk(self):
26        disk_process = self.process.io_counters() 
27        disk_usage_process = disk_process[2] + disk_process[3]
28
29        disk_system = psutil.disk_io_counters()
30        disk_system_total = disk_system[2] + disk_system[3]
31
32        return self.convert_to_MB(disk_usage_process/disk_system_total * 100)
33
34    def convert_to_GB(self, size):
35        return(f"{size/float(1<<30):,.2f}")
36
37    def convert_to_MB(self, size):
38        return (f"{size/float(1<<20):,.2f}")
class System:
 6class System():
 7    """Goldy Bot class used to check how much Goldy is utilizing on the host system."""
 8    def __init__(self):
 9        self.process = psutil.Process(os.getpid())
10
11    @property
12    def os(self) -> str:
13        return f"{platform.system()} {platform.release()}"
14
15    @property
16    def cpu(self) -> int:
17        """Returns amount of CPU Goldy Bot is using on this system."""
18        return self.process.cpu_percent(0)/psutil.cpu_count()
19
20    @property
21    def ram(self) -> int:
22        """Returns amount of ram Goldy Bot is using on this system."""
23        return self.convert_to_GB(self.process.memory_info().rss)
24
25    @property
26    def disk(self):
27        disk_process = self.process.io_counters() 
28        disk_usage_process = disk_process[2] + disk_process[3]
29
30        disk_system = psutil.disk_io_counters()
31        disk_system_total = disk_system[2] + disk_system[3]
32
33        return self.convert_to_MB(disk_usage_process/disk_system_total * 100)
34
35    def convert_to_GB(self, size):
36        return(f"{size/float(1<<30):,.2f}")
37
38    def convert_to_MB(self, size):
39        return (f"{size/float(1<<20):,.2f}")

Goldy Bot class used to check how much Goldy is utilizing on the host system.

System()
8    def __init__(self):
9        self.process = psutil.Process(os.getpid())
os: str
cpu: int

Returns amount of CPU Goldy Bot is using on this system.

ram: int

Returns amount of ram Goldy Bot is using on this system.

disk
def convert_to_GB(self, size):
35    def convert_to_GB(self, size):
36        return(f"{size/float(1<<30):,.2f}")
def convert_to_MB(self, size):
38    def convert_to_MB(self, size):
39        return (f"{size/float(1<<20):,.2f}")