Hi all
I'm new to shell script and I want to write a script that checks to see how many of my virtual machines are running and if it is below the correct amount to send me an email
the command i need to run is simply
$ vmrun list
this returns me
Total Running VMs: 4
so basically i want to write a script that says
myvar = `vmrun list | grep [only get me the number, e.g. 4] | wc -l`
if [ $myvar < 4 ] then
email me a message at 'mymail@mail.com' saying 'not all vms are running'
or even
email me a message at 'mymail@mail.com' with the output from the command vmrun list
If anyone could help me with the actual shell script then I'd be very happy
Awk will be better for this ie:
Code:#!/bin/sh NUMBER=`vmrun list | awk '{print $NF}'` if [ $NUMBER le 3 ] ; then echo "Less than the desired 4 running" | mail -s "Stats from wmrun" mymail@mail.com else echo "equal or more than the desired 4 running" | mail -s "Stats from wmrun" mymail@mail.com fi
Don't worry Ma'am. We're university students, - We know what We're doing.
'Ruiat coelum, fiat voluntas tua.'Datalogi - en livsstil; Intet liv, ingen stil.
Bookmarks