Forum in maintenance, we will back soon 🙂
Notifications
Clear all
Localhost Information Script
Python Scripting
2
Posts
2
Users
3
Reactions
233
Views
Topic starter
I've created a simple Python script to help with knowing information about your system in a tabular format.
You can find this project on GitHub.
File: .requirements.txt
psutil tabulate
File: hostinfo.py
import platform import os import socket import psutil from tabulate import tabulate # Function to get the local IP address def get_local_ip(): try: hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname) return local_ip except Exception as e: return str(e) # Function to get the external IP address # This function uses a system command that might not work in all environments def get_external_ip(): try: external_ip = os.popen('curl -s http://whatismyip.akamai.com /').read() return external_ip except Exception as e: return str(e) # Collecting extensive information info = { "Operating System": platform.system(), "OS Release": platform.release(), "Platform": platform.platform(), "Architecture": platform.architecture()[0], "Processor": platform.processor(), 'Machine': platform.machine(), 'Node': platform.node(), "CPU Cores": psutil.cpu_count(logical=False), "CPU Threads": psutil.cpu_count(logical=True), "Total RAM": f"{psutil.virtual_memory().total / (1024**3):.2f} GB", "Hostname": socket.gethostname(), "Local IP": get_local_ip(), "External IP": get_external_ip(), # Add more system details as needed "Python Version": platform.python_version(), } # Preparing for tabulate data = [[key, value] for key, value in info.items()] # Print in 2-column format print(tabulate(data, headers=["Information", "Value"], tablefmt="grid"))
To use:
python3 -m venv .pyHostProbe
source .pyHostProbe/bin/activate
pip install -r .requirements.txt
python3 hostinfo.py
Sample output:
+------------------+--------------------------------------------------------+ | Information | Value | +==================+========================================================+ | Operating System | Linux | +------------------+--------------------------------------------------------+ | OS Release | 6.1.64-09049-g010fe86d9eae | +------------------+--------------------------------------------------------+ | Platform | Linux-6.1.64-09049-g010fe86d9eae-x86_64-with-glibc2.36 | +------------------+--------------------------------------------------------+ | Architecture | 64bit | +------------------+--------------------------------------------------------+ | Processor | | +------------------+--------------------------------------------------------+ | Machine | x86_64 | +------------------+--------------------------------------------------------+ | Node | penguin | +------------------+--------------------------------------------------------+ | CPU Cores | 4 | +------------------+--------------------------------------------------------+ | CPU Threads | 4 | +------------------+--------------------------------------------------------+ | Total RAM | 14.18 GB | +------------------+--------------------------------------------------------+ | Hostname | penguin | +------------------+--------------------------------------------------------+ | Local IP | 127.0.1.1 | +------------------+--------------------------------------------------------+ | External IP | 216.186.166.104 | +------------------+--------------------------------------------------------+ | Python Version | 3.11.2 | +------------------+--------------------------------------------------------+
Provide feedback: GitHub Issues
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Posted : 02/23/2024 4:31 pm
Husein Aboul Hasan reacted
Topic Tags
Nice! You remind me, back in 2013, I was learning c# , I created a similar app with a UI 🙂
Posted : 02/24/2024 1:29 pm
Husein Aboul Hasan and SSAdvisor reacted
Forum Jump:
Related Topics
-
How to add payment using "Streamlit UI"
3 months ago
-
How can i remember python scripting
9 months ago
-
A cautionary tale about using Flask in debug mode with Python Threads
11 months ago
-
I don't understand the reason of error.
1 year ago
-
csv download is not including all the results in a django application
1 year ago
Forum Information
Our newest member: Azi
Latest Post: Create Killer Viral Content With AI - NOT ChatGPT!
Forum Icons:
Forum contains no unread posts
Forum contains unread posts
Topic Icons:
Not Replied
Replied
Active
Hot
Sticky
Unapproved
Solved
Private
Closed