Skip to content

Commit f1854ac

Browse files
committed
Merge branches 'gh-pages' and 'master' of https://github.com/Tech-Overlord/system-info
2 parents 898956e + 3a50ebb commit f1854ac

File tree

7 files changed

+129
-0
lines changed

7 files changed

+129
-0
lines changed

sysinfo/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env python3
2+

sysinfo/main_system.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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('\nSystem & 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('\nCurrent process details below: \n')
39+
pid_info.processes_info()

sysinfo/pid_info.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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)

sysinfo/ram_gb.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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)) + '%')

sysinfo/ram_kb.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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)) + '%')

sysinfo/ram_mb.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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)) + '%')

sysinfo/sys_sw_hw_info.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import sys
55

66

7+
# Defining system_details function.
8+
# Use of platform and sys libraries to obtain and print system, os and architecture info.
79
def system_details():
810
os_type = platform.system()
911
print('OS Type: ' + os_type)

0 commit comments

Comments
 (0)