Jenkins String Variables:
VM = This is the name of the VM that we are gathering VM_Info About. Must be copied from vSphere in Full. SVR = This is the Hostname of the ESXi VM Server UNAME = This is the Username that we will use to log into ESXi Server PWD = This is the PWD for the USERNAME Above vmip = This is the IP for the host from hosts.cfg which this script will append vm_info to that line and delaypurple vmshortname = This is the VM's shortname for DNS. AKA W/O domain.com
Notes:
I can't get Server-Side scripts to be called by clientlaunch so I use Cron, actually I use Jenkins Cron, but same idea.
Example :
*/60 * * * * root /usr/lib/xymon/client/bin/xymoncmd "/usr/lib/xymon/client/ext/${vmshortname}_vminfo.sh"
Also, this line Below limits the Purpre Reading for 75 Minutes just to give it extra time. This isn't really a "check" so much as a nice way to see the Vm_info in XYMon. The only way this fails is if it gets NO stats. I could grep for something more specific, but I have more specific checks for that, this column is just a nice "overview"
Also provides good intel if you want to see VM_Info during peak hour.
sed -i "/^${vmip}/ s/$/ ${vmshortname}_vminfo delaypurple=vm_info:75/" /etc/xymon/hosts.cfg
The Meat and Potatoes!
cat << 'EOL' >"/usr/lib/xymon/client/ext/${vmshortname}_vminfo.sh" #!/bin/bash #This script was created by FreeSoftwareServers #Check out my site https://www.freesoftwareservers.com/wiki/xymon-aka-hobbit-aka-big-brother-3965320.html for more cool XYMon Stuff! #In hosts.cfg you need to add vm_vminfo #Substitute "vm" for what you put in vm variable below aka IP/Hostname #ESXi Variables server=$SVR username=$UNAME password=$PWD vm=$VMNAME #Get CPU & RAM Status python /opt/python-vmstats/py-vminfo.py -s "$server" -u "$username" -p "$password" -m "$vm" >> "/tmp/${vmshortname}_vminfo" ##XYMon VM_INFO Section## HOSTTAG="${vmshortname}_vminfo" COLUMN=vm_info cmd="$(cat "/tmp/${vmshortname}_vminfo")" $XYMONHOME/bin/xymongrep $HOSTTAG | while read L do set $L# To get one line of output from xymongrep HOSTIP="$1" MACHINEDOTS="$2" MACHINE=`echo $2 | $SED -e's/\./,/g'` COLOR=green MSG="$HOSTTAG status for host $MACHINEDOTS" if [ -z "$cmd" ] then COLOR=red MSG="${MSG} Couldn't Connect to ${server} to get VM_INFO "${cmd}" " else MSG="${MSG} Virtual Machine Stats: "${cmd}" " fi $XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG} " done rm "/tmp/${vmshortname}_vminfo" exit 0 EOL sudo chown xymon:xymon "/usr/lib/xymon/client/ext/${vmshortname}_vminfo.sh" sudo chmod 500 "/usr/lib/xymon/client/ext/${vmshortname}_vminfo.sh" sed -i "/^${vmip}/ s/$/ ${vmshortname}_vminfo delaypurple=vm_info:75/" /etc/xymon/hosts.cfg /usr/lib/xymon/client/bin/xymoncmd "/usr/lib/xymon/client/ext/${vmshortname}_vminfo.sh"