I'm not very familiar with bash scripting. This seems like its an easy problem to solve but my lack of experience with bash has me baffled.
I have a file which contains a list of Ip addresses and the corresponding Virtual machine name. What I want my program to do is get the ip and check for it in my file. Then when a match is found assign the Virtual Machine name to the variable VM so I can use it later.
IP = 10.XXX.XX.10
cat /usr/lib64/nagios/plugins/be_vcenter_names.txt | 'VM = awk -F " " {if ( $1==$IP) VM=$2}'
echo $VM # nothing shows here
#
/usr/lib64/nagios/plugins/check_esx3 -D <DataCentre IP> -u <User> -p <password> -N $VM -l cpu -s ready --trace 3 | grep counterId\>12 | tail -1 | awk -F ">" '{print $15}'| awk -F "<" 'PERC= $1/200 {print "CHECK_ESX3 OK -\"${VM}\" cpu ready="PERC"% | cpu_ready="PERC"%;;"}'
FYI the last command works with a virtual machine name. The problem with my code is whats above the # signs
Also the following command works
cat /usr/lib64/nagios/plugins/be_vcenter_names.txt | 'VM = awk -F " " {if ( $1=="10.XXX.XX.10") print $2}
Thanks for your help. I'll be happy to give more info as needed
Aucun commentaire:
Enregistrer un commentaire