We did two live demos as part of VI Toolkit’s breakout session at VMworld Europe 2009. This post is about the first demo which featured some network configuration monitoring and Carter’s cell phone beeping loudly when he received the alert emails…
So, you’re a VI system administrator and you have a policy that no VM can be simultaneously connected to the Intranet and the DMZ. With all the configuration changes going on, it would be nice if a script could monitor the network and drop you an email when some change breaks the policy.
With VI Toolkit stuff like this is pretty easy. How about getting all VMs and then examining each one’s network configuration? Sounds about right but it could be a bit slow if you have a large number of VMs. Let’s tweak it a bit by first looking at the Virtual Center’s even log. Filter only events which show that a VM’s network was reconfigured. Then go check only those VMs.
You want a script which runs the check repeatedly until you stop it. So, each time, it needs to look only at the events, created since the last check. And with PowerShell’s native access to .Net library, sending email is a piece of cake.
Finally, here’s the script itself (you need to be connected before you run it):