33from memory_monitor import MemoryMonitor
44from network_monitor import NetworkMonitor
55from system_info import SystemInfo
6+ from processes import ProcessMonitor
67
78# ANSI color escape codes
89COLOR_RESET = "\033 [0m"
@@ -16,6 +17,7 @@ def main():
1617 memory_monitor = MemoryMonitor ()
1718 network_monitor = NetworkMonitor ()
1819 system_info = SystemInfo ()
20+ process_monitor = ProcessMonitor ()
1921
2022 try :
2123 while True :
@@ -24,39 +26,36 @@ def main():
2426 memory_output = memory_monitor .get_memory_usage ()
2527 bandwidth_output = network_monitor .get_bandwidth_usage ()
2628 sys_info_output = system_info .get_system_info ()
29+ processes_output = process_monitor .get_running_processes (num_processes = 10 )
2730
2831 # Apply colors to entire output strings
2932 cpu_output = f"{ COLOR_YELLOW } { cpu_output } { COLOR_RESET } "
3033 memory_output = f"{ COLOR_GREEN } { memory_output } { COLOR_RESET } "
31- bandwidth_output = f"{ COLOR_BLUE } { bandwidth_output } { COLOR_RESET } "
34+ bandwidth_output = f"{ COLOR_BLUE } { bandwidth_output . replace ( 'Received' , '↓' ). replace ( 'Sent' , '↑' ) } { COLOR_RESET } "
3235 sys_info_output = f"{ COLOR_CYAN } { sys_info_output } { COLOR_RESET } "
36+ processes_output = "\n " .join ([f"{ COLOR_CYAN } Running Processes{ COLOR_RESET } " , "-----------------" ] + processes_output )
3337
3438 # Clear screen
3539 print ("\033 c" , end = '' )
3640
3741 # Print headers
38- print (f"{ COLOR_CYAN } CPU & Memory{ COLOR_RESET } " )
39- print (f"{ COLOR_CYAN } ------------{ COLOR_RESET } " )
42+ print (f"{ COLOR_CYAN } CPU & Memory Network { COLOR_RESET } " )
43+ print (f"{ COLOR_CYAN } ------------- ------- { COLOR_RESET } " )
4044
41- # Print CPU and Memory meters
42- print (f"{ cpu_output } \n { memory_output } \n " )
43-
44- # Print Network header
45- print (f"{ COLOR_CYAN } Network{ COLOR_RESET } " )
46- print (f"{ COLOR_CYAN } -------{ COLOR_RESET } " )
47-
48- # Print Network meter
49- print (f"{ bandwidth_output } \n " )
50-
51- # Print System Info header
45+ # Print meters and system info
46+ print (f"{ cpu_output } { bandwidth_output } " )
47+ print (f"{ memory_output } " )
5248 print (f"{ COLOR_CYAN } System Info{ COLOR_RESET } " )
5349 print (f"{ COLOR_CYAN } -----------{ COLOR_RESET } " )
50+ sys_info_lines = [line [:40 ] for line in sys_info_output .split ("\n " )]
51+ for line in sys_info_lines :
52+ print (line )
5453
55- # Print System Info
56- print (sys_info_output )
54+ # Print Running Processes
55+ print (processes_output )
5756
5857 # Move cursor to the top
59- print ("\033 [10A " , end = '' )
58+ print ("\033 [6A " , end = '' )
6059
6160 time .sleep (0.5 ) # Wait for 0.5 seconds before updating again
6261
0 commit comments