I am a Arthur, and in this article I want to share a small Python project that can be surprisingly useful when working on a new server, VPS, or development machine.
When I start working on a new environment, one of the first things I want to know is:
- Which operating system am I using?
- How much RAM is available?
- How many CPU cores are available?
- How much disk space is left?
- Is Python installed correctly?
- What is the machine’s IP address?
- Is the system running normally?
You can check all of these manually with different commands, but writing a small script can save time.
So in this tutorial, we are going to build a Developer Environment Checker using Python.
The project is beginner-friendly, but it also demonstrates concepts that are useful for real development and server administration.
What We Are Going to Build
Our Python script will display information such as:
========================================
Developer Environment Checker
========================================
Operating System : Linux
Machine : my-server
CPU Cores : 4
RAM : 7.8 GB
Disk Total : 80.0 GB
Disk Used : 31.4 GB
Disk Free : 48.6 GB
Python Version : 3.12.2
Local IP : 192.168.1.20
System check completed!
Enter fullscreen mode Exit fullscreen mode
The nice thing is that we don’t need a complicated framework.
We can build the entire tool with Python and a small external package.
1. Create the Project
First, create a directory:
mkdir environment-checker
cd environment-checker
Enter fullscreen mode Exit fullscreen mode
Create a Python file:
touch checker.py
Enter fullscreen mode Exit fullscreen mode
On Windows, you can simply create a file called:
checker.py
Enter fullscreen mode Exit fullscreen mode
2. Install psutil
We will use the psutil package to retrieve system information.
Install it with:
pip install psutil
Enter fullscreen mode Exit fullscreen mode
If your system uses pip3:
pip3 install psutil
Enter fullscreen mode Exit fullscreen mode
You can verify the installation:
python -c "import psutil; print(psutil.__version__)"
Enter fullscreen mode Exit fullscreen mode
If you get a version number, everything is ready.
3. Import the Required Modules
Let’s start with our Python file.
import platform
import socket
import shutil
import psutil
import sys
Enter fullscreen mode Exit fullscreen mode
Each module has a different job.
platform helps us get information about the operating system.
socket helps us retrieve network information.
shutil can be used to check disk usage.
psutil gives us CPU, memory, and other system information.
sys gives us information about the Python installation.
4. Get Operating System Information
Let’s create our first function.
def get_system_info():
return {
"system": platform.system(),
"release": platform.release(),
"machine": platform.machine(),
"hostname": socket.gethostname()
}
Enter fullscreen mode Exit fullscreen mode
Now we can test it:
info = get_system_info()
print("Operating System:", info["system"])
print("OS Release:", info["release"])
print("Machine:", info["machine"])
print("Hostname:", info["hostname"])
Enter fullscreen mode Exit fullscreen mode
For example:
Operating System: Linux
OS Release: 6.8.0
Machine: x86_64
Hostname: development-server
Enter fullscreen mode Exit fullscreen mode
This is useful when your application may run on different operating systems.
5. Check CPU Information
Next, let’s check how many CPU cores are available.
def get_cpu_info():
return {
"physical_cores": psutil.cpu_count(logical=False),
"logical_cores": psutil.cpu_count(logical=True),
"usage": psutil.cpu_percent(interval=1)
}
Enter fullscreen mode Exit fullscreen mode
Then:
cpu = get_cpu_info()
print("Physical CPU Cores:", cpu["physical_cores"])
print("Logical CPU Cores:", cpu["logical_cores"])
print("Current CPU Usage:", cpu["usage"], "%")
Enter fullscreen mode Exit fullscreen mode
Example:
Physical CPU Cores: 2
Logical CPU Cores: 4
Current CPU Usage: 17.3 %
Enter fullscreen mode Exit fullscreen mode
The distinction between physical and logical cores is useful when you’re checking whether a machine has enough resources for your workload.
6. Check RAM
Now let’s inspect memory.
def get_memory_info():
memory = psutil.virtual_memory()
return {
"total": memory.total,
"available": memory.available,
"used": memory.used,
"percent": memory.percent
}
Enter fullscreen mode Exit fullscreen mode
The values returned by psutil are in bytes, so let’s create a helper function.
def bytes_to_gb(value):
return round(value / (1024 ** 3), 2)
Enter fullscreen mode Exit fullscreen mode
Now we can display the result:
memory = get_memory_info()
print("Total RAM:", bytes_to_gb(memory["total"]), "GB")
print("Available RAM:", bytes_to_gb(memory["available"]), "GB")
print("RAM Usage:", memory["percent"], "%")
Enter fullscreen mode Exit fullscreen mode
Example output:
Total RAM: 7.8 GB
Available RAM: 4.2 GB
RAM Usage: 46.1 %
Enter fullscreen mode Exit fullscreen mode
7. Check Disk Space
Disk space is another important thing to monitor.
A server can appear healthy while an application suddenly stops working because the disk is full.
Let’s add:
def get_disk_info():
disk = shutil.disk_usage("/")
return {
"total": disk.total,
"used": disk.used,
"free": disk.free
}
Enter fullscreen mode Exit fullscreen mode
Then:
disk = get_disk_info()
print("Disk Total:", bytes_to_gb(disk["total"]), "GB")
print("Disk Used:", bytes_to_gb(disk["used"]), "GB")
print("Disk Free:", bytes_to_gb(disk["free"]), "GB")
Enter fullscreen mode Exit fullscreen mode
Example:
Disk Total: 80.0 GB
Disk Used: 31.4 GB
Disk Free: 48.6 GB
Enter fullscreen mode Exit fullscreen mode
If you’re running this on Linux, / represents the root filesystem.
8. Check Python Version
Now let’s check the Python version running the script.
def get_python_version():
return sys.version.split()[0]
Enter fullscreen mode Exit fullscreen mode
Use it like this:
print("Python Version:", get_python_version())
Enter fullscreen mode Exit fullscreen mode
Example:
Python Version: 3.12.2
Enter fullscreen mode Exit fullscreen mode
This can be particularly helpful when debugging dependency problems.
For example, one application might require Python 3.11 while another requires Python 3.12.
9. Find the Local IP Address
Let’s add a simple function for the local IP address.
def get_local_ip():
try:
hostname = socket.gethostname()
return socket.gethostbyname(hostname)
except socket.error:
return "Unable to detect"
Enter fullscreen mode Exit fullscreen mode
Then:
print("Local IP:", get_local_ip())
Enter fullscreen mode Exit fullscreen mode
Example:
Local IP: 192.168.1.20
Enter fullscreen mode Exit fullscreen mode
Keep in mind that this is normally a local/private address when you’re running the script inside a home or office network.
10. Add a Simple Health Check
Now let’s make the script a little smarter.
We can warn the user when CPU, memory, or disk usage becomes high.
def health_check(cpu_usage, memory_usage, disk_usage):
warnings = []
if cpu_usage > 80:
warnings.append("CPU usage is high.")
if memory_usage > 80:
warnings.append("Memory usage is high.")
if disk_usage > 80:
warnings.append("Disk usage is high.")
return warnings
Enter fullscreen mode Exit fullscreen mode
Now we need the disk percentage.
def get_disk_usage_percent():
disk = shutil.disk_usage("/")
return round((disk.used / disk.total) * 100, 2)
Enter fullscreen mode Exit fullscreen mode
We can now run:
cpu_usage = psutil.cpu_percent(interval=1)
memory_usage = psutil.virtual_memory().percent
disk_usage = get_disk_usage_percent()
warnings = health_check(
cpu_usage,
memory_usage,
disk_usage
)
if warnings:
print("\nWarnings:")
for warning in warnings:
print("-", warning)
else:
print("\nSystem looks healthy.")
Enter fullscreen mode Exit fullscreen mode
This is where our small script starts becoming more useful than simply printing system information.
11. Put Everything Together
Now let’s combine everything into one complete program.
import platform
import socket
import shutil
import psutil
import sys
def bytes_to_gb(value):
return round(value / (1024 ** 3), 2)
def get_system_info():
return {
"system": platform.system(),
"release": platform.release(),
"machine": platform.machine(),
"hostname": socket.gethostname()
}
def get_cpu_info():
return {
"physical_cores": psutil.cpu_count(logical=False),
"logical_cores": psutil.cpu_count(logical=True),
"usage": psutil.cpu_percent(interval=1)
}
def get_memory_info():
memory = psutil.virtual_memory()
return {
"total": memory.total,
"available": memory.available,
"used": memory.used,
"percent": memory.percent
}
def get_disk_info():
disk = shutil.disk_usage("/")
return {
"total": disk.total,
"used": disk.used,
"free": disk.free,
"percent": round((disk.used / disk.total) * 100, 2)
}
def get_python_version():
return sys.version.split()[0]
def get_local_ip():
try:
hostname = socket.gethostname()
return socket.gethostbyname(hostname)
except socket.error:
return "Unable to detect"
def health_check(cpu_usage, memory_usage, disk_usage):
warnings = []
if cpu_usage > 80:
warnings.append("CPU usage is high.")
if memory_usage > 80:
warnings.append("Memory usage is high.")
if disk_usage > 80:
warnings.append("Disk usage is high.")
return warnings
def main():
system = get_system_info()
cpu = get_cpu_info()
memory = get_memory_info()
disk = get_disk_info()
print("=" * 45)
print(" Developer Environment Checker")
print("=" * 45)
print(f"\nOperating System : {system['system']}")
print(f"OS Release : {system['release']}")
print(f"Machine : {system['machine']}")
print(f"Hostname : {system['hostname']}")
print(f"\nPhysical Cores : {cpu['physical_cores']}")
print(f"Logical Cores : {cpu['logical_cores']}")
print(f"CPU Usage : {cpu['usage']}%")
print(f"\nTotal RAM : {bytes_to_gb(memory['total'])} GB")
print(f"Available RAM : {bytes_to_gb(memory['available'])} GB")
print(f"RAM Usage : {memory['percent']}%")
print(f"\nDisk Total : {bytes_to_gb(disk['total'])} GB")
print(f"Disk Used : {bytes_to_gb(disk['used'])} GB")
print(f"Disk Free : {bytes_to_gb(disk['free'])} GB")
print(f"Disk Usage : {disk['percent']}%")
print(f"\nPython Version : {get_python_version()}")
print(f"Local IP : {get_local_ip()}")
warnings = health_check(
cpu["usage"],
memory["percent"],
disk["percent"]
)
print("\n" + "=" * 45)
if warnings:
print("System Warnings:")
for warning in warnings:
print(f"- {warning}")
else:
print("System looks healthy.")
print("=" * 45)
if __name__ == "__main__":
main()
Enter fullscreen mode Exit fullscreen mode
Save the file and run:
python checker.py
Enter fullscreen mode Exit fullscreen mode
12. Understanding the Main Function
The main() function is responsible for putting the pieces together.
Instead of writing one huge block of code, we separated the project into smaller functions.
For example:
system = get_system_info()
Enter fullscreen mode Exit fullscreen mode
gets operating system information.
Then:
cpu = get_cpu_info()
Enter fullscreen mode Exit fullscreen mode
gets CPU information.
And:
memory = get_memory_info()
Enter fullscreen mode Exit fullscreen mode
gets RAM information.
Finally:
disk = get_disk_info()
Enter fullscreen mode Exit fullscreen mode
gets disk information.
This approach makes the code easier to read and easier to modify later.
13. Add JSON Output
Here’s another useful improvement.
Developers often need machine-readable output instead of terminal output.
Let’s add JSON support.
First import:
import json
Enter fullscreen mode Exit fullscreen mode
Then create:
def create_report():
system = get_system_info()
cpu = get_cpu_info()
memory = get_memory_info()
disk = get_disk_info()
report = {
"system": system,
"cpu": cpu,
"memory": {
"total_gb": bytes_to_gb(memory["total"]),
"available_gb": bytes_to_gb(memory["available"]),
"usage_percent": memory["percent"]
},
"disk": {
"total_gb": bytes_to_gb(disk["total"]),
"used_gb": bytes_to_gb(disk["used"]),
"free_gb": bytes_to_gb(disk["free"]),
"usage_percent": disk["percent"]
},
"python_version": get_python_version(),
"local_ip": get_local_ip()
}
return report
Enter fullscreen mode Exit fullscreen mode
Now save it to a file:
def save_report():
report = create_report()
with open("system-report.json", "w") as file:
json.dump(report, file, indent=4)
print("Report saved to system-report.json")
Enter fullscreen mode Exit fullscreen mode
Call:
save_report()
Enter fullscreen mode Exit fullscreen mode
Now you’ll have:
system-report.json
Enter fullscreen mode Exit fullscreen mode
The JSON might look like:
{
"system": {
"system": "Linux",
"release": "6.8.0",
"machine": "x86_64",
"hostname": "development-server"
},
"cpu": {
"physical_cores": 2,
"logical_cores": 4,
"usage": 18.2
},
"memory": {
"total_gb": 7.8,
"available_gb": 4.2,
"usage_percent": 46.1
},
"python_version": "3.12.2"
}
Enter fullscreen mode Exit fullscreen mode
Now another application could consume this information automatically.
14. Why This Small Project Is Useful
At first glance, this might look like a simple Python exercise.
But the same idea can be extended into much larger tools.
For example, you could turn it into:
Server Monitoring Tool
|
+-- CPU monitoring
|
+-- RAM monitoring
|
+-- Disk monitoring
|
+-- Network monitoring
|
+-- Process monitoring
|
+-- JSON reports
|
+-- Email alerts
|
+-- API endpoint
Enter fullscreen mode Exit fullscreen mode
You could even run the script periodically with a Linux cron job.
For example:
*/10 * * * * /usr/bin/python3 /home/user/checker.py
Enter fullscreen mode Exit fullscreen mode
This would execute the script every 10 minutes.
15. Running It on a VPS
A small project like this is also a good way to learn how applications behave outside your local computer.
Instead of running it only on your laptop, you can deploy the project to a Linux VPS and test the environment remotely.
For developers who need a server for development, testing, deployment, or other workloads, SeiMaxim provides VPS and dedicated server options.
The important part is not which server you choose, but understanding the environment your application is actually running in.
Once you have SSH access to a Linux server, the workflow is straightforward:
ssh username@server-ip
Enter fullscreen mode Exit fullscreen mode
Then:
git clone https://github.com/yourusername/environment-checker.git
Enter fullscreen mode Exit fullscreen mode
Move into the project:
cd environment-checker
Enter fullscreen mode Exit fullscreen mode
Create a virtual environment:
python3 -m venv venv
Enter fullscreen mode Exit fullscreen mode
Activate it:
source venv/bin/activate
Enter fullscreen mode Exit fullscreen mode
Install the dependency:
pip install psutil
Enter fullscreen mode Exit fullscreen mode
And run:
python checker.py
Enter fullscreen mode Exit fullscreen mode
That’s it.
You now have a simple way to inspect the actual server environment from the command line.
16. A Few Ideas to Take This Further
If you want to turn this beginner project into something more advanced, there are several directions you can take.
Add Network Monitoring
You could use:
psutil.net_io_counters()
Enter fullscreen mode Exit fullscreen mode
to monitor uploaded and downloaded bytes.
Monitor Running Processes
You could inspect running processes:
for process in psutil.process_iter(
["pid", "name", "memory_percent"]
):
print(process.info)
Enter fullscreen mode Exit fullscreen mode
Add Alerts
You could send an alert whenever:
CPU > 90%
RAM > 90%
Disk > 90%
Enter fullscreen mode Exit fullscreen mode
Build a Web Dashboard
The Python script could become a small API using Flask or FastAPI.
For example:
from fastapi import FastAPI
import psutil
app = FastAPI()
@app.get("/health")
def health():
return {
"cpu": psutil.cpu_percent(),
"memory": psutil.virtual_memory().percent,
"disk": psutil.disk_usage("/").percent
}
Enter fullscreen mode Exit fullscreen mode
Then a monitoring dashboard could request:
GET /health
Enter fullscreen mode Exit fullscreen mode
and receive:
{
"cpu": 23.5,
"memory": 51.2,
"disk": 42.8
}
Enter fullscreen mode Exit fullscreen mode
That is already starting to look like a real monitoring service.
Final Thoughts
I like projects like this because they start small but teach several useful concepts at the same time.
We worked with:
- Python functions
- System information
- CPU monitoring
- RAM monitoring
- Disk monitoring
- Network information
- JSON
- Virtual environments
- Linux commands
- SSH
- VPS environments
- Basic server health checks
You don’t need a huge project to learn something useful.
Sometimes a 100-line script can teach you more about how a server actually works than a long theoretical tutorial.
And once this basic version works, the next step is to turn it into something bigger — perhaps a REST API, a web dashboard, or a lightweight monitoring service.
That’s where the fun really begins.