Created
November 24, 2024 21:36
-
-
Save kenanpelit/a9b4b97ce66eef6ef9c4d6ff37226645 to your computer and use it in GitHub Desktop.
monitor-cpu-temp.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Renk tanımları | |
RED='\033[0;31m' | |
YELLOW='\033[0;33m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
clear | |
echo "CPU Sıcaklık İzleme (Çıkış için CTRL+C)" | |
echo "----------------------------------------" | |
while true; do | |
echo -e "\n$(date '+%H:%M:%S')" | |
sensors | grep -E 'Core|Package' | while read -r line; do | |
# Sadece sıcaklık değerini al (ilk sayıyı) | |
temp=$(echo "$line" | grep -oP '\+\d+' | head -n1 | tr -d '+') | |
# Package id satırını atla | |
if [[ "$line" == *"Package id"* ]]; then | |
echo -e "$line" | |
continue | |
fi | |
# Sıcaklığa göre renk seç | |
if [ "$temp" -gt 80 ]; then | |
echo -e "${RED}$line${NC}" | |
elif [ "$temp" -gt 70 ]; then | |
echo -e "${YELLOW}$line${NC}" | |
else | |
echo -e "${GREEN}$line${NC}" | |
fi | |
done | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment