1. Turn off Firewall service iptables stop
2.SSH Configuration
(1) Generate key ssh-keygen-t RSA on the Monitor machine
(2) Create a folder on the monitored machine mkdir/root/.ssh/
(3) Copy files from the control machine to the controlled end scp/root/.ssh/id_rsa.pub 192.168.1.2:root/.ssh/authorized_keys
3. Scripting on the server
(1) Script abc.sh on the control machine is as follows
#/bin/bash
Fsmax=6
Remote_user=root
remote_ip= (192.168.1.1 192.168.1.2)
Ip_num=0
While ["$ip _num"-lt "${#remote_ip [@]}"]
Do
SSH [email protected]${remote_ip[$ip _num]} df-h >/tmp/disk_tmp
Disksize= ' grep ' \/$ '/tmp/disk_tmp | awk ' {print $4} ' | Cut-d%-f1 '
If [$disksize-gt $FSMAX]
Then
grep ' \/$ '/tmp/disk_tmp >/tmp/maildisk
echo ${remote_ip[$ip _num]} >>/tmp/maildisk
Mail-s "Diskcheck_alert" Root </tmp/maildisk
Fi
ip_num= ' expr $ip _num + 1 '
Done
(2) chmod a+x abc.sh
(3)./abc.sh
(4) Add a task plan CRONTAB-E
*/10 * * * */abc.sh
4. View message Records
Tail/var/spool/mail/root
Operations Monitoring Scripts