Jul 062009
 

The other day I was installing kernel updates on a few of my Red Hat servers and I ran into a minor nuisance.  After each reboot, I no longer had network connectivity on the hosts, that has the updated kernel. I then realized, that vmware-tools was not running on all of those hosts. So after a few manual instance of me running "vmware-tools-config.pl -d" and "/etc/init.d/network restart"….I decided to automate that, by adding the below into "/etc/rc.local"

rkernel=`uname -r`
if [ -e /etc/vmware-tools/not_configured ]; then
echo "vmware-tools not configured for running kernel $rkernel"
echo "running vmware-config-tools.pl"
/usr/bin/vmware-config-tools.pl -d
echo "vmware-tools now compiled for running kernel $rkernel"
echo "restarting networking"
/etc/init.d/network restart
echo "network restarted"
exit 0
fi
 

 After each host rebooted, I now had network connectivity and vmware-tools was running. I hope the above will save you some time.

Apr 012009
 

The other day I was told to check and see if VMware Tools was installed on every Virtual Machine in our Cluster. I figured this was the perfect time for me to write another script to do this.

Here are a list of things that I want to have in the script…

  • List all Virtual Machines and the VMstatus and Version if installed
  • Check for toolsOK
  • Check for toolsNotInstalled
  • Check for toolsNotRunning
  • Check for toolsOld
  • And last but not least, able to do this either on a per Virtual Machine or on the entire Cluster

Well I was able to do all of the above in a nice Perl Script that I created. It can be downloaded here  vmToolsStatus.pl

{quickdown:36}
perl vmToolsStatus.pl
help : Hiding the command line arguments [--help]
--toolsOld : This will print out all the Virtual Machines with an Old version of vmTools and you need to upgrade
--toolsNotInstalled : This will print out all the Virtual Machines with vmTools Not Installed
--toolsNotRunning : This will print out all the Virtual Machines with vmTools Not Running
--toolsOk : This will print out all Virtual Machines with vmTools running
--all : This will print out all Virtual Machines with vmTools installed or not installed
example : Hiding the command line arguments --toolsOld
example : Hiding the command line arguments --toolsOk
example : Hiding the command line arguments --toolsNotInstalled
example : Hiding the command line arguments --toolsRunning
example : Hiding the command line arguments --all --vm_name "vm_name"
example : Hiding the command line arguments --all  
Remember!!! That in order to use this script you will need the Perl VI SDK installed on your linux box as well as $home/.visdkrc setup correctly

Here is an example .visdkrc…

VI_SERVER = Virtual Console Server
VI_USERNAME = login
VI_PASSWORD = passwd
VI_PROTOCOL = https
VI_PORTNUMBER = 443

 

Continue reading “How to check the status of VMware Tools per virtual Machine the easy way.” »

Mar 312009
 

This is the 3rd and I think final revision of this script. I added the –list function, which before had to be combined with the –vm_name function. The main reason for creating this script was so that there can be an easy way to manage snapshots, especially automating the deletion, creation, reverting, and listing of snapshots. If you find this script or any of my scripts useful, please let me know.

 

perl vm_snapshot.pl --list
Platinum
name: test1
description:
state: poweredOff
vm type: VirtualMachine
time created: 2009-03-17T10:26:34.605171-04:00

Gold
name: test2
description:
state: poweredOff
vm type: VirtualMachine
time created: 2009-03-17T13:32:05Z

Silver
name: test3
description:
state: poweredOff
vm type: VirtualMachine
time created: 2009-03-17T13:32:22Z 

Remember!!! That in order to use this script you will need the Perl VI SDK installed on your linux box as well as $home/.visdkrc setup correctly

Here is an example .visdkrc…

VI_SERVER = Virtual Console Server
VI_USERNAME = login
VI_PASSWORD = passwd
VI_PROTOCOL = https
VI_PORTNUMBER = 443

Continue reading “VMware ESX SDK SnapShot Perl Script Part 3” »

Mar 312009
 

Welcome to part 2 of the “HowTo List Virtual Machines using Python and CIM“. In this part, I modified the original script so that you can pass the Virtual Machine name as well as run it with out the Virtual Machine name. In the first part of this HowTO I created the listVMsInfo.py script witch just listed all the Virtual Machines. So please enjoy the script and hopefully it will make your life just a bit easier.

python listVMsInfo.py -u "http://esxhost" -a "login passwd" -n "testVM"
VM Name 		 testVM
Operating System 	 Suse Linux Enterprise Server 10 (32-bit)
Host Name 		 None
IP Address 		 None
DataStore Used 		 [Esxtestvol] testVM.vmxRequested
State 	 Not ApplicableOperational
Status 	 Enabled
Enabled by Default 	 Enabled
Enabled State 		 Not Applicable

Download this script here!
Download

Mar 252009
 

Good Afternoon guys, here I created another Python Script. This script will check your DataStores aka VMFS. I built this script so that it can be used with Nagios and or Zenoss. The purpose of this script is so that you can monitor thresholds on a per DataStore/VMFS. You will need to download and install Pywbem in order to use this script. You can get it here
Example below…

        example below...
python check_datastore.py -u "http://esxhost" -a "login passwd" --d "Esxtestvol2" -w 60 -c 73 -m GB
Warning Esxtestvol2 189GB Avail 62% used |avail=189

