Skip to content

Cross-platform system metrics collector - Gathers CPU, memory, disk usage & uptime on Windows/macOS/Linux with automatic server backup. Uses psutil when available, falls back to native OS commands.

License

Notifications You must be signed in to change notification settings

i3T4AN/Cross-platform-sys-reporting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

System Metrics

A simple Python script to collect and display system metrics across Windows, macOS, and Linux.

Features

  • Cross-platform: Works on Windows, macOS, and Linux
  • Automatic fallbacks: Uses psutil when available, otherwise falls back to system commands
  • Comprehensive metrics: Collects CPU usage, memory usage, disk usage, uptime, and hostname
  • Dual output: Displays both JSON report and formatted table

Requirements

  • Python 3.6+
  • psutil (optional but recommended for better performance)

Installation

  1. Clone or download system_metrics.py
  2. (Optional) Install psutil for enhanced functionality:
    pip install psutil

Usage

Run the script directly:

python system_metrics.py

Output

The script provides two output formats:

  1. JSON Report: Machine-readable format with all metrics
  2. Table Report: Human-readable formatted table

Sample Output

System Metrics Collection
==================================================

JSON Report:
==================================================
{
  "timestamp": "2025-09-11T10:30:45.123456",
  "os": "Linux",
  "hostname": "mycomputer",
  "cpu_percent": 25.4,
  "memory_percent": 67.8,
  "disk_percent": 45.2,
  "uptime_seconds": 86400.0,
  "uptime_formatted": "1d 0h 0m",
  "psutil_available": true
}

System Metrics Table:
==================================================
Metric               Value                        
--------------------------------------------------
Timestamp            2025-09-11T10:30:45.123456   
OS                   Linux                        
Hostname             mycomputer                   
CPU Usage            25.4                         %
Memory Usage         67.8                         %
Disk Usage           45.2                         %
Uptime               1d 0h 0m                     
Uptime (seconds)     86400.0                      
psutil Available     true                         

Metrics Collected

  • CPU Usage: Current CPU utilization percentage
  • Memory Usage: RAM usage percentage
  • Disk Usage: Primary disk usage percentage
  • Uptime: System uptime in both seconds and formatted time
  • Hostname: System hostname
  • OS: Operating system type

Fallback Methods

When psutil is not available, the script uses:

  • Linux: /proc/stat, /proc/meminfo, /proc/uptime, df command
  • macOS: top, vm_stat, sysctl, df commands
  • Windows: wmic commands for system information

License

This project is licensed under the GNU General Public License v3.0 - see the [LICENSE] file for details.

About

Cross-platform system metrics collector - Gathers CPU, memory, disk usage & uptime on Windows/macOS/Linux with automatic server backup. Uses psutil when available, falls back to native OS commands.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages