hi,
I need help in the client from xenserver, it collect information xenserver with client 2.0.1, but no collect the information de virtualmachine.
I am creating a script in shell that collect information from virtual machi, but do not know how to create an entry in ocs for the agent.
#!/bin/bash
echo "Create the csv for the vm-list"
xe vm-list params=dom-id,name-label,power-state,memory-actual,name-description,uuid,resident-on |grep -i [a-z]|awk 'ORS=NR%7?":":"\n"' |awk -F': ' '{print $2";"$4";"$6";"$8";"$10";"$12";"$14}'|grep -v "Control domain on host" >> csv/vm-list.csv
echo "Create the csv for the host-list"
xe host-list |grep -i [a-z]|awk 'ORS=NR%3?":":"\n"' |awk -F': ' '{print $2";"$4}'|grep -v "^Control domain on host" >> csv/$CMD.csv
VirtualMachine ( )
{
cat csv/vm-list.csv |while read LINE
do
ARQ1=$LINE
echo $ARQ1 > arq2.txt
maquinasvirtuais
done
}
maquinasvirtuais ()
{
residenton=$(awk -F ";" '{print $6}' arq2.txt)
l6=$(grep "$residenton" csv'\'host-list.csv|cut -d ";" -f2)
l1=$(awk -F ";" '{print $1}' arq2.txt)
l2=$(awk -F ";" '{print $2}' arq2.txt)
l3=$(awk -F ";" '{print $3}' arq2.txt)
l4=$(awk -F ";" '{print $4}' arq2.txt)
l5=$(awk -F ";" '{print $5}' arq2.txt)
l7=$(awk -F ";" '{print $7}' arq2.txt)
echo " <VIRTUALMACHINES>" >> $l6.ocs
echo " <COMMENT></COMMENT>" >> $l6.ocs
echo " <MAC></MAC>" >> $l6.ocs
echo " <MEMORY>$l5</MEMORY>" >> $l6.ocs
echo " <NAME>$l2</NAME>" >> $l6.ocs
echo " <STATUS>$l4</STATUS>" >> $l6.ocs
echo " <UUID>$l1</UUID>" >> $l6.ocs
echo " <VCPU></VCPU>" >> $l6.ocs
echo " <VMID>vm-$l7</VMID>" >> $l6.ocs
echo " <VMTYPE>XEN</VMTYPE>" >> $l6.ocs
echo " </VIRTUALMACHINES>" >> $l6.ocs
}
rm *.ocs
head ()
{
cat csv/host-list.csv |while read LINE
do
host=$LINE
host=$(grep "$host" csv'\'host-list.csv|cut -d ";" -f2)
echo '<?xml version="1.0" encoding="UTF-8"?>' >> $host.ocs
echo " <REQUEST>" >> $host.ocs
echo " <CONTENT>" >> $host.ocs
done
}
tail ()
{
cat csv/host-list.csv |while read LINE
do
host=$LINE
host=$(grep "$host" csv'\'host-list.csv|cut -d ";" -f2)
echo " </CONTENT>" >> $host.ocs
echo " <DEVICEID>$host</DEVICEID>" >> $host.ocs
echo " <QUERY>INVENTORY</QUERY>" >> $host.ocs
echo " </REQUEST>" >> $host.ocs
done
}
head
VirtualMachine
tail