Δημοσιεύτηκε: 03 Δεκ 2009, 12:41
και σε περίπτωση που ενδιαφέρεται κάποιος, έφτιαξα ένα scriptάκι για να μην γεμίζει άσκοπα ο δίσκος όσο γίνεται monitoring:
το τρέχω στο tty1 [watch ./cpuMon.sh] μόλις bootάρω και το αφήνω... κρατάει logs μόνο όταν το CPU load ανέβει πάνω από το threshold (90%).
ξανά ευχαριστώ πολύ!
- Κώδικας: Επιλογή όλων
#!/bin/bash
#
# cpuMon.sh
# Monitors CPU load and logs it if it exceeds the threshold
#
threshold="90.0"
dFile="/home/user/cpuPeak.txt"
# Get current total-CPU-load (by adding all processes's %CPU)
cpuLoad=`ps aux --no-headers --sort=-%cpu | awk '{cpuload += $3} END {print cpuload}'`
# If the sum is greater than the threshold, log top-10 processes
if [ "$cpuLoad" \> "$threshold" ]; then
echo =====[ CPU load = "$cpuLoad" ]===== >> "$dFile"
date >> "$dFile"
ps aux --no-headers --sort=-%cpu | head -n10 >> "$dFile"
echo >> "$dFile"
fi
exit
το τρέχω στο tty1 [watch ./cpuMon.sh] μόλις bootάρω και το αφήνω... κρατάει logs μόνο όταν το CPU load ανέβει πάνω από το threshold (90%).
ξανά ευχαριστώ πολύ!