nguyenminh

linux console commands check vps

Run sh on php $output = shell_exec(“sh process.sh”);

Disk
df -h | awk '$NF=="/"{printf "%s\t\t", $5}' > logs.txt
Ram
free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }' > logs.txt
CPU
top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}' > logs.txt

df | awk '$1 $5~/([2-9]|10)[0-9]/ {exit 1}' && echo 'No >=20s' || echo "Hello da su dung hon 20%" | mail -s "a subject" admin@nguyenminh.me

echo "Hello" | sendmail -f adminh@nguyenminh.me admin@nguyenminh.me

create process.sh
#!/bin/bash
# My first script
echo "CheckDisk"
df -h | awk '$NF=="/"{printf "%s\t\t", $5}'
echo "EndCheckDisk"
echo "CheckRam"
free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }'
echo "EndCheckRam"
echo "CheckCPU"
top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}'
echo "CheckCPU"
///////////
Run sh on php $output = shell_exec("sh process.sh");

Categorised in: Tổng hợp

0 Comments for "linux console commands check vps"

Leave a Reply

Your email address will not be published. Required fields are marked *