Clean up idle sessions

Here we go again, another quick workflow that came out of the desire to clean up idle session on my vCenter servers.

The premise is pretty simple, loop over a list of vCenter servers and find any connections that have been idle over X minutes and terminate them.

I realized pretty quickly that I have to be careful to not terminate sessions for things like Site Recovery Manager, vCloud Director, Update Manager, etc. so I built in a whitelist that leaves those accounts alone.

As far as the code it is pretty straight forward, start with a loop that loops over all the vCenters and then another loop that loops over the sessions to that vCenter:

Then we filter out the ones that we do not want to terminate:

For the ones that are left, we calculate how long the sessions have been idle.

Then we kill the ones that have been idle for too long.

There is not a whole lot more to say about this one, it should be pretty straight forward.

Download the package here.

2 thoughts on “Clean up idle sessions

  1. Great post! There are a lot of idle session killer scripts running out there, but having it in VCO as a scheduled workflow is a great way to consolidate these types of operational automation workflows into a central solution.

    Thanks for sharing the solution!

  2. Pingback: vCenter Orchestrator Workflow for old snapshots removal | VirtCode

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">