VMware Cloud Community
inglenin
Contributor
Contributor

How to get the list of the last log session VMs of a datacenter?

Hi everybody

We have a datacenter with more than 1000 vms in our v-center. we need to get the access logs of the last 90 days for each VM. Does anybody know the way to do it from Vcenter?

I hope you can help me

Thanks

Lenin R.

10 Replies
LeslieBNS9
Enthusiast
Enthusiast

Are you referring to anyone who access the console of the VM?

Reply
0 Kudos
LeslieBNS9
Enthusiast
Enthusiast

If you ONLY want console access information. Then you can run this query directly on the database....

select* from vpxv_events WHERE event_type = 'vim.event.VmAcquiredTicketEvent'

Keep in mind the date/time stamps don't account for timezone so you may need to do a little math there.

If you have the vCenter appliance this blog post explains how to gain access to the database... How to Hack vCenter Database in vCSA Appliance | DoubleCloud => Private Cloud + Public Cloud

inglenin
Contributor
Contributor

Hi Leslie

Yes, I need to know which was the last access logs each console, to debug VMs are not using for a long time...  Can I get this in vcenter client?

Thanks

Reply
0 Kudos
Anjani_Kumar
Commander
Commander

I created this script for my vcenter servers. to check the logon. hope it can help you atleast 90%.

Please consider marking this answer "correct" or "helpful" if you found it useful. Anjani Kumar | VMware vExpert 2014-2015-2016 | Infrastructure Specialist Twitter : @anjaniyadav85 Website : http://www.Vmwareminds.com
LeslieBNS9
Enthusiast
Enthusiast

You can but you have to go to each server individually, go to the Events area and search for mks. This also may not display back 90 days. Anjani_Kumar's script will tell you the last logged on time of your specified servers, but not who and doesn't give a history.

inglenin
Contributor
Contributor

Thanks Leslie,I will execute the script you gave me, and will let you know the test results.

Best regards.

Reply
0 Kudos
inglenin
Contributor
Contributor

Thanks Anjani,

I will execute the script you gave me, and will let you know the test results.

Best regards.

Reply
0 Kudos
LeslieBNS9
Enthusiast
Enthusiast

Sounds good.  Keep in mind that script will tell you who opened the console on VMs, not whether they logged in or not. It also won't tell you the details if anyone logged into the server through other means (i.e. RDP).

Reply
0 Kudos
Prakas
Enthusiast
Enthusiast

If you are looking to get the list of users who accessed the VM console, I've developed a small PowerCLI script which can be useful to you.

You can find the script in my blog here. Also I am attaching a copy of it.

inglenin
Contributor
Contributor

Hi PrakasPrakash

This script works for users who access the virtual machine from the View client?

Thanks

Reply
0 Kudos