About
You arrived at the weblog of Geert Baeke. I am a technology consultant for a company called Xylos (Belgium). I mostly work with Microsoft technologies such as Windows, Active Directory, Exchange, Sharepoint, MSCS, and more. I am also actively busy with VMware's products, focussing on VMware ESX.

Sections
Search






XBOX 360

RSS Newsfeeds
baeke.info Main RSS Feed Main Page RSS
View Article  Quick Tip: using vmware-cmd with multiple virtual machines

The vmware-cmd.pl script is a standard script you can run on the ESX console to do stuff with virtual machines from the command line. For example, to stop a virtual machine, you can use:

vmware.cmd <path_to_vmx> stop

Above, <path_to_vmx> is the path to a virtual machine's vmx file (configuration file) like /vmfs/volumes/vmfs02/vm007/vm007.vmx.

What if you want to stop all the virtual machines on an ESX server or just a subset? In that case, do the following from the command line (one line):

vmware.cmd -l | while read vmxpath; do vmware-cmd $vmxpath stop; done

If you want to do some filtering, you can do something like this:

vmware.cmd -l | grep labsrv | while read vmxpath; do vmware-cmd $vmxpath stop; done

The above command will only perform the stop operations on virtual machines that have labsrv in the vmx filepath.

View Article  PowerShell support in Virtual Machine Manager

Jeffrey Snover wrote an interesting article for the Windows PowerShell blog about PowerShell functionality in System Center Virtual Machine Manager (SCVMM). In it, he compares a shell script to disconnect virtual media from virtual machines to a few PowerShell cmdlets to do the same thing.

Indeed, when you compare the scripts, there is no doubt that it is much easier in PowerShell. But to be fair, you don't have to write such a script using bash shell scripting and vmware-cmd.pl. You can also do it using pure Perl or with the COM API from VBScript or .NET. With VBScript and the COM API, it would be much simpler.

Of course, nothing beats the simplicity of these cmdlets. This has already been demonstrated by Exchange Server 2007 and its cmdlets where they replace tedious scripting with VBScript.

View Article  Release: vizioncore esxRanger 3.0 Professional

vizioncore have released esxRanger 3.0 Professional. This newest version of their backup software for ESX integrates nicely with VMware Consolidated Backup (VCB) to give you the highest backup speed possible. By leveraging the VCB framework, esxRanger can use the backup server's fiber connection to access the virtual machine disk files.

For a full and clear explanation, they have written a whitepaper. Get it here.

View Article  Combining the VI3 Perl Toolkit, PowerShell and PowerGadgets

Earlier I blogged about scripting with the VI3 Perl toolkit. The toolkit makes it relatively easy to get information from VI3. In reality, I do not want to spend a lot of time writing Perl scripts, especially with the availability of PowerShell.

In PowerShell, it is easy to work with the information you retrieve. For example, if you would like to get a list of running processes with sorts and filters you do something like this:

ps | where {$_.processname -like "a*"} | sort WS -desc

The above command gets a list of processes that start with the letter a and then performs a descending sort on the working set of each process.

We will do something similar with information obtained from VirtualCenter. We will get information about disk space usage in each of the virtual machines belonging to a datacenter. Because I do not know of a way to do this directly from PowerShell, a Perl script will be used that sends the data to a PowerShell script.

In short, the steps are:

  1. Write a Perl script with the VI3 Perl Toolkit to connect to VirtualCenter, get all virtual machines in the datacenter and get disk space information from the virtual machines. Output this information to the screen.
  2. Write a PowerShell script to get the output from the Perl script and create custom objects so that you can apply filters and sorts to the dataset.

WARNING: code written by a non-programmer below :-)

The Perl script

