WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Uncategorized / Identifying Idle vCenter Sessions

Identifying Idle vCenter Sessions

12.20.2011 by William Lam // 4 Comments

I recently received a question on how to identify idle vCenter sessions that may stem from a non-active vSphere Client or vSphere API connection. Properly managing sessions to your vCenter Server is as important as knowing who is logging in. If you exhaust the maximum number of connections, you can easily deny login access to other users and/or services that are needed to connect to vCenter Server which can lead to very bad things. In the worse case, you can even prevent administrators from logging into a new session to help terminate any stale/idle connections.

The vSphere API provides a sessionManagement manager to help you manage all sessions, including checking whether a session is still active and terminating a session. I wrote a quick vSphere SDK for Perl script called sessionManagement.pl which allows you to list all sessions for a given vCenter and terminating a a specific session. Every session has a unique sessionKey that the vCenter Server uses to track and it provides information such username, login time and last active which can be used to create an unattended script to automatically terminate sessions that have gone beyond a certain threshold.

Here is an example script output of performing the "list" operation:

Note: There maybe vCenter Plugins/Extensions that creates sessions such as CapacityIQ, those will be denoted by "vCenter Ext Session" field. These should not be terminated as it can negatively impact 3rd party applications.

Here is an example script output of terminating a specific session using the "disconnect" operation which you will need to specify sessionkey provided in the previous command:

For those of you that are interested in creating your own script to terminate idle sessions, you can use the DateTime Perl module to help with calculating the amount of idle time and comparing that to a pre-defined timeout value.

More from my site

  • An update on how to retrieve useful information from a vSphere login?
  • Do I need to install both the vSphere CLI & vSphere SDK for Perl?
  • Automate Enabling VM Storage Profiles Capability in vSphere
  • Automating VCSA Network Configurations For Greenfield Deployments
  • Retrieving vscsiStats Using the vSphere 5.1 API
Share this...
  • Twitter
  • Facebook
  • Linkedin
  • Reddit
  • Pinterest

Categories // Uncategorized Tags // idle, session, vsphere sdk for perl

Comments

  1. Gregg says

    05/18/2012 at 9:21 am

    Hi,

    I get the following error when executing:

    Undefined subroutine &UserSession::extensionSession called at sessionManagement.pl line 75

    Gregg

    Reply
    • William says

      05/18/2012 at 3:26 pm

      @Gregg,

      The extensionSession property is only available in vSphere 5, I assume you're most likely connecting to a non-vSphere 5 environment. You can still leverage the script, but you'll need to comment out line #75 which will not print the "vCenter Ext Session"

      Reply
  2. Gregg says

    05/24/2012 at 10:52 am

    Hi,

    Thanks, works like a charm - Really, really useful script!!!

    Thanks again
    Gregg

    Reply

Trackbacks

  1. Capacityiq Login - login link says:
    04/06/2021 at 1:10 pm

    […] Identifying Idle vCenter Sessions – virtuallyGhetto […]

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Support

Recent

  • Using the new vSphere Guest OS Customization with cloud-init in vSphere 7.0 Update 3 06/27/2022
  • How to forcefully disconnect a vSphere VM Console session? 06/24/2022
  • Quick Tip - Using ESXi Scripted Installation (kickstart) to configure IPv6 networking 06/21/2022
  • Hiking Trails 06/04/2022
  • 2022 VMUG Advantage Community Group Buy 06/01/2022

Advertisment

Copyright WilliamLam.com © 2022