python check_datastore.py -u "http://esxhost" -a "login passwd" --d "Esxtestvol2" -w 70 -c 85 -m MB
OK Esxtestvol2 194558MB Avail 61% used |avail=194558

python check_datastore.py -u "http://esxhost" -a "login passwd" --d "ISO" -w 10 -c 21 -m KB
Critical ISO 41867542528KB Avail 21% used |avail=41867542528

python check_datastore.py -u "http://esxhost" -a "login passwd" --d "Esxtestvol2" -w 70 -c 85
OK Esxtestvol2 204008849408bytes Avail 61% used |avail=204008849408

-u, --url This is the URL you will use to connect to the ESX server, "http://esxhost"
-a, --auth This is the Login and Passwd you will use, "login passwd"
-d, --dstore This is the DataStore aka VMFS to check, "Esxtestvol2"
-w, --warn This is the warning threshold that you will set, 70
-c, --crit This is the critical threshold that you will set, 85
-m, --metric This is the metric that you will use, "KB", "MB", "GB", The default is Bytes

You can download this script here check_datastore.py

Mar 242009
 

Here I created another Python script using Pywbem to get the Storage Pools from ESX.
In this script you can get the disk utilisation statistics from each datastore or from a particular datastore.
Script Updated to include the .VMX files that belong to each DataStore..


example below…
python VMdataStorePool.py -u “http://esxhost” -a “login passwd”
Available DataStores on http://esxhost

DataStore Name                   Esxtestvol2
Total Disk Space                 499G
Remaining Disk Space             189G
Used Disk Space                  310G
Percentage Used                  62%
VMX files that belong to this DataStore::
[Esxtestvol2] Win2003test3/Win2003test3.vmx
[Esxtestvol2] netwaretest/netwaretest.vmx
[Esxtestvol2] RHEL 4 NFS test/RHEL 4 NFS test.vmx
[Esxtestvol2] RHEL 5 NFS test/RHEL 5 NFS test.vmx
[Esxtestvol2] RHEL 3 NFS test/RHEL 3 NFS test.vmx
[Esxtestvol2] vicfg/vicfg.vmx

DataStore Name                   ISO
Total Disk Space                 49G
Remaining Disk Space             38G
Used Disk Space                  11G
Percentage Used                  22%
VMX files that belong to this DataStore::
None Exist

python VMdataStorePool.py -u “http://esxhost” -a “login passwd” –dstore=”KodakVol1″
Available DataStores on http://esxhost

DataStore Name                   KodakVol1
Total Disk Space                 499G
Remaining Disk Space             379G
Used Disk Space                  120G
Percentage Used                  24%
VMX files that belong to this DataStore::
[KodakVol1] Kojak/Kojak.vmx
[KodakVol1] Sakai/Sakai.vmx
[KodakVol1] bbtest2.vmx
[KodakVol1] bbtest.vmx

-u, –url       This is the URL you will use to connect to the ESX server, “http://esxhost”
-a, –auth      This is the Login and Passwd you will use, “login passwd”
-d, –dstore    This is the DataStore aka VMFS to check, “Esxtestvol2″

 

Mar 242009
 

Good morning my fellow Admins, Engineers, Scripters, Programmers, etc….. YOU GET THE IDEA :) . For the past week, I have been learning all about the CIM and WBEM API. Since I am working alot more then I have ever have with VMware. I am trying to automate as much as possible with out using Perl. Now please do not think I am hating on Perl, it is not that at all, it is just the fact that I love Python, thats all! That being said here is the 1st part in a 2 part series on Listing Virtual Machines using Pywbem in Python. I the 1st part I will show you how to list Virtual Machines and data related to those VMs. Example Below…

Update, here is the link for part 2 of this article.

    python listVMsInfo.py -u "http://esxhost" -a "login passwd"

    VM Name                  Linux DP1 Client     Operating System         Red Hat Enterprise Linux 5 (32-bit)    Host Name                dpclient.linuxdynasty    IP Address               192.168.101.124    DataStore Used           [Esxlinuxvol2] Linux Data Protector Install Ser/Linux Data Protector Install Ser.vmx    Requested State          Not Applicable    Operational Status       Enabled    Enabled by Default       Enabled    Enabled State            Not Applicable

Continue reading “HowTo List Virtual Machines using Python and CIM Part 1” »

Jul 292008
 

And here we go again another VMware Perl Script… This has been like an evolution of my previous scripts.. :) Except this Perl CGI Script uses my ESX Perl Module ESX_VM.pm. This script will give you an Idea on how to use my ESX_VM.pm. You can also use this script with the ESX_VM.pm for your current environment.

Continue reading “VMWare Perl CGI Script” »

Jul 012008
 

Another
Perl SDK Script for VMware ESX 3.+. This is essentially my first 2 (part 1 and part 2) ESX Perl scripts modified into 1 and converted into a CGI. If  you have been using my scripts and they have helped you please leave a comment.

This script assumes you have the VMware
Infrastructure (VI) Perl Toolkit Packages installed and your
$HOME/.visdkrc set correctly. Without the above the script below will
not work!! 

Continue reading “VMware ESX SDK SnapShot CGI Perl Script” »


Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.