File tree Expand file tree Collapse file tree 7 files changed +129
-0
lines changed Expand file tree Collapse file tree 7 files changed +129
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ import ram_kb
4
+ import ram_mb
5
+ import ram_gb
6
+ import sys_sw_hw_info
7
+ import variables_data
8
+ import pid_info
9
+ import ip_address
10
+
11
+
12
+ # Assigning a variable for the purpose of specifying which data measurement function is to be used.
13
+ data_measure = variables_data .megabyte
14
+
15
+ # Printing system, os, architecture level information using the function system_details in sys_sw_hw_info module.
16
+ print ('\n System & OS level details below:\n ' )
17
+ sys_sw_hw_info .system_details ()
18
+ print ()
19
+
20
+ # Printing IP address using the ip_addr function within the ip_address module.
21
+ # ip_address.ip_addr()
22
+ # print()
23
+
24
+ # Printing RAM details by using if/else statements so that the data measurement is in accordance to value of
25
+ # data_measure variable
26
+ print ('RAM details below: ' )
27
+
28
+ if data_measure == variables_data .kilobyte :
29
+ ram_kb .ram_specs ()
30
+ elif data_measure == variables_data .megabyte :
31
+ ram_mb .ram_specs ()
32
+ elif data_measure == variables_data .gigabyte :
33
+ ram_gb .ram_specs ()
34
+ else :
35
+ print ('Data Variable messed up! please check the code.' )
36
+
37
+ # Listing all of the current processes using process_info function in pid_info module.
38
+ print ('\n Current process details below: \n ' )
39
+ pid_info .processes_info ()
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ from psutil import process_iter
4
+
5
+
6
+ # Defining process_info function to list all the process, names and usernames with the help of psutil library.
7
+ def processes_info ():
8
+ for process in process_iter (attrs = ['name' , 'pid' , 'username' ]):
9
+ print (process .info )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ import psutil
4
+ import variables_data
5
+
6
+
7
+ # Assign variable to store total memory value.
8
+ mem = psutil .virtual_memory ()
9
+ mem_total = float (mem .total / variables_data .gigabyte )
10
+
11
+ # Assign variable with the value of currently available memory.
12
+ mem_free = float (mem .free / variables_data .gigabyte )
13
+
14
+ # Assign variable with the value of currently used memory.
15
+ mem_used = float (mem .used / variables_data .gigabyte )
16
+
17
+
18
+ # Defining function ram_specs that uses modules/functions from psutil library and from variables_data.
19
+ def ram_specs ():
20
+ print ()
21
+ print ('Total memory is: ' + str (float (mem_total )) + ' GBs' )
22
+ print ('Current available memory is: ' + str (float (mem_free )) + ' GBs' )
23
+ print ('Current used memory is: ' + str (float (mem_used )) + ' GBs' )
24
+ print ('Percentage of RAM being utilized currently: ' + str (float (mem .percent )) + '%' )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ import psutil
4
+ import variables_data
5
+
6
+
7
+ # Assign variable to store total memory value.
8
+ mem = psutil .virtual_memory ()
9
+ mem_total = float (mem .total / variables_data .kilobyte )
10
+
11
+ # Assign variable with the value of currently available memory.
12
+ mem_free = float (mem .free / variables_data .kilobyte )
13
+
14
+ # Assign variable with the value of currently used memory.
15
+ mem_used = float (mem .used / variables_data .kilobyte )
16
+
17
+ # Set Threshold
18
+ threshold = variables_data .kilobyte * 700 # 7000MB
19
+
20
+
21
+ # Defining function ram_specs that uses modules/functions from psutil library and from variables_data.
22
+ def ram_specs ():
23
+ # Set flow based on Threshold value.
24
+ print ()
25
+ print ('Total memory is: ' + str (float (mem_total )) + ' KBs' )
26
+ print ('Current available memory is: ' + str (float (mem_free )) + ' KBs' )
27
+ print ('Current used memory is: ' + str (float (mem_used )) + ' KBs' )
28
+ print ('Percentage of RAM being utilized currently: ' + str (float (mem .percent )) + '%' )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ import psutil
4
+ import variables_data
5
+
6
+
7
+ # Assign variable to store total memory value.
8
+ mem = psutil .virtual_memory ()
9
+ mem_total = float (mem .total / variables_data .megabyte )
10
+
11
+ # Assign variable with the value of currently available memory.
12
+ mem_free = float (mem .free / variables_data .megabyte )
13
+
14
+ # Assign variable with the value of currently used memory.
15
+ mem_used = float (mem .used / variables_data .megabyte )
16
+
17
+
18
+ # Defining function ram_specs that uses modules/functions from psutil library and from variables_data.
19
+ def ram_specs ():
20
+ # Set flow based on Threshold value.
21
+ print ()
22
+ print ('Total memory is: ' + str (float (mem_total )) + ' MBs' )
23
+ print ('Current available memory is: ' + str (float (mem_free )) + ' MBs' )
24
+ print ('Current used memory is: ' + str (float (mem_used )) + ' MBs' )
25
+ print ('Percentage of RAM being utilized currently: ' + str (float (mem .percent )) + '%' )
Original file line number Diff line number Diff line change 4
4
import sys
5
5
6
6
7
+ # Defining system_details function.
8
+ # Use of platform and sys libraries to obtain and print system, os and architecture info.
7
9
def system_details ():
8
10
os_type = platform .system ()
9
11
print ('OS Type: ' + os_type )
You can’t perform that action at this time.
0 commit comments