{"id":26876879,"url":"https://github.com/endtoenddev/pysysmoniter","last_synced_at":"2025-07-12T23:34:52.366Z","repository":{"id":281939510,"uuid":"946938959","full_name":"EndToEndDev/PySysMoniter","owner":"EndToEndDev","description":"A little gui to see system metrics","archived":false,"fork":false,"pushed_at":"2025-03-11T23:37:28.000Z","size":26538,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T11:17:27.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EndToEndDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-11T23:04:44.000Z","updated_at":"2025-03-11T23:37:31.000Z","dependencies_parsed_at":"2025-03-12T00:35:53.345Z","dependency_job_id":null,"html_url":"https://github.com/EndToEndDev/PySysMoniter","commit_stats":null,"previous_names":["endtoenddev/pysysmoniter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EndToEndDev/PySysMoniter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndToEndDev%2FPySysMoniter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndToEndDev%2FPySysMoniter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndToEndDev%2FPySysMoniter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndToEndDev%2FPySysMoniter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EndToEndDev","download_url":"https://codeload.github.com/EndToEndDev/PySysMoniter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndToEndDev%2FPySysMoniter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265068763,"owners_count":23706527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-31T11:17:30.830Z","updated_at":"2025-07-12T23:34:52.345Z","avatar_url":"https://github.com/EndToEndDev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PySysMoniter\nA little gui to see system metrics\n\nThis Python script is designed to monitor and display **CPU**, **Disk**, and **NVIDIA GPU usage** in real time. It uses the **`psutil`** library to track CPU and disk usage, and **`GPUtil`** to monitor the GPU usage specifically for NVIDIA GPUs. The results are displayed in a **CustomTkinter** GUI, which is a modern and visually appealing alternative to the standard Tkinter library.\n\n## Libraries Used\n\n- **`psutil`**: Used to retrieve system information such as CPU usage and disk usage.\n- **`GPUtil`**: A Python library used to interact with NVIDIA GPUs and retrieve GPU usage information.\n- **`customtkinter`**: An extension of the Tkinter library that provides a modern and customizable GUI with a dark mode.\n\n## Key Functions\n\n### 1. **`get_gpu_usage()`**\nThis function checks for NVIDIA GPUs using the **`GPUtil.getGPUs()`** method and retrieves their memory usage as a percentage. If no NVIDIA GPUs are found, it returns a message indicating that.\n\n```python\ndef get_gpu_usage():\n    try:\n        # Check for NVIDIA GPUs using GPUtil\n        gpus = GPUtil.getGPUs()\n        if gpus:\n            gpu_usage = []\n            for gpu in gpus:\n                usage = gpu.memoryUtil * 100  # GPU memory utilization as percentage\n                gpu_usage.append(f\"NVIDIA GPU {gpu.id}: {usage}%\")\n            return '\\n'.join(gpu_usage)\n        else:\n            return \"No NVIDIA GPUs found.\"\n    except Exception as e:\n        return \"Error retrieving NVIDIA GPU usage.\"\n```\n\n### 2. **`monitor_usage()`**\nThis function collects real-time system information:\n- **CPU Usage** using **`psutil.cpu_percent()`**\n- **Disk Usage** for the C drive using **`psutil.disk_usage()`**\n- **GPU Usage** using the **`get_gpu_usage()`** function\n\nIt formats these values into a readable string that displays the current system usage.\n\n```python\ndef monitor_usage():\n    # Get CPU usage\n    cpu_usage = psutil.cpu_percent(interval=1)\n    \n    # Get Disk usage for C drive (or modify as needed)\n    disk_usage = psutil.disk_usage('C:\\\\')\n    \n    # Get GPU usage (NVIDIA only)\n    gpu_usage = get_gpu_usage()\n    \n    # Return formatted usage details\n    return f\"CPU Usage: {cpu_usage}%\\nDisk Usage: {disk_usage.percent}%\\nGPU Usage:\\n{gpu_usage}\"\n```\n\n### 3. **`update_display(status_label)`**\nThis function updates the **CustomTkinter** window with the current system usage information every second. It continuously calls the **`monitor_usage()`** function and updates the text of the label on the GUI.\n\n```python\ndef update_display(status_label):\n    usage = monitor_usage()  # Get the updated usage info\n    status_label.configure(text=usage)\n    status_label.after(1000, update_display, status_label)  # Update every 1 second\n```\n\n### 4. **`create_gui()`**\nThis function sets up the **CustomTkinter** window. It initializes the window, sets the dark mode theme, creates a label to display system usage, and starts the update loop that continuously refreshes the displayed information.\n\n```python\ndef create_gui():\n    # Initialize the window\n    root = ctk.CTk()\n    root.title(\"System Usage Monitor\")\n    \n    # Set dark mode appearance\n    ctk.set_appearance_mode(\"dark\")\n    \n    # Create a label to display system usage\n    status_label = ctk.CTkLabel(root, text=\"Loading system usage...\", anchor=\"w\")\n    status_label.pack(pady=10, padx=20, fill=\"x\", anchor=\"w\")\n    \n    # Start the display update loop\n    update_display(status_label)\n    \n    # Run the Tkinter main loop\n    root.mainloop()\n```\n\n### 5. **`__main__` Block**\nThe **`if __name__ == \"__main__\":`** block ensures that the **`create_gui()`** function is called when the script is executed directly.\n\n```python\nif __name__ == \"__main__\":  \n    create_gui()\n```\n\n## How It Works\n\n- The **`get_gpu_usage()`** function checks for available NVIDIA GPUs and fetches their memory utilization.\n- **CPU** usage is updated every second using **`psutil.cpu_percent(interval=1)`**.\n- **Disk** usage is fetched using **`psutil.disk_usage()`**, which returns the disk usage for a given path (the script checks the C drive by default).\n- **GPU** usage is retrieved using **`GPUtil.getGPUs()`**, which accesses the NVIDIA GPUs on the system and reports their memory usage.\n- The GUI is created using **`customtkinter`** in **dark mode**, and the system usage information is displayed in real-time on the GUI.\n\n## Requirements\n\nMake sure to install the required libraries before running the script:\n\n```bash\npip install psutil GPUtil customtkinter\n```\n\n## Running the Script\n\nOnce the dependencies are installed, simply run the script and a GUI window will appear displaying your system's real-time **CPU**, **Disk**, and **GPU** usage.\n\n### Example Output in the GUI:\n\n```\nCPU Usage: 45%\nDisk Usage: 72%\nGPU Usage:\nNVIDIA GPU 0: 38%\n```\n\n### Error Handling\n\n- If no **NVIDIA GPU** is found on the system, the script will display the message: \"No NVIDIA GPUs found.\"\n- If there’s an error when retrieving GPU usage (e.g., if **`GPUtil`** encounters an issue), it will display: \"Error retrieving NVIDIA GPU usage.\"\n\n## Conclusion\n\nThis application provides a simple and intuitive way to monitor system resources, specifically **CPU**, **Disk**, and **NVIDIA GPU** usage, all through a clean, modern GUI built with **CustomTkinter**.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendtoenddev%2Fpysysmoniter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendtoenddev%2Fpysysmoniter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendtoenddev%2Fpysysmoniter/lists"}