Skip to content

Instantly share code, notes, and snippets.

View krameraad's full-sized avatar
🤺

krameraad krameraad

🤺
View GitHub Profile
@krameraad
krameraad / monitoring.sh
Created January 12, 2026 15:52
Monitoring script for the 42 Born2BeRoot project
#!/bin/bash
architecture=$(uname -a)
n_cpu=$(grep "physical id" /proc/cpuinfo | wc -l)
n_vcpu=$(grep processor /proc/cpuinfo | wc -l)
mem_use=$(free --mega | awk '$1 == "Mem:" {printf("%d/%d (%.2f%%)"), $3, $2, $3/$2*100}')
disk_use=$(df -m | grep "/dev/" | grep -v "/boot" | \
awk '{use += $3} {total += $2} END {printf("%d/%dMB (%d%%)\n"), use, total, use/total*100}')
cpu_load=$(vmstat 1 4 | tail -1 | awk '{printf("%d%%"), 100-$15}')
last_boot=$(who -b | awk '{print $3, $4, $5}')