Skip to content

Commit

Permalink
Merge dev branch to master
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneddo committed Aug 19, 2016
2 parents 5bbc544 + eb029d9 commit 8ba8f3e
Show file tree
Hide file tree
Showing 30 changed files with 1,366 additions and 830 deletions.
8 changes: 8 additions & 0 deletions .gitAttributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Custom for PowerShell
*.ps1 text eol=crlf
*.psm1 text eol=crlf
*.psd1 text eol=crlf

# Misc/Others
*.xml text eol=crlf

# Ignore plugins.xml in exports
plugins.xml export-ignore
.gitAttributes export-ignore
Expand Down
112 changes: 112 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Contribute to the vCheck-vSphere repository

Hi! We can't thank you enough for wanting to contribute; the community is what keeps the wheels moving on this awesome project.
All we ask is that you follow some simple guidelines. The roots of these guidelines stem from the developer community and the actual document has been borrowed from [Microsoft's DscResources](https://github.com/PowerShell/DscResources) repository; they did an excellent job putting these guidelines together; why reinvent the wheel?

## Using GitHub, Git, and this repository

We are working on more detailed instructions that outline the basics.

## Contributing to the existing vCheck-vSphere repository

### Forks and Pull Requests

GitHub fosters collaboration through the notion of [pull requests](https://help.github.com/articles/using-pull-requests/).
On GitHub, anyone can [fork](https://help.github.com/articles/fork-a-repo/) an existing repository into their own branch where they can make private changes to the original repository.
To contribute these changes back into the original repository, a user simply creates a pull request in order to "request" that the changes be taken "upstream".

#### Lifecycle of a pull reqeust

* **Always create pull requests to the `dev` branch of a repository**.
For more information, learn about the [branch structure](#branch-structure) that we are using.

![PR-Dev.png](https://github.com/vScripter/vCheck-vSphere/blob/dev/Images/PR-Dev.PNG)

* When you create a pull request, fill out the description with a summary of what's included in your changes.
If the changes are related to an existing GitHub issue, please reference the issue in your description.
* Once the PR is submitted, we will review your code
* Once the code review is done, and all merge conflicts are resolved, a maintainer will merge your changes.

### Contributing to documentation
One of the easiest ways to contribute to a PowerShell project is by helping to write and edit documentation.
All of our documentation hosted on GitHub is written using [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/)

*We are at lest working on shifting things over to GFM, for 'core' documentation. Some things may still live on the GitHub wiki, but using GFM allows the documentation to exist in the repo, so you always have a local copy to reference ;)*

To [edit an existing file](https://help.github.com/articles/editing-files-in-another-user-s-repository/), simply navigate to it and click the "Edit" button.
GitHub will automatically create your own fork of our repository where you can make your changes.
Once you're finished, save your edits and submit a pull request to get your changes merged upstream.

If you want to contribute new documentation, first check for [issues tagged as "Documentation"](https://github.com/alanrenouf/vCheck-vSphere/labels/documentation) to make sure you're not duplicating efforts.
If no one seems to be working on what you have planned:
* Open a new issue tagged as "Documentation" to tell others what you're working on
* Create a fork of our repository and start adding new Markdown-based documentation to it
* When you're ready to contribute your documentation, submit a pull request to the *dev* branch


#### GitHub Flavored Markdown (GFM)

All of the articles in this repository use [GitHub Flavored Markdown (GFM)](https://help.github.com/articles/github-flavored-markdown/).

If you are looking for a good editor, try [Markdown Pad](http://markdownpad.com/) or
GitHub also provides a web interface for Markdown editing with syntax highlighting and the ability to preview changes.

Some of the more basic GFM syntax includes:

* **Line breaks vs. paragraphs:** In Markdown there is no HTML `<br />` or `<p />` element.
Instead, a new paragraph is designated by an empty line between two blocks of text.
(Note: Please add a single newline after each sentence to simplify the command-line output of diffs and history.)
It will simplify diffs and history.
* **Italics:** The HTML `<em>some text</em>` is written as `*some text*`
* **Bold:** The HTML `<strong>some text</strong>` element is written as `**some text**`
* **Headings:** HTML headings are designated using `#` characters at the start of the line.
The number of `#` characters corresponds to the hierarchical level of the heading (for example, `#` = `<h1>` and `###` = ```<h3>```).
* **Numbered lists:** To make a numbered (ordered) list start the line with `1. `.
If you want multiple elements within a single list element, format your list as follows:
```
1. For the first element (like this one), insert a tab stop after the 1.
To include a second element (like this one), insert a line break after the first and align indentations.
```
to get this output:

1. For the first element (like this one), insert a tab stop after the 1.

To include a second element (like this one), insert a line break after the first and align indentations.

* **Bulleted lists:** Bulleted (unordered) lists are almost identical to ordered lists except that the `1. ` is replaced with either `* `, `- `, or `+ `.
Multiple element lists work the same way as with ordered lists.
* **Links:** The syntax for a hyperlink is `[visible link text](link url)`.
Links can also have references, which will be discussed in the "Link and Image References" section below.

## Editing an existing plugin

We are in the process of adding/consolidating more detailed documentation around this.

## Creating a new plugin

We are in the process of adding/consolidating more detailed documentation around this. In the meantime, you can review the documentation that we do have inside the [README.md](README.md) file for the repo.

## Gitter & Waffle

We are using [![Join the chat at https://gitter.im/alanrenouf/vCheck-vSphere](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alanrenouf/vCheck-vSphere?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) for general discussion around the vCheck utility. This is a good place for general questions or minor issues that someone might be able to answer, on the spot. If something cannot be resolved in the chat, it may warrant the submission of an Issue.

We are also using Waffle.io to help track and resolve issues. You can visit the the dashboard [![Stories in Ready](http://badge.waffle.io/alanrenouf/vCheck-vSphere.png)](http://waffle.io/alanrenouf/vCheck-vSphere) to view or submit issues (you can also still use the GitHub web interface to submit/view issues).


## Style guidelines

When contributing to this repository, please follow the following guidelines:

* For all indentation, use 4 spaces instead of tab stops
* Make sure all files are encoding using UTF-8.
* When writing Markdown, if a paragraph includes more than one setence, end each sentence with a newline.
GitHub will still render the sentences as a single paragraph, but the readability of `git diff` will be greatly improved.


## Branch structure

We are using a [git flow](http://nvie.com/posts/a-successful-git-branching-model/) model for development.
We recommend that you create local working branches that target a specific scope of change.
Each branch should be limited to a single feature/bugfix both to streamline workflows and reduce the possibility of merge conflicts.
![git flow picture](http://nvie.com/img/[email protected])
35 changes: 23 additions & 12 deletions Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
$Title = "Connection settings for vCenter"
$Author = "Alan Renouf"
$PluginVersion = 1.5
$PluginVersion = 1.7
$Header = "Connection Settings"
$Comments = "Connection Plugin for connecting to vSphere"
$Display = "List"
$Display = "None"
$PluginCategory = "vSphere"

# Start of Settings
Expand Down Expand Up @@ -50,17 +50,19 @@ else
# Path to credentials file which is automatically created if needed
$Credfile = $ScriptPath + "\Windowscreds.xml"

# Adding PowerCLI core snapin
if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
add-pssnapin VMware.VimAutomation.Core
# Adding PowerCLI core snapin, also check if powerCLI module is alsready added
if (!(get-module -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
add-pssnapin VMware.VimAutomation.Core -erroraction silentlycontinue
}
}

$OpenConnection = $global:DefaultVIServers | where { $_.Name -eq $VIServer }
if($OpenConnection.IsConnected) {
Write-CustomOut $pLang.connReuse
Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server )
$VIConnection = $OpenConnection
} else {
Write-CustomOut $pLang.connOpen
Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server )
$VIConnection = Connect-VIServer -Server $VIServer -Port $Port
}

Expand All @@ -76,7 +78,7 @@ function Get-VMLastPoweredOffDate {
process {
$Report = "" | Select-Object -Property Name,LastPoweredOffDate
$Report.Name = $_.Name
$Report.LastPoweredOffDate = (Get-VIEvent -Entity $vm | `
$Report.LastPoweredOffDate = (Get-VIEventPlus -Entity $vm | `
Where-Object { $_.Gettype().Name -eq "VmPoweredOffEvent" } | `
Select-Object -First 1).CreatedTime
$Report
Expand All @@ -90,8 +92,8 @@ function Get-VMLastPoweredOnDate {
process {
$Report = "" | Select-Object -Property Name,LastPoweredOnDate
$Report.Name = $_.Name
$Report.LastPoweredOnDate = (Get-VIEvent -Entity $vm | `
Where-Object { $_.Gettype().Name -eq "VmPoweredOnEvent" } | `
$Report.LastPoweredOnDate = (Get-VIEventPlus -Entity $vm | `
Where-Object { $_.Gettype().Name -match "VmPoweredOnEvent" } | `
Select-Object -First 1).CreatedTime
$Report
}
Expand All @@ -102,7 +104,7 @@ New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-V

New-VIProperty -Name PercentFree -ObjectType Datastore -Value {
param($ds)
[math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),0)
[math]::Round(((100 * ($ds.FreeSpaceMB)) / ($ds.CapacityMB)),2)
} -Force | Out-Null

New-VIProperty -Name "HWVersion" -ObjectType VirtualMachine -Value {
Expand Down Expand Up @@ -181,6 +183,9 @@ if ($VIVersion -ge 5) {
A switch indicating if the full message shall be compiled.
This switch can improve the execution speed if the full
message is not needed.
.PARAMETER UseUTC
A switch indicating if the event shoukld remain in UTC or
local time.
.EXAMPLE
PS> Get-VIEventPlus -Entity $vm
.EXAMPLE
Expand All @@ -197,7 +202,8 @@ function Get-VIEventPlus {
[string[]]$User,
[Switch]$System,
[string]$ScheduledTask,
[switch]$FullMessage = $false
[switch]$FullMessage = $false,
[switch]$UseUTC = $false
)

process {
Expand Down Expand Up @@ -248,6 +254,11 @@ function Get-VIEventPlus {
}
$eventCollector.DestroyCollector()
}
if (-not $UseUTC)
{
$events | % { $_.createdTime = $_.createdTime.ToLocalTime() }
}

$events
}
}
2 changes: 1 addition & 1 deletion Plugins/00 Initialize/01 General Information.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if ($DRSMigrateAge -gt 0) {
# Adding vSphere 5 informations
if ($VIVersion -ge 5) {
$Info | Add-Member Noteproperty "Number of Datastore Clusters" $(@($DatastoreClustersView).Count)
if ($SDRSMigrateAge -gt 0) {
if (($MigrationQuery2) -and ($SDRSMigrateAge -gt 0)) {
$Info | Add-Member Noteproperty "Storage DRS Migrations for last $($SDRSMigrateAge) Days" (@($MigrationQuery2 | Where {$_.FullFormattedMessage -imatch "(Storage vMotion){1}.*(DRS){1}"}).Count)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/10 vCenter/23 VI Events.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Start of Settings
# End of Settings

$Result = @(Get-VIEvent -maxsamples $MaxSampleVIEvent -Start ($Date).AddDays(-$VCEventAge ) -Type Error | Select @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage)
$Result = @(Get-VIEvent -maxsamples $MaxSampleVIEvent -Start ($Date).AddDays(-$VCEventAge ) -Types Error | Select @{N="Host";E={$_.host.name}}, createdTime, @{N="User";E={($_.userName.split("\"))[1]}}, fullFormattedMessage)
$Result

$Title = "Checking VI Events"
Expand Down
18 changes: 12 additions & 6 deletions Plugins/20 Cluster/10 HA Configuration Issues.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
# Start of Settings
# HA Configuration Issues, do not report on any Clusters that are defined here
$ClustersDoNotInclude = "Example_Cluster_*|Test_Cluster_*"
# HA should be set to ...
$CLusterHAShouldBeEnabled = $true
# HA host monitoring should be set to ...
$ClusterHAHostMonitoringShouldBeEnabled = $true
# HA Admission Control should be set to ...
$ClusterHAAdmissionControlShouldBeEnabled = $true
# End of Settings

# Setup plugin-specific language table
$pLang = DATA {
ConvertFrom-StringData @'
HADisabled = HA Disabled on this cluster.
HAMonDisabled = Host Monitoring disabled.
HAACDisabled = HA Admission Control disabled.
HADisabled = HA config not compliant on this cluster.
HAMonDisabled = Host Monitoring config not compliant.
HAACDisabled = HA Admission Control config not compliant.
'@
}
# Override the default (en) if it exists in lang directory
Import-LocalizedData -BaseDirectory ($ScriptPath + "\lang") -BindingVariable pLang -ErrorAction SilentlyContinue

# Clusters with HA disabled
$HAIssues = @()
$HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and -not $_.HAEnabled} |
$HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and $_.HAEnabled -ne $CLusterHAShouldBeEnabled } |
Select-Object @{Name="Cluster";Expression={$_.Name}},@{Name="Configuration Issue";Expression={$pLang.HADisabled}}

# Clusters with host monitoring disabled
$HAIssues += $clusviews | where {$_.Name -notmatch $ClustersDoNotInclude -and $_.Configuration.DasConfig.HostMonitoring -eq "disabled"} |
$HAIssues += $clusviews | where {$_.Name -notmatch $ClustersDoNotInclude -and ( $_.Configuration.DasConfig.HostMonitoring -eq "enabled" ) -ne $ClusterHAHostMonitoringShouldBeEnabled } |
Select-Object @{Name="Cluster";Expression={$_.Name}}, @{N="Configuration Issue";E={$pLang.HAMonDisabled}}

# Clusters with admission Control Disabled
$HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and -not $_.HAAdmissionControlEnabled} |
$HAIssues += $Clusters | Where-Object {$_.Name -notmatch $ClustersDoNotInclude -and $_.HAAdmissionControlEnabled -ne $ClusterHAAdmissionControlShouldBeEnabled } |
Select-Object @{Name="Cluster";Expression={$_.Name}},@{Name="Configuration Issue";Expression={$pLang.HAACDisabled}}


Expand Down
17 changes: 4 additions & 13 deletions Plugins/20 Cluster/15 HA VMs restarted.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
# Start of Settings
# Start of Settings
# HA VM restart day(s) number
$HAVMrestartold = 5
# End of Settings

$EventFilterSpec = New-Object VMware.Vim.EventFilterSpec
$EventFilterSpec.Category = "warning"
$EventFilterSpec.eventTypeId = "com.vmware.vc.ha.VmRestartedByHAEvent"
$EventFilterSpec.Time = New-Object VMware.Vim.EventFilterSpecByTime
$EventFilterSpec.Time.beginTime = (Get-Date).AddDays(-$HAVMrestartold)

$HAVMrestartlist = @((get-view (get-view ServiceInstance -Property Content.EventManager).Content.EventManager).QueryEvents($EventFilterSpec) | select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending)
$HAVMrestartlist
@(Get-VIEventPlus -EventType "com.vmware.vc.ha.VmRestartedByHAEvent" -Start (Get-Date).AddDays(-$HAVMrestartold) | Select-Object CreatedTime, FullFormattedMessage | Sort-Object CreatedTime -Descending)

$Title = "HA VMs restarted"
$Header = ("HA: VM restart (Last {0} Day(s)) : {1}" -f $HAVMrestartold, @($HAVMrestartlist).count)
$Header = ("HA: VM restart (Last {0} Day(s)) : [count]" -f $HAVMrestartold)
$Comments = "The following VMs have been restarted by HA in the last $HAVMresetold days"
$Display = "Table"
$Author = "Alan Renouf"
$PluginVersion = 1.1
$PluginVersion = 1.2
$PluginCategory = "vSphere"

Remove-Variable HAVMrestartlist, EventFilterSpec
33 changes: 18 additions & 15 deletions Plugins/20 Cluster/18 Cluster Slot Sizes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
# Number of slots available in a cluster
$numslots = 10
# End of Settings

If ($vSphere){
$SlotInfo = @()
Foreach ($Cluster in ($Clusters)){
If ($Cluster.ExtensionData.Configuration.DasConfig.Enabled -eq $true){
$SlotDetails = $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo()
$Details = "" | Select Cluster, TotalSlots, UsedSlots, AvailableSlots
$Details.Cluster = $Cluster.Name
$Details.TotalSlots = $SlotDetails.TotalSlots
$Details.UsedSlots = $SlotDetails.UsedSlots
$Details.AvailableSlots = $SlotDetails.UnreservedSlots
$SlotInfo += $Details
}
}
$SlotCHK = @($SlotInfo | Where { $_.AvailableSlots -lt $numslots})
$SlotInfo = @()
Foreach ($Cluster in ($Clusters)){
If ($Cluster.ExtensionData.Configuration.DasConfig.Enabled -eq $true -and
$Cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.getType() -eq [VMware.Vim.ClusterFailoverLevelAdmissionControlPolicy]){
$SlotDetails = $Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo()

$Details = [PSCustomObject] @{
Cluster = $Cluster.Name
TotalSlots = $SlotDetails.TotalSlots
UsedSlots = $SlotDetails.UsedSlots
AvailableSlots = $SlotDetails.UnreservedSlots
}
$SlotInfo += $Details
}
}
$SlotCHK = @($SlotInfo | Where { $_.AvailableSlots -lt $numslots})
}

$SlotCHK
Expand All @@ -26,5 +29,5 @@ $Header = "Clusters with less than $numslots Slot Sizes : $(@($SlotCHK).count)"
$Comments = "Slot sizes in the below cluster are less than is specified, this may cause issues with creating new VMs, for more information click here: <a href='http://www.yellow-bricks.com/vmware-high-availability-deepdiv/' target='_blank'>Yellow-Bricks HA Deep Dive</a>"
$Display = "Table"
$Author = "Alan Renouf"
$PluginVersion = 1.1
$PluginVersion = 1.2
$PluginCategory = "vSphere"
Loading

0 comments on commit 8ba8f3e

Please sign in to comment.