#/bin/bash
memory=$(grep "Memory Usage" /tmp/esxihealth | grep -o '[0-9]*' | tr '\n' ' ')
ramused=$(echo $memory | cut -d' ' -f1)
ramtotal=$(echo $memory | cut -d' ' -f2)
rampercent=$((200*$ramused/$ramtotal % 2 + 100*$ramused/$ramtotal))
ramthreshold=95
if (( rampercent > ramthreshold )); then
ramhigh=true
fi
cpu=$(grep "CPU Usage" /tmp/esxihealth | grep -o '[0-9]*' | tr '\n' ' ')
cpuused=$(echo $cpu | cut -d' ' -f1)
cputotal=$(echo $cpu | cut -d' ' -f2)
cpupercent=$((200*$cpuused/$cputotal % 2 + 100*$cpuused/$cputotal))
cputhreshold=90
if (( cpupercent > cputhreshold )); then
cpuhigh=true
fi
if [ ! -z "$ramhigh" ] || [ ! -z "$cpuhigh" ]; then
...
else
...
fi