От одного VM-X я хочу войти в систему другой VM-Y, получить произведенную горячекатаную команду-H от VM-Y
и узнайте, какое использование диска выше, говорят 50% и sendemail
от VM-X
echo "df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \$1 }'" | sshpass -p 'password' ssh user@VM-Y-IpAddress
и я могу быть произведенным
Pseudo-terminal will not be allocated because stdin is not a terminal. Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-62-generic x86_64)
* Documentation: https://help.ubuntu.com/
122 packages can be updated. 0 updates are security updates.
*** System restart required *** udev /dev/mapper/servername--vg-root /dev/sda1
но когда я поместил его в ganeticheckdiskspace.sh, который не в состоянии получить его
#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# set admin email so that you can get email
ADMIN="email@domain.com"
# set alert level 90% is default
ALERT=50
OUTPUT="$(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \$1 }' \" | sshpass -p 'password' ssh user@VM-Y-IpAddress)"
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \$1 }'" | sshpass -p 'password' ssh user@VM-Y-IpAddress | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep" $ADMIN
fi
done
любая справка