De um VM-X, eu quero fazer logon em diferentes VM-Y, obter o comando output dh -H da VM-Y
e descubra qual o uso do disco acima, digamos 50% e sendemail
da VM-X
echo "df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \ }'" | sshpass -p 'password' ssh user@VM-Y-IpAddress
e eu sou capaz de obter saída
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
mas quando eu coloco no ganeticheckdiskspace.sh não consegui
#!/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 protected]"
# set alert level 90% is default
ALERT=50
OUTPUT="$(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \ }' \" | sshpass -p 'password' ssh user@VM-Y-IpAddress)"
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 \" \" \ }'" | 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
qualquer ajuda plz