As discussed in the previous post, you will need Perl (http://www.activestate.com) and the VI3 Perl Toolkit. Thanks to this example it was easy to write the script. It looks like this:

use strict;
use warnings;
use VMware::VIRuntime;

Vim::login(service_url => "https://server/sdk/vimService", user_name => "user", password => "password");

my $dc = Vim::find_entity_view(view_type => "Datacenter", filter => {'name' => 'dcname'} );

my $vms = Vim::find_entity_views(view_type => "VirtualMachine", begin_entity => $dc, filter => { 'guest.guestState' => 'running', 'guest.toolsStatus' => 'toolsOk' } );

foreach my $thisVM (@$vms) {
my $count=0;
while ($thisVM->guest->disk->[$count]) {
print $thisVM->name . ","
print $thisVM->guest->disk->[$count]->diskPath . ","
print $thisVM->guest->disk->[$count]->capacity / (1024*1024) . ","
print $thisVM->guest->disk->[$count]->freeSpace / (1024*1024) . "\n"
$count++;
}
}

 

The output of the script is something like:

server1,C:\,8000,1234
server1,D:\,4500,3500

So the format is: servername, driveletter, capacity and free space.

The PowerShell script

For this, you need the .NET Framework 2 or higher and PowerShell 1.0. The script is:

$a=perl c:\diskfree.pl

$a | foreach {
 $b=$_.split(",")
 $server=$b[0]
 $disk=$b[1]
 $capacity=[int]$b[2]
 $free=[int]$b[3]
 $percfree=$free / $capacity 
 new-object psobject |
  add-member -pass NoteProperty Server $server |
  add-member -pass NoteProperty Disk $disk |
  add-member -pass NoteProperty Capacity $capacity |
  add-member -pass NoteProperty Free $free |
  add-member -pass NoteProperty PercFree $percfree }

With PowerShell, It is very easy to grab the output of a command. The first line ($a=perl c:\diskfree.pl) executes the Perl script and saves the output in $a. After that, each line in $a is split on the comma so we can get the servername, driveletter, capacity and free space.

The nice thing is that you can create your own object with new-object and attach custom properties to it. This is done to allow the sorting and grouping I talked about earlier. I also added the percentage of free space.

I saved the PowerShell script as c:\diskfree.ps1. When I run it, it outputs data is list format but with the following command:

c:\diskfree.ps1 | ft -autosize

you get something like:

Now you can do all sorts of things. For example, to get only information about the C:\ disk and to do some sorting:

C:\diskfree.ps1 | where {$_.Disk -eq "C:\"} | sort capacity -desc | ft -AutoSize

The above command results in:

Now for some fun stuff. With PowerGadgets (not free), you can even get this data in a chart easily. This command does the trick:

C:\diskfree.ps1 | where {$_.Disk -eq "C:\"} | sort capacity,free -desc | out-chart -Label Server
-Values Capacity,Free -Title "Free space"


The result is:

I hope you found this useful and that you can use this information to do some quick and dirty monitoring and reporting on VI3.

View Article  Scripting with the VI3 Perl Toolkit

For a project we are doing, we needed a script that gets a list of all virtual machines belonging to a specific datacenter object. At first we tried to do it in .NET with C#. However, because of the complexity of the object model, we quickly had to turn to something else.

The VI3 Perl Toolkit turned out to be much, much simpler. After installing ActivePerl on Windows, we installed the toolkit following the instructions on the website. According to the instructions, you have to use ppm (Perl Package Manager) to download some additional packages that the VI3 Perl Toolkit needs. If you use a proxy server, first set an environment variable with proxy settings before you run ppm. For example:

set http_proxy=http://username:password@proxyserver:proxyport

The VI3 Perl Toolkit contains a guide in HTML format and some samples to get you started. From that guide, we quickly made the script we needed. It looks something like this:

use strict;
use warnings;
use VMware::VIRuntime;

Vim::login(service_url => https://virtualcenter/sdk/vimService, user_name => "user", password => "password");

my $dc = Vim::find_entity_view(view_type => "Datacenter", filter => {'name' => 'datacentername'} );

my $vms = Vim::find_entity_views(view_type => "VirtualMachine", begin_entity => $dc);

foreach (@$vms) {
print "Name: " . $_->name . "\n"
}

I think the code is pretty self-explanatory and very simple, even if you don't know Perl.  Vim::login connects to the VirtualCenter web service using https. Then, a reference to the datacenter is retrieved (find_entity_view) and saved in the $dc variable. After that, all the virtual machines in that datacenter are retrieved (find_entity_views) and printed on screen.

One thing to note is that the toolkit does not have issues with non-trusted certificates. We use these default certifates in our test environment.

If you are not a developer and you need some quick scripts to do stuff with VI3, I recommend you use the VI3 Perlkit instead of trying it with .NET.

(Quick note to VMware: you should make it simpler to script VI3 using Windows tools in a supported way. It should be easy to access VI3 using mainstream tools that Windows administrators are accustomed to. With that I mean tools such as COM and VBScript. Or make simpler .NET classes so that we can use them easily in Visual Studio or even PowerShell.)

View Article  PowerShell 1.0 on Vista RTM

I am playing around with PowerShell and wanted to install it on Vista RTM. As you might have heard, there is no installer yet for Vista RTM. It should be available around the end of the month.

There are some workarounds to get it to work, and this one works. Not supported of course, but good enough if you just want to play with it.

View Article  Xbox 360 as a media extender

A while ago, I bought an Xbox 360. I actually bought it in Barcelona during ITForum 2006 because I did not win one from the Windows Server Virtualization guys during one of their contests. Maybe for the better because they gave away Xbox 360 Core and I really wanted a Premium version.

Anyway, the Xbox 360 can also be used as a Media Center Extender. Because I run Windows Vista Ultimate on my laptop, I can use it with that.

Technically, it all works but there are some serious issues with Xbox 360 as an extender. First of all, the Xbox is way to noisy. Compared to my Pinnacle ShowCenter 200, which is completely silent, it does not stand a chance. Secondly, and even more annoying, is the fact that the Xbox does not support streaming DivX and Xvid to it. There are some solutions to fix that and one of those with support for Vista is Transcode 360. It is still in beta but I tried it and it works fine.

Be aware of the fact that a solution like Transcode 360 actually converts the video from DivX/Xvid format to a format that the Xbox understands. On my laptop (HP nw8000) this results in 70%-90% CPU load. When you stop watching a transcoded video on the Xbox, the transcoding process keeps running on the media center. You need to kill that with Task Manager to stop it.

For these two reasons (noise and lack of DivX/Xvid support), it will not replace my ShowCenter any time soon.

View Article  January TechNet Magazine about SharePoint

This month's TechNet magazine is devoted to SharePoint. You will find an overview article, information about security features, search and command line administration.

Check it out here.

 

Login
User name:
Password:
Remember me 
This Month
January 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Networking
View Geert Baeke's profile on LinkedIn

Services

Powered by BlogHarbor
Powered by BlogHarbor
StatCounter