-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem
More file actions
138 lines (123 loc) · 4.13 KB
/
system
File metadata and controls
138 lines (123 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# AMD GPU Monitoring with radeontop
# Optimized for ASRock RX 6600 Challenger on Kali Linux
echo "🔴 AMD RX 6600 GPU Monitor"
echo "=========================="
echo "Hardware: ASRock RX 6600 Challenger"
echo "Platform: Kali Linux"
echo ""
# Check if radeontop is installed
if ! command -v radeontop &> /dev/null; then
echo "❌ radeontop not found. Installing..."
sudo apt update
sudo apt install -y radeontop
echo "✅ radeontop installed successfully"
echo ""
fi
# Function to get AMD GPU device path
get_amd_device() {
# Try common AMD device paths
for device in /dev/dri/card0 /dev/dri/card1; do
if [ -e "$device" ]; then
# Check if it's an AMD device
if lspci | grep -i "amd\|ati" | grep -q "$(basename $(readlink -f $device))"; then
echo "$device"
return 0
fi
fi
done
echo "/dev/dri/card0" # Default fallback
}
# Function to run radeontop with safe parameters
run_radeontop() {
local device=$(get_amd_device)
echo "🎯 Using device: $device"
echo "📊 Starting radeontop monitoring..."
echo "Press Ctrl+C to stop"
echo ""
# Run radeontop with safe parameters
# -d: device path
# -l: limit samples (1 = continuous)
# -s: sample interval (1 second)
timeout 30s radeontop -d "$device" -l 1 -s 1 2>/dev/null || {
echo "⚠️ radeontop failed, trying alternative method..."
# Alternative: try without device specification
timeout 30s radeontop -l 1 -s 1 2>/dev/null || {
echo "❌ radeontop failed to start"
echo "🔍 Troubleshooting:"
echo " 1. Check if AMD GPU is properly detected:"
lspci | grep -i "amd\|ati"
echo ""
echo " 2. Check available DRI devices:"
ls -la /dev/dri/
echo ""
echo " 3. Check GPU driver status:"
dmesg | grep -i "amd\|ati" | tail -5
return 1
}
}
}
# Function to get basic GPU info without radeontop
get_basic_gpu_info() {
echo "🔍 Basic GPU Information:"
echo "========================="
# PCI information
echo "📋 PCI Device:"
lspci | grep -i "amd\|ati" | while read -r line; do
echo " $line"
done
echo ""
# Driver information
echo "🔧 Driver Status:"
if [ -d "/sys/class/drm/card0/device" ]; then
echo " ✅ AMD GPU device found"
if [ -f "/sys/class/drm/card0/device/driver" ]; then
driver=$(basename $(readlink -f /sys/class/drm/card0/device/driver))
echo " Driver: $driver"
fi
else
echo " ❌ AMD GPU device not found"
fi
echo ""
# Temperature (if available)
echo "🌡️ Temperature:"
if command -v sensors &> /dev/null; then
amd_temp=$(sensors | grep -i "edge\|junction" | head -1 | awk '{print $2}')
if [ -n "$amd_temp" ]; then
echo " $amd_temp"
else
echo " Temperature sensor not available"
fi
else
echo " sensors command not available"
fi
echo ""
# Memory information
echo "💾 Memory Information:"
if [ -f "/sys/class/drm/card0/device/mem_info_vram_total" ]; then
vram_total=$(cat /sys/class/drm/card0/device/mem_info_vram_total 2>/dev/null)
vram_used=$(cat /sys/class/drm/card0/device/mem_info_vram_used 2>/dev/null)
if [ -n "$vram_total" ] && [ -n "$vram_used" ]; then
echo " Total VRAM: $((vram_total / 1024 / 1024))MB"
echo " Used VRAM: $((vram_used / 1024 / 1024))MB"
echo " Free VRAM: $(((vram_total - vram_used) / 1024 / 1024))MB"
else
echo " VRAM information not available"
fi
else
echo " VRAM information not available"
fi
echo ""
}
# Main execution
echo "🚀 Starting AMD GPU monitoring..."
echo ""
# First show basic info
get_basic_gpu_info
# Then try radeontop
echo "📈 Real-time Monitoring:"
echo "========================"
run_radeontop
echo ""
echo "✅ Monitoring complete"
echo "💡 Tip: Run this script periodically to monitor GPU health"