Linux monitoring

#!/bin/bash
Mem_totl = ` Free | Awk  ' Nr == 2 {print $ 2} ' `
Mem_use = ` Free | Awk  ' Nr == 2 {print $ 3} ' `
mem_use_rate=`awk 'BEGIN{print('$mem_use'/'$mem_total')*100}'`
current_time=$(date "+%Y-%m-%d %H:%M:%S")
echo $current_time
pid=$(ps | grep "linksdwan" |grep "usr"|awk '{print $1}')
log=/root/$current_time.txt
link_mem=$(cat /proc/$pid/status | grep 'VmSize')
echo $mem_use_rate
process=$$
echo $process

while :;
do
    echo '***'
    if [ $mem_use_rate > 90 ]; then
        kill -9 $process
    fi
    sleep 60
    echo $current_time"-----Mem_use_rate"$mem_use_rate"---"$link_mem >> $log
done

Guess you like

Origin www.cnblogs.com/heishanyaoren/p/12176965.html