Vamos começar.
Criar load.sh
script
nano /path/load.sh
#!/bin/bash
#we use output from "uptime" i "w" to have load on 5 min
UPTIME='uptime';
W='w';
RAM='free -m';
DATE='date';
sleep 3
DF='df -h'
sleep 3
echo "######################################" >> /var/log/load-result/load_log
echo "$DATE" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "UPTIME:" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "$UPTIME" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "W COMMAND:" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "$W" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "FREE RAM:" >> /var/log/load-result/load_log
echo "$RAM" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "FREE SPACE:" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "$DF" >> /var/log/load-result/load_log
echo "" >> /var/log/load-result/load_log
echo "#####################################" >> /var/log/load-result/load_log
dê permissão do roteiro X
chmod 777 /path/load.sh
Crie um diretório para armazenar um arquivo de log
sudo mkdir /var/log/load-result
Crie um script para enviar e-mails
nano /path/mail.sh
mail -s Load_From_PC [email protected] < /var/log/load-result/load_log
Dê X mail.sh
chmod 777 /path/mail.sh
Crie tarefas agendadas
sudo crontab -e
*/5 * * * * /path/load.sh
00 11 * * * /path/mail.sh
load.sh
será executado a cada 5 min e o resultado do script será adicionado na parte inferior do arquivo de log.
mail.sh
será acionado todos os dias às 11:00 h
Você pode mudar o horário ...