A FastAPI project to expose various Linux system statistics as RESTful APIs using common Linux commands.
β οΈ Important: This project only works on Linux systems.
It uses native Linux shell commands (e.g.lshw,df,ps, etc.)
β It will not run correctly on Windows or macOS.
- β System Information (kernel, hostname, uptime, user)
- β CPU & Memory Usage (top, free, lscpu)
- β Disk & Filesystem Info (df, du, mount)
- β Network Status (IP, routes, ping, traceroute)
- β Processes & Services (ps, systemctl)
- β Logs (syslog, dmesg, auth.log)
- β Hardware Details (lshw, lspci, sensors)
linux_monitor_api/
βββ app/
β βββ main.py
β βββ routes/
β β βββ system.py
β β βββ cpu_memory.py
β β βββ disk.py
β β βββ network.py
β β βββ processes.py
β β βββ logs.py
β β βββ hardware.py
β βββ utils/
β βββ run_command.py
βββ tests/
β βββ test_system.py
β βββ test_cpu_memory.py
β βββ test_disk.py
β βββ test_network.py
β βββ test_processes.py
β βββ test_logs.py
β βββ test_hardware.py
βββ requirements.txt
βββ README.md
pip install -r requirements.txtuvicorn app.main:app --reloadpytest tests/- Some commands may require elevated privileges (e.g.,
dmidecode,lshw). - Make sure required tools like
traceroute,dig, orlm-sensorsare installed if needed.
| Endpoint | Description |
|---|---|
/api/system/uname |
Kernel info (uname -a) |
/api/cpu/lscpu |
CPU info (lscpu) |
/api/disk/df |
Disk usage (df -h) |
/api/network/ip |
IP addresses (ip a) |
/api/processes/ps |
Running processes (ps aux) |
/api/logs/syslog |
Syslog tail (tail /syslog) |
/api/hardware/lshw |
Hardware info (lshw) |
| π§ Command | π£οΈ API Endpoint | π Description | ποΈ Scope |
|---|---|---|---|
uname -a |
/api/system/uname |
Kernel name, version, architecture | π§ System Information |
hostnamectl |
/api/system/hostname |
Show hostname and system information | π§ System Information |
lsb_release -a |
/api/system/release |
Ubuntu release information | π§ System Information |
uptime |
/api/system/uptime |
System uptime and load average | π§ System Information |
whoami |
/api/system/user |
Current logged-in user | π§ System Information |
id |
/api/system/id |
User ID and group info | π§ System Information |
uname -m |
/api/system/architecture |
System architecture | π§ System Information |
top |
/api/cpu/top |
Real-time CPU, memory, processes snapshot | π§ CPU & Memory Usage |
vmstat 1 |
/api/cpu/vmstat |
CPU/memory system performance | π§ CPU & Memory Usage |
lscpu |
/api/cpu/lscpu |
Detailed CPU information | π§ CPU & Memory Usage |
free -h |
/api/memory/free |
Memory usage summary | π§ CPU & Memory Usage |
cat /proc/meminfo |
/api/memory/meminfo |
Live memory usage details | π§ CPU & Memory Usage |
df -h |
/api/disk/df |
Disk space usage | πΎ Disk & Filesystem |
du -sh * |
/api/disk/du |
Disk usage per directory | πΎ Disk & Filesystem |
lsblk |
/api/disk/lsblk |
Block devices overview | πΎ Disk & Filesystem |
mount |
/api/disk/mount |
Mounted filesystems | πΎ Disk & Filesystem |
fdisk -l |
/api/disk/fdisk |
Partition table info | πΎ Disk & Filesystem |
findmnt |
/api/disk/findmnt |
Hierarchical view of mount points | πΎ Disk & Filesystem |
ip a |
/api/network/ip |
Show IP addresses | π Network |
ip route |
/api/network/route |
Routing table | π Network |
ss -tuln |
/api/network/ss |
Listening ports (TCP/UDP) | π Network |
ping 8.8.8.8 |
/api/network/ping |
Test network connectivity | π Network |
traceroute google.com |
/api/network/traceroute |
Trace network route | π Network |
dig example.com |
/api/network/dig |
DNS lookup | π Network |
nmcli dev show |
/api/network/nmcli |
Network manager details | π Network |
ps aux |
/api/processes/ps |
List running processes | π Processes & Services |
systemctl status |
/api/processes/systemctl_status |
Service manager status | π Processes & Services |
systemctl list-units |
/api/processes/systemctl_services |
List active services | π Processes & Services |
journalctl -xe |
/api/processes/journalctl |
View systemd logs | π Processes & Services |
tail -n 100 /var/log/syslog |
/api/logs/syslog |
Follow system logs | π Logs |
less /var/log/auth.log |
/api/logs/auth |
Authentication logs | π Logs |
dmesg |
/api/logs/dmesg |
Kernel ring buffer | π Logs |
lshw -short |
/api/hardware/lshw |
Detailed hardware info | π§° Hardware Info |
lspci |
/api/hardware/lspci |
PCI bus devices | π§° Hardware Info |
lsusb |
/api/hardware/lsusb |
USB devices | π§° Hardware Info |
dmidecode |
/api/hardware/dmidecode |
BIOS, motherboard, RAM details | π§° Hardware Info |
sensors |
/api/hardware/sensors |
CPU temperature sensors | π§° Hardware Info |
This project is licensed under the MIT License.