[vi-admin@rafaeli ~]$ ./vmwarevSphereHealthCheck.pl
Required command option 'type' not specified.
Synopsis: ./vmwarevSphereHealthCheck.pl OPTIONS
Command-specific options:
--cluster
The name of a vCenter cluster
--datacenter
The name of a vCenter datacenter
--logcount
The number of lines to output from hostd logs
--report
The name of the report to output. Please add ".html" extension
--type (required)
Type: [vcenter|datacenter|cluster|host|detail-hosts]
Common VI options:
--config (variable VI_CONFIG)
Location of the VI Perl configuration file
--credstore (variable VI_CREDSTORE)
Name of the credential store file defaults to <HOME>/.vmware/credstore/vicredentials.xml on Linux and <APPDATA>/VMware/credstore/vicredentials.xml on Windows
--encoding (variable VI_ENCODING, default 'utf8')
Encoding: utf8, cp936 (Simplified Chinese), iso-8859-1 (German), shiftjis (Japanese)
--help
Display usage information for the script
--passthroughauth (variable VI_PASSTHROUGHAUTH)
Attempt to use pass-through authentication
--passthroughauthpackage (variable VI_PASSTHROUGHAUTHPACKAGE, default 'Negotiate')
Pass-through authentication negotiation package
--password (variable VI_PASSWORD)
Password
--portnumber (variable VI_PORTNUMBER)
Port used to connect to server
--protocol (variable VI_PROTOCOL, default 'https')
Protocol used to connect to server
--savesessionfile (variable VI_SAVESESSIONFILE)
File to save session ID/cookie to utilize
--server (variable VI_SERVER, default 'localhost')
VI server to connect to. Required if url is not present
--servicepath (variable VI_SERVICEPATH, default '/sdk/webService')
Service path used to connect to server
--sessionfile (variable VI_SESSIONFILE)
File containing session ID/cookie to utilize
--url (variable VI_URL)
VI SDK URL to connect to. Required if server is not present
--username (variable VI_USERNAME)
Username
--verbose (variable VI_VERBOSE)
Display additional debugging information
--version
Display version information for the script
./vmwarevSphereHealthCheck.pl --server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type vcenter
./vmwarevSphereHealthCheck.pl --server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type datacenter --datacenter DATACENTER_NAME
./vmwarevSphereHealthCheck.pl --server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type cluster --cluster CLUSTER_NAME
./vmwarevSphereHealthCheck.pl --server ESX_ESXi_SERVER --username ESX_ESXi_USERNAME --password ESX_ESXi_PASSWORD --type host
./vmwarevSphereHealthCheck.pl -server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type detail-hosts
./vmwarevSphereHealthCheck.pl -server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type detail-hosts --logcount 20
./vmwarevSphereHealthCheck.pl -server VC_SERVER --username VC_USERNAME --password VC_PASSWORD --type vcenter --vmperforamnce 1
If you look at the requirements in the documentation you'll see one is for pre-vSphere and the other is for vSphere.
The relationship is the following:
VIMA 1.0 + ESX(i) 3.5u2+ = VMware Health Check Report v0.9.4
vMA 4.0 + ESX(i) 4.0+ = VMware vSphere Health Check Report v1.4.1
How to scheduler this report on daily basis and email it automatically?
Thanks in advance.
If you're launching it from a Windows box I would guess that you could do it as a couple of scheduled tasks (1> generate 2> email).
If you're doing it from the vMA it would be a cron job.
Maybe someone with direct experience will chime in, but examples of both should be on the interwebs.
What an awesome script! If anyone knows how to schedule this as a Scheduled Task in Windows 2008 please post it. It would help greatly!
@IPF - I've seen other scripts here that do this, I just don't recall which off top of my head. I'm sure a search will get you an answer...
I've got as far as creating a .bat file with the following:
START "C:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" "C:\Scripts\vmwarevSphereHealthCheck.pl" --server SERVER --username USERNAME --password PASSWORD --type vcenter"
When I run the .bat file it runs great. As a scheduled task...nothing happens. I've tried just the command in the scheduled task as well...nothing.
There has to be someone who has created a scheduled task? Anyone?
I so have to learn to copy my comments into my paste buffer before trying to hit submit on these sh*t forums... I lost a much longer post
Anyway -
Remove the "START"
Pass a "-- report" option - your command just send the output to null space
Start your task or specify your file output path as required or you'll be hunting for the result.
William - I use the vMA mostly, but am getting wonky results
"Can't use an undefined value as an ARRAY reference at ./vmwarevSphereHealthCheck.pl line 1114."
Please provide the exact syntax you're using with all the command line flags to help me better understand your issue.
Are you using vMA 4.0? and what is your environment like both vCenter and ESX(i) systems? build/versions?
Regarding line #1114, this refers to the following:
my $luns = $host->config->storageDevice->scsiLun;
foreach (sort {$a->canonicalName cmp $b->canonicalName} @$luns) {
Syntax (used on both my XP-based perl toolkit and the vMA):
vmwarevSphereHealthCheck.pl" --server 192.168.2.160 --username Administrator --password xxxxxx --type vcenter --report vCenter.html
The vMA:
With the information you've provided, here is what I'm thinking:
Is the vCenter fully managing all ESX(i) 4.0 hosts? If so, then the licensing server from VI3.5 might be what's causing the issue since the licensing portion of the API has significantly changed between VI and vSphere ... which could explain why it's off. If you don't for see needing the license server, can you try uninstalling and re-running the report to see if license output is fixed? This was one of the main reason I had two separate health check scripts for VI 3.5 and vSphere 4.0 due to the differences in the APIs.
Regarding the stand alone host, if it's not part of a vCenter cluster, it will not be caught by the script and that is a requirement. How is your ESX(i) host connected to your vCenter? Can you provide me with the inventory breakdown (e.g. hosta/b are in cluster1 and hostc is in cluster/etc?)
At present, yes, vCenter is managing 4.0 hosts only. Until only a couple days ago I maintained a 3.5 host. Customer requirement (I'm a working consultant by trade) will likely mean another 3.5 host sooner or later.
However, I can test with the licensing server off (is uninstalling really required?) I will say that I have a number of customers that will have both legacy and vSphere based licensing simply because of the upgrade process and internal requirement - I hope the script can be made happy by just killing the legacy service for a few ticks. I will test this tomorrow as time permits.
Yes - my one host is, at present, outside a cluster, and I thought I recalled that this was a limitation / requirement of the script. SO basically I have hast a & b in a cluster, and host c is "a loner". But again, this changes frequently as required.
William,
When I run the script with "--type host" and have SNMP enabled on the ESXi 4.0 Host, the script does not complete for me. :
C:\Program Files\VMware\VMware vSphere CLI\bin>vmwarevSphereHealthCheck.pl --ser
ver hq200-esx02 --username root --type host
Enter password:
Generating VMware vSphere Health Report 1.2 "vmware_health_report.html" ...
This can take a few minutes depending on environment size.
Get a cup of coffee/tea and check out http://www.engineering.ucsb.edu/~duonglt/v
mware/
Can't locate object method "commmunity" via package "HostSnmpDestination" at C:\
Program Files\VMware\VMware vSphere CLI\bin\vmwarevSphereHealthCheck.pl line 180
6, <STDIN> line 1.
End Disconnect
The issue ended up being a typo in one of the variables, I had an extra m in community which is why you saw the error message with not being able to locate the object. I did not have enough time to test SNMP section in VI3 version of the script: VMware Health Check Report v0.9.4 which was noted in the document and carried over to the vSphere version.
I've fixed the issue and actually re-did the output for the SNMP section and hopefully it'll be neater.
Thanks for the comments and try version 1.3 which has been uploaded and let me know if it resolves the issue.
I try to check my vCenter and I get this:
"Generating VMware vSphere Health Report 1.3 "vmware_health_report.html" ...
This can take a few minutes depending on environment size.
Get a cup of coffee/tea and check out http://www.engineering.ucsb.edu/~duonglt/vmware/
Can't locate object method "licenses" via package "LicenseManager" at C:\Install\vmwarevSphereHealthCheck.pl line 2407.
End Disconnect"
What I doing wrong?
Are you running on vSphere? This script is only for vSphere 4.0 setup: vCenter or ESX(i) 4.0
If you're still running on VI 3.5, please take a look at this script: VMware Health Check Report v0.9.4
Yes, I run this script on vSphere 4 - vCenter! (it's was upgrade from 3.5)
Do you have any hosts that are on ESX 4 yet? or is it just vCenter that's upgraded to vSphere? As you know, if you're in this situation, your ESX(i) 3.5 hosts will continue pulling their licenses from the license server which might explain why it's erroring out since you may not have any ESX(i) 4.0 licenses setup, you may be in this hybrid state where it's part 3.5 and 4.0. I know for a fact that if you have vCenter on 4.0 and it's managing both ESX(i) 3.5 and 4.0 systems, the vSphere report works
Yes, I have hosts on vCenter! All hosts under ESX 4. All systems work properly. I stopped service license server (even uninstalled it).
The same problem remains.
(sorry for my English).
Hi there,
first i congratulate for this great script.
therefore i would have a inquiry/comments on that.
i have a non-perl script based on Ivo Beerens. With a lot of privat modifications.
But now i'am interested to integrate them into this Perl script.
i'am not familiar with Perl so i finished only few Basic extentions:
ESX/ESXI Configurations:
I can take a look to see if I can integrate some of this information into the report, but remember this report is meant to capture the environment at the time of execution and is not meant to be any type of performance monitoring report. Detail performance data should probably be generated in another type of custom report, so specifying a time interval will not be supported.
Regarding the actual requests, there are a few things I would like to clear up:
VirtualMachines:
Take a look at the newest version of the script 1.4 which contains of the attributes you've requested. Note that this is not a performance gathering scripts and does increase execution time, especially when you look at the VM stats. Please take a look at the release notes for more information
Hi William,
Sry for the delay.
Have many thx for your fast integrations ![]()
for the Snapshot Point (Creator) i ment the Owner of the Snapshot.
from time to time i make an analyze of available Snapshot and therefore i have the Owner Name in this field.
if you like to integrate this also i could deliver you the non-Perl Toolkit Code over PM.
Have many thx
Best regards
Max
Hey William,
Stellar script! Thanks for the hard work.
Its throwing an error form me, even with out the --vmperforamance fllag set.
C:\Downloads\VM>perl vmwarevspherehealthcheck.pl --server opusvrc1 --type cluste
r --cluster VMCluster1 --passthroughauth
Generating VMware vSphere Health Report 1.4 "vmware_health_report.html" ...
This can take a few minutes depending on environment size.
Get a cup of coffee/tea and check out http://www.engineering.ucsb.edu/~duonglt/v
mware/
Error retrieving VMCluster1 performance:
SOAP Fault:
I've got this set up on Windows Server 2008 with scheduled tasks and powershell scripts. The powershell script runs the .pl healthcheck script then emails the html output as an attachment to wherever you choose. I've got my powershell script below, and the details on the scheduled task beneath that.
Powershell Script:
report.ps1_________________________________________________________________
$dt = get-date -format yyyyMMdd
$pp = get-process powershell
D:\vmwarevSphereHealthCheck.pl --server VCENTERSERVER --username VCENTERUSER --password VCENTERUSERPASSWORD --type datacenter --datacenter DATACENTERNAME --report D:\vmware_health_check$dt.html
$pp = get-process perl
$pp.waitforexit()
Copy-Item D:\vmware_health_check$dt.html D:\emailed\vmware_daily_report.html
$file = "D:\vmware_daily_report.html"
$smtpServer = "SMTPSERVERNAME"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "vmwarereport@yourcompany.com"
$msg.To.Add("recipients@yourcompany.com")
$msg.Subject = "Today's VMWare Health Report"
$msg.Body = "Enjoy!"
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()
Remove-Item D:\vmware_health_check$dt.html
Remove-Item D:\emailed\vmware_daily_report.html
_______________________________________________________________________
Scheduled Task:
Run: C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" & "D:\report.ps1"
Start in: C:\WINDOWS\system32\windowspowershell\v1.0
_______________________________________________________________________
Seems to work pretty flawlessly, thanks for all the hard work on this!
--vmperforamance flag is ONLY for performance stats for the VMs in the VM table. With the new version, it'll automatically report on Cluster and Host performance stats.
What you're seeing is most likely referring to Cluster performance since I do print out an error message Error retrieving VMCluster1 performance: which tells me where the fault is being generated from.
I've also gotten reports from others with various odd 'errors' regarding the performance stats but I've not had the time to narrow it down. I'm wondering if the way I'm extracting the performance is not correct and I'm using an identifier that only works in my environment.
I'll need to do some further research and get back to everyone. Please be patient and I'll have an update as soon as I get a chance.
Thanks for the feedback/comments
Glad to hear and very cool way to automate the report ... though I personally prefer vMA (linux) over Windows ![]()
I also plan on adding email functionality into the script, so you can just setup your email info and it can deliver it to you when it's completed. That'll most likely make it out in the next update of the script. So all you would need to do is to schedule the execution of the script.
I've just made some updates to the script regarding the performance issue, please download the latest version v1.4.1, the issue should be resolved
Hi ,
There is a Typo Error on the VM Performance Stats Section of Supported Use Cases .
When i Run this report against a vCenter , I am able to see reports generated only for Hosts that are part of a Cluster ? Is there a way to run the Script against a vCenter and generate Similar reports for all Hosts that are part of them which are not in a clustered Environment ?
Thanks
Sudharsan
Which typo?
The script assumes that you will have at least 1 cluster to logically separate out your hosts, if you don't have a cluster in which hosts are under, they will not be discovered.
Performance has been misspelled in the VM Performance Stats Section of Supported Use Cases .
Thanks . But Can you please connsider it as an request for feature so that this script can be even used by SMBs .
Thanks I'll get the typo fixed tonight.
Regarding the cluster setup, if you have vCenter ...you have the functionality of creating a cluster ... remember a cluster is a logical container. I don't expect or care if it has DRS/HA enabled and you don't need those to be enabled to have a valid cluster. For most setups, isolation/segregation is usually done at the cluster level, hence I decided to stick with that. You can easily just create a cluster object and move your hosts into it and the script will work. I'll keep it in mind in the future but as I mentioned, if you have vCenter ... you have cluster creation functionality and this has nothing to do with SMBs
Not sure what you're referring to with the scheduled task? Atm, you can schedule it via any means, so long as the input params are specified in the execution line.
Hi Willian, thanks for the great script. I was using the 3.5 version flawlessy however after moving to the vSphere version (all of our hosts and vCenter are vsphere U1) it throws a few errors but does succeed. Wondering if you can shed any light?
Use of uninitialized value in concatenation (.) or string at ./vmwarevSphereHealthCheck.pl line 992.
Use of uninitialized value in print at ./vmwarevSphereHealthCheck.pl line 2471.
Cheers
If you're using the latest version of the script v1.4.1:
The errors are regarding the following:
Line 992: Something with the output of a dvPortgroup with dvs
Line: 2471: HA Failover level is not configured or unable to retrieve the value
Could you double check this within your environment and also for the dvPortgroup, see if this is listed out properly for all your VMs, I suspect there's some logic that's still being missed.
Thanks
I am using v1.4.1 and did check the code that the errors referred too but still thought my settings looked good. After you suggestion I rechecked my HA cluster settings and they were set to reserve a percentage of resources for HA rather than dedicating the cluster failover to say 1. When I set it back to 1,2,3 etc... the error does not appear for 2471. The script doesn't pick up the percentage it seems.
For dvPortgroup error yes they do all appear correctly form what I can tell. What I do notice when I run the script againts vSphere vCeneters that still using VSS and have no vDS at all the error still appears
I've just found your script and ran it against an ESX4i host and got the performance error.
Command used: vmwarevSphereHealthCheck.pl --server myserver --username root --password mypassword --type host
Error retrieving myserver performance:
SOAP Fault:
Thanks for nice script, I've got an error in 1.4.1 script like sammyvm:
Command: /home/vi-admin/vmwarevSphereHealthCheck.pl --server ps01 --username vcenter --password ************ --type vcenter --report /home/vi-admin/vmware_health_report.html
Generating VMware vSphere Health Report 1.4.1 "/home/vi-admin/vmware_health_report.html" ...
This can take a few minutes depending on environment size.
Get a cup of coffee/tea and check out http://www.engineering.ucsb.edu/~duonglt/vmware/
Use of uninitialized value in concatenation (.) or string at /home/vi-admin/vmwarevSphereHealthCheck.pl line 992.
I'll have to look into the performance stats again, I thought it was resolved in the latest version but looks like I might still have missed something. I'll post an update once I get a chance to investigate.
Thanks for your patience
I'll need to investigate this issue, is the ESXi 4.0 host a standalone? or is it being managed by vCenter and using virtual distributed vSwitch?
I use ESX 4.0 hosts (not "i") managed by vCenter with vds.
Okay, that's what I thought, it's most likely related to retrieving the vDS information. I'll update when I have something, too many things to do and not enough time
I get the below error when I run the script..
D:\>vmwarevSphereHealthCheck.pl --type host --server esx26 --username root --report esx26.html
Enter password:
Generating VMware vSphere Health Report 1.4.1 "esx26.html" ...
..
..
Use of uninitialized value in concatenation (.) or string at D:\vmwarevSphereHealthCheck.pl line 424, <STDIN> line 1.
What version of vSphere 4.0 license do you have for your ESX 4.0 host? The features should display....
Hi,
This may be a tad too late but I just got my vma4.0 installed a couple of days so I was wanting to test out some useful scripts. Then I stumbled across this discussion by chance, which is great. Anyway, for the cron, here's what I did and got some output scripts with date.
1. System cron example.
# vi /etc/crontab
*/5 * * * * root /home/vi-admin/scripts/vmwarevSphereHealthCheck.pl --server valerie --username chakrit --password 'XXX' --type vcenter --report=/home/vi-admin/reports/alcae_health_`date +\%m-\%d-\%y_\%H:\%M:\%S`.html
Here you specify the frequency (stars bit), then the user to execute the script follow by script parameters.
The last bit is the output filename with date/time stamp. Note that you'll need a backslash before the % symbol to enable it to be recognised by the cron.
2. User cron example.
# crontab -e
*/5 * * * * /home/vi-admin/scripts/vmwarevSphereHealthCheck.pl --server valerie --username chakrit --password 'X' --type vcenter --report=/home/vi-admin/reports/health_`date +\%m-\%d-\%y_\%H:\%M:\%S`.html
Similar to the above but you don't specify the username to execute the script.
The other thing I had to do is to always use the full path to the location of the script and the output directory.
Thanks Chakrit - I'm still watching this thread ![]()
I scripted a collection for cron, in effect doing what you state, and I even added a bit for compression and FTP to a remote target, with local cleanup after.
I think the Windows folks have a tougher time, particularly looking for a mechanism to email the output. On the vMA I just get Sendmail working.
Cheers -
Don
In the next version, I'll include email functionality, it's actually been there for awhile in various scripts I've written but haven't had the time to port that back into other scripts. Keep an eye out for that update pretty soon ... just need to find the time ![]()
Also note, this script 'can' run on Windows so long as vCLI is installed ... I don't support it under Windows since I rather not deal with any 'window' issues that may be generated but I do know users have successfully executed this on Windows and it works perfectly fine. If you're more comfortable on Windows, you can just setup a schedule task and use the email capabilities on Windows. Though, do note that all my development is on vMA, so any issues that may come up, I won't be able to assist.
Email for Windows isn't hard... Blat (www.blat.net) is freely available, and has been for years...
Learning how to write a batch file to blat the output of William's code and schedule it via Task Scheduler is an exercise left for the reader...
Cool.
I'm hoping the Perl email module will just 'work' in Windows, that way you don't need another utility. You can just pass in your mailserver/etc. and then a simple scheduled task will work. I unfortunately don't have a test mail server to verify, so I'll have to rely on users to confirm or deny for Windows.
I've noted that with the vMA on ESX3.5U4 I get an error with the .9.4 script you have also graced us with. Is it even worth an attempt to try this script (with the vMA) on older hosts?
I am assuming the it's a VIMA/.9.4/ESX3.5.x and vMA/1.2/vSphere kind of relationship....