VMware Cloud Community
joshuatownsend
Enthusiast
Enthusiast

Guest Downtime / Underutilization Report

I am setting up a cold storage array (bunch-o-SATA disks) on my SAN for under-utilized VM's. I want the setup to work like this: If a VM has not been powered-on for n[/i] days, it will be moved to the ice box until it is needed again or reaches the deletion time of x[/i] days. This will free up my faster FC disks for a real workload.

My question is this: how do you find the 'downtime' of your guest VM's - either through VC or ESX - that is, display the last time the server was running and/or shutdown.

Secondary would be finding under-utilized machines (anything guest without a load) and report on that.

I don't need a mechanism to move to the VM's at this time - just a decent way to report on non/under-utilized VMs (but I'll take one if you have it)

I am working with a few hundred VM's so the solution should be programatic.

Thanks,

Josh

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful". Please visit http://vmtoday.com for News, Views and Virtualization How-To's Follow me on Twitter - @joshuatownsend
0 Kudos
9 Replies
badazws6
Enthusiast
Enthusiast

What OS are your VM's? If they are Windows are they in an AD domain? I have written scripts before to query the AD for a last login date of a computer account...

joshuatownsend
Enthusiast
Enthusiast

They are 95% Windows boxes.

Problem is, you can't query a powered-off guest for, well, anything. And current power state is not indiciative of power state history (having been powered off for n days).

I certainly can use WMI to query for utilization of windows guests for the machines that are powered on.

Solution is probably within VC performance metrics or reading guest tasks out of VC DB for power state changes and applying a little logic to the results (If power-off date is more than n days, report as unused).

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful". Please visit http://vmtoday.com for News, Views and Virtualization How-To's Follow me on Twitter - @joshuatownsend
0 Kudos
badazws6
Enthusiast
Enthusiast

I'm suggesting you write a script that query's a domain controller. In the AD there is a field that keeps track of when the last time a computer account logged in or contacted a DC. You do not need to query the powered off VM at all. In fact this solution has nothing to do with ESX or the VM, it is all windows based. Basically your asking your AD how long it has been since it saw that computer account last.

In a former life I wrote a script that went out and looked for unused computer accounts in the AD and then either logged it or just plain deleted the account. Assuming you have named your VM instance the same as the host name in Windows it is a one-to-one relationship.

0 Kudos
RParker
Immortal
Immortal

The downtime is easy, last update on the date of the *.vmdk file is how I check for when the files were last used.

The hard part for me is similar to what you are doing, which is to figure which VM's are not be utilized..

0 Kudos
RParker
Immortal
Immortal

I will PAY for this script. Please send me any and all info regarding this info, please! This would be most helpful.

I found a set of utilities that would query this info (but not the AD, individual machines). The AD would be much better..

Is is VB script?

0 Kudos
badazws6
Enthusiast
Enthusiast

No it wasn't a VB script I was using winbatch, are you familiar with it? I know someone that did do it in VB so it is possible. Let me see what I can dig up.

0 Kudos
RParker
Immortal
Immortal

Sweet you da man! Seriously, I will donate to your time.

0 Kudos
badazws6
Enthusiast
Enthusiast

That was in a past life, I don't have the scripts anymore, sorry. If you are familiar with Winbatch (?) I found a couple of scripts that should give you a starting point.

This first one is a script that finds if an AD user account is disabled. It will work with computer accounts also. You should be able to modify the dsGetProperty function in this script to look for something like time sense last logged in or something along those lines. The 2nd function I think will get you the available properties of the account. Please forgive me, it has been 3-4 years since I looked at this last. If you are more familiar with VB I know you can do something along the same lines.

The following where taken from: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/techsupt.web

; The tech db article is saying do the following and

; it gets a list of all disabled users.

AddExtender("wwads44i.dll")

; Search the domain.

; Note: server name used here (shamrock) but not necessary

; if computer joined to the domain.

sDomain = "LDAP://shamrock/dc=jclass,dc=org"

; Disabled accounts have the second bit (2) of the

; userAccountControl property set.

sFilter = "(&(objectCategory=person)(objectClass=person)(userAccountControl:1.2.840.113556.1.4.803:=2))"

lDisabled = dsFindPath(sDomain, sFilter)

Message("Disabled users", lDisabled)

; To get the status of known user account

; check the bit directly.

sUser = "LDAP://shamrock/cn=Homer Simpson,cn=users,dc=jclass,dc=org"

nStatus = dsGetProperty(sUser, "userAccountControl")

If nStatus & 2 ; Note: bitwise AND

sText = "Is disabled"

Else

sText = "Is enabled"

EndIf

Message(sUser, sText)

;From: Crypt

;Date: Friday, February 07, 2003 04:14 PM

;

;This is a modification to a previously published script. It will

;return all of the attributes that you can populate on an AD user

;account. You will still have to figure out what the field they

;display in or what they are exactly. Eventually I'll have a list

;of what they're associated with.

;

;1. Set the login name

;2. Change the LDAP path to a valid one in your environment.

;

;----


AddExtender("WWADS44I.DLL")

; Set credentials.

Account="mrenselda"

pwd=AskPassword ("Password", "Enter the Password for %Account%")

a=dsSetCredent(Account, pwd)

; Define some constants.

MANDATORY = 1

OTIONAL = 2

MANANDOPT = 3

; An Active Directory example.

; The user object "Russ T Gate" on the "win2000" server.

; Make sure the following on one line

sAdsiPath = "LDAP://win2000/CN=Russ T Gate,CN=Users,DC=win2000,DC=peakresources,DC=com"

Output=FileOpen("C:\temp\out.csv","WRITE")

FileWrite(Output,"Type,Property Name,Value")

; Get mandatory properties of object.

sList = dsGetPropName(sAdsiPath, MANDATORY)

If sList != ""

count=ItemCount(sList,@TAB)

For x=1 To count

item=ItemExtract(x,sList,@TAB)

val=dsGetProperty(sAdsiPath, item)

FileWrite(Output,"MANDATORY,%item%,%val%")

Next

EndIf

; Get optional properties of object.

sList = dsGetPropName(sAdsiPath, OTIONAL)

If sList != ""

count=ItemCount(sList,@TAB)

For x=1 To count

item=ItemExtract(x,sList,@TAB)

val=dsGetProperty(sAdsiPath, item)

Data=StrCat("OPTIONAL",",",item,",",val)

FileWrite(Output,Data)

Next

EndIf

; Get all properties of object.

;sList = dsGetPropName(sAdsiPath, MANANDOPT )

;if sList != ""

; sList = strreplace(sList,@TAB, @CRLF)

; message("All Property names. ", sList)

; FileWrite(Output," ")

;FileWrite(Output," ")

;FileWrite(Output,"All Property names. ")

;FileWrite(Output,"----


")

;FileWrite(Output,sList)

;endif

FileClose(Output)

Run("Excel.exe","C:\temp\out.csv")

0 Kudos
RParker
Immortal
Immortal

OK, these will give me a good start.

thanks for your help.

0 Kudos