├── .vscode └── launch.json ├── Build ├── build.depend.psd1 ├── build.ps1 ├── build.psake.ps1 └── deploy.psdeploy.ps1 ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Documentation ├── ConvertTo-InfluxLineString.md ├── ConvertTo-Metric.md ├── ConvertTo-StatsDString.md ├── Get-3ParSystemMetric.md ├── Get-3ParVirtualVolumeMetric.md ├── Get-DatacenterMetric.md ├── Get-DatastoreClusterMetric.md ├── Get-DatastoreMetric.md ├── Get-HostMetric.md ├── Get-IsilonStoragePoolMetric.md ├── Get-ResourcePoolMetric.md ├── Get-TFSBuildMetric.md ├── Get-VMMetric.md ├── Send-3ParSystemMetric.md ├── Send-3ParVirtualVolumeMetric.md ├── Send-DatacenterMetric.md ├── Send-DatastoreClusterMetric.md ├── Send-DatastoreMetric.md ├── Send-HostMetric.md ├── Send-IsilonStoragePoolMetric.md ├── Send-ResourcePoolMetric.md ├── Send-TFSBuildMetric.md ├── Send-VMMetric.md ├── Write-Influx.md ├── Write-InfluxUDP.md └── Write-StatsD.md ├── Influx ├── Influx.psd1 ├── Influx.psm1 ├── Private │ ├── ConvertTo-UnixTimeMillisecond.ps1 │ ├── ConvertTo-UnixTimeNanosecond.ps1 │ ├── Invoke-UDPSendMethod.ps1 │ └── Out-InfluxEscapeString.ps1 └── Public │ ├── 3PAR │ ├── Get-3ParSystemMetric.ps1 │ ├── Get-3ParVirtualVolumeMetric.ps1 │ ├── Send-3ParSystemMetric.ps1 │ └── Send-3ParVirtualVolumeMetric.ps1 │ ├── ConvertTo-InfluxLineString.ps1 │ ├── ConvertTo-Metric.ps1 │ ├── ConvertTo-StatsDString.ps1 │ ├── Isilon │ ├── Get-IsilonStoragePoolMetric.ps1 │ └── Send-IsilonStoragePoolMetric.ps1 │ ├── TFS │ ├── Get-TFSBuildMetric.ps1 │ └── Send-TFSBuildMetric.ps1 │ ├── VMWare │ ├── Get-DatacenterMetric.ps1 │ ├── Get-DatastoreClusterMetric.ps1 │ ├── Get-DatastoreMetric.ps1 │ ├── Get-HostMetric.ps1 │ ├── Get-ResourcePoolMetric.ps1 │ ├── Get-VMMetric.ps1 │ ├── Send-DatacenterMetric.ps1 │ ├── Send-DatastoreClusterMetric.ps1 │ ├── Send-DatastoreMetric.ps1 │ ├── Send-HostMetric.ps1 │ ├── Send-ResourcePoolMetric.ps1 │ └── Send-VMMetric.ps1 │ ├── Write-Influx.ps1 │ ├── Write-InfluxUDP.ps1 │ └── Write-Statsd.ps1 ├── LICENSE ├── PSScriptAnalyzerSettings.psd1 ├── README.md ├── Tests ├── Common │ ├── Help.Tests.ps1 │ ├── Manifest.Tests.ps1 │ └── PSSA.Tests.ps1 ├── ConvertTo-InfluxLineString.Tests.ps1 ├── ConvertTo-Metric.Tests.ps1 ├── ConvertTo-StatsDString.Tests.ps1 ├── ConvertTo-UnixTimeMillisecond.Tests.ps1 ├── ConvertTo-UnixTimeNanosecond.Tests.ps1 ├── Get-3ParSystemMetric.Tests.ps1 ├── Influx.Tests.ps1 ├── Invoke-UDPSendMethod.Tests.ps1 ├── Mock-Get-3parStatVV.xml ├── Mock-Get3parSpace.xml ├── Mock-Get3parSystem.xml ├── Mock-GetisiStoragePools.xml ├── Out-InfluxEscapeString.Tests.ps1 ├── Send-3ParSystemMetric.Tests.ps1 ├── Send-3ParVirtualVolumeMetric.Tests.ps1 ├── Send-DatacenterMetric.Tests.ps1 ├── Send-DatastoreClusterMetric.Tests.ps1 ├── Send-DatastoreMetric.Tests.ps1 ├── Send-HostMetric.Tests.ps1 ├── Send-IsilonStoragePoolMetric.Tests.ps1 ├── Send-ResourcePoolMetric.Tests.ps1 ├── Send-TFSBuildMetric.Tests.ps1 ├── Send-VMMetric.Tests.ps1 ├── Write-Influx.Tests.ps1 ├── Write-InfluxUDP.Tests.ps1 └── Write-Statsd.Tests.ps1 └── azure-pipelines.yml /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "PowerShell", 9 | "request": "launch", 10 | "name": "PowerShell Launch Current File", 11 | "script": "${file}", 12 | "args": [], 13 | "cwd": "${file}" 14 | }, 15 | { 16 | "type": "PowerShell", 17 | "request": "launch", 18 | "name": "PowerShell Launch Current File in Temporary Console", 19 | "script": "${file}", 20 | "args": [], 21 | "cwd": "${file}", 22 | "createTemporaryIntegratedConsole": true 23 | }, 24 | { 25 | "type": "PowerShell", 26 | "request": "launch", 27 | "name": "PowerShell Launch Current File w/Args Prompt", 28 | "script": "${file}", 29 | "args": [ 30 | "${command:SpecifyScriptArgs}" 31 | ], 32 | "cwd": "${file}" 33 | }, 34 | { 35 | "type": "PowerShell", 36 | "request": "attach", 37 | "name": "PowerShell Attach to Host Process", 38 | "processId": "${command:PickPSHostProcess}", 39 | "runspaceId": 1 40 | }, 41 | { 42 | "type": "PowerShell", 43 | "request": "launch", 44 | "name": "PowerShell Interactive Session", 45 | "cwd": "${workspaceRoot}" 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /Build/build.depend.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | # Defaults for all dependencies 3 | PSDependOptions = @{ 4 | Target = 'CurrentUser' 5 | Parameters = @{ 6 | # Use a local repository for offline support 7 | Repository = 'PSGallery' 8 | SkipPublisherCheck = $true 9 | } 10 | } 11 | 12 | # Dependency Management modules 13 | # PackageManagement = '1.2.2' 14 | # PowerShellGet = '2.0.1' 15 | 16 | # Common modules 17 | BuildHelpers = '2.0.1' 18 | Pester = '4.6.0' 19 | PlatyPS = '0.12.0' 20 | psake = '4.7.4' 21 | PSDeploy = '1.0.1' 22 | PSScriptAnalyzer = '1.17.1' 23 | # 'VMware.VimAutomation.Cloud' = '11.0.0.10379994' 24 | } 25 | -------------------------------------------------------------------------------- /Build/build.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param ( 3 | [Parameter()] 4 | [System.String[]] 5 | $TaskList = 'Default', 6 | 7 | [Parameter()] 8 | [System.Collections.Hashtable] 9 | $Parameters, 10 | 11 | [Parameter()] 12 | [System.Collections.Hashtable] 13 | $Properties, 14 | 15 | [Parameter()] 16 | [Switch] 17 | $ResolveDependency 18 | ) 19 | 20 | Write-Output "`nSTARTED TASKS: $($TaskList -join ',')`n" 21 | 22 | Write-Output "`nPowerShell Version Information:" 23 | $PSVersionTable 24 | 25 | # Load dependencies 26 | if ($PSBoundParameters.Keys -contains 'ResolveDependency') { 27 | # Bootstrap environment 28 | Get-PackageProvider -Name 'NuGet' -ForceBootstrap | Out-Null 29 | 30 | # Install PSDepend module if it is not already installed 31 | if (-not (Get-Module -Name 'PSDepend' -ListAvailable)) { 32 | Write-Output "`nPSDepend is not yet installed...installing PSDepend now..." 33 | Install-Module -Name 'PSDepend' -Scope 'CurrentUser' -Force 34 | } else { 35 | Write-Output "`nPSDepend already installed...skipping." 36 | } 37 | 38 | # Install build dependencies 39 | $psdependencyConfigPath = Join-Path -Path $PSScriptRoot -ChildPath 'build.depend.psd1' 40 | Write-Output "Checking / resolving module dependencies from [$psdependencyConfigPath]..." 41 | Import-Module -Name 'PSDepend' 42 | $invokePSDependParams = @{ 43 | Path = $psdependencyConfigPath 44 | # Tags = 'Bootstrap' 45 | Import = $true 46 | Confirm = $false 47 | Install = $true 48 | # Verbose = $true 49 | } 50 | Invoke-PSDepend @invokePSDependParams 51 | 52 | # Remove ResolveDependency PSBoundParameter ready for passthru to PSake 53 | $PSBoundParameters.Remove('ResolveDependency') 54 | } else { 55 | Write-Host "Skipping dependency check...`n" -ForegroundColor 'Yellow' 56 | } 57 | 58 | 59 | # Init BuildHelpers 60 | Set-BuildEnvironment -Force 61 | 62 | 63 | # Execute PSake tasts 64 | $invokePsakeParams = @{ 65 | buildFile = (Join-Path -Path $env:BHProjectPath -ChildPath 'Build\build.psake.ps1') 66 | nologo = $true 67 | } 68 | Invoke-Psake @invokePsakeParams @PSBoundParameters 69 | 70 | Write-Output "`nFINISHED TASKS: $($TaskList -join ',')" 71 | 72 | exit ( [int](-not $psake.build_success) ) 73 | -------------------------------------------------------------------------------- /Build/deploy.psdeploy.ps1: -------------------------------------------------------------------------------- 1 | # Config file for PSDeploy 2 | # Set-BuildEnvironment from BuildHelpers module has populated ENV:BHModulePath and related variables 3 | # Publish to gallery with a few restrictions 4 | if ($StagingModulePath) { 5 | $ModuleSourcePath = $StagingModulePath 6 | } 7 | else { 8 | $ModuleSourcePath = $env:BHPSModulePath 9 | } 10 | 11 | if ( 12 | $ModuleSourcePath -and 13 | $env:BHBuildSystem -ne 'Unknown' -and 14 | $env:BHBranchName -eq "master" -and 15 | $ENV:NugetApiKey 16 | ) { 17 | Deploy Module { 18 | By PSGalleryModule { 19 | FromSource $ModuleSourcePath 20 | To PSGallery 21 | WithOptions @{ 22 | ApiKey = $ENV:NugetApiKey 23 | } 24 | } 25 | } 26 | } else { 27 | "Skipping deployment: To deploy, ensure that...`n" + 28 | "`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" + 29 | "`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" + 30 | "`t* You have access to the Nuget API key" | 31 | Write-Host 32 | } 33 | 34 | # Publish to AppVeyor if we're in AppVeyor 35 | if ($env:BHPSModulePath -and $env:BHBuildSystem -eq 'AppVeyor') { 36 | Deploy DeveloperBuild { 37 | By AppVeyorModule { 38 | FromSource $ModuleSourcePath 39 | To AppVeyor 40 | WithOptions @{ 41 | Version = $env:APPVEYOR_BUILD_VERSION 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [1.0.103] - 2024-09-07 4 | 5 | * [Feature] Added `-TrustServerCertificate` to `Write-Influx` to ignore SSL certificate validation errors. Thanks [@Max-Lyulchenko](https://github.com/max-lyulchenko)! 6 | * [Feature] Added `-SingleLineMetrics` to `Write-Influx` to combine metrics into a single call of the Influx Line Protocol. Thanks [@Max-Lyulchenko](https://github.com/max-lyulchenko)! 7 | 8 | ## [1.0.102] - 2023-05-06 9 | 10 | * [Bug] Merged fix for [#38](https://github.com/markwragg/PowerShell-Influx/issues/38) where using `Write-Influx` or `Write-InfluxUDP` without tags resulted in an error due to an empty hashtable being treated as true. Thanks [@DerT94](https://github.com/DerT94) 11 | * [Feature] Added a -BulkSize parameter to `Write-Influx` with a default of 5000 (the recommended bulk size). When using `-Bulk` writes will occur when the number of metrics in the bulk reach this size. Thanks [@DerT94](https://github.com/DerT94) 12 | 13 | ## [1.0.101] - 2021-12-11 14 | 15 | * [Feature] Added support for Influx v2.x to the `Write-Influx` cmdlet. `Write-Influx` still supports Influx v1, which is assumed if the `-Database` parameter is used. If the new `-Organisation` `-Bucket` and `-Token` parameters are used then Influx v2 is assumed. Thanks [@Robin Hermann](https://github.com/R-Studio) for contributing most of this change. 16 | 17 | ## [1.0.100] - 2020-02-21 18 | 19 | * [Bug] Merged fix [#31](https://github.com/markwragg/PowerShell-Influx/pull/31) from [@Trovalo](https://github.com/Trovalo) where `Out-InfluxEscapeString` was escaping more characters than were necessary. 20 | 21 | ## [1.0.99] - 2019-12-03 22 | 23 | * [Feature] Multiple fields for a single metric are written via a single Influx line protocol entry. 24 | * [Feature] Tags are now sorted alphabetically to improve performance. 25 | * [Bug] The full set of special characters are now escaped when writing to Influx. 26 | 27 | Thanks [@Trovalo](https://github.com/Trovalo) for these enhancements! 28 | 29 | ## [1.0.80] - 2018-08-22 30 | 31 | - [Feature] Added a `-Credential` parameter to `Write-Influx` as requested in #9. This allows `Write-Influx` to be used with instances of Influx where authentication has been enabled (disabled by default). 32 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Guidelines 4 | 5 | Contributions to this module are welcomed. Please consider the following guidance when making a contribution: 6 | 7 | - Create an Issue for any features/bugs/questions and (if you submit a code change) reference this via your Pull Request. 8 | - In general, this repository follows the guidance in the PowerShell Best Practices and Style Guide here: https://github.com/PoshCode/PowerShellPracticeAndStyle. In particular: 9 | - Use full cmdlet names 10 | - Be consistent with the existing code layout style (this is Stroustrup and its the default behaviour of the code auto-formatter for PowerShell in VSCode which I encourage you to use). 11 | - Function names should follow the Verb-Noun structure (even Private functions). 12 | - Where possible please create a Pester test to cover any code changes you make and/or modify existing tests. 13 | - Please ensure you update the comment-based help text for any new parameters you add as well as add new examples where it may be useful. 14 | 15 | ## Deployment 16 | 17 | This module uses Azure Pipelines for CI/CD. When a version of the code is ready for deployment, the following change needs to be committed in order for a new version to be deployed to the PowerShell Gallery: 18 | 19 | - Update [CHANGELOG.md](CHANGELOG.md) to have a new section, titled `## !Deploy` followed by a list of changes for the new version. 20 | 21 | As part of the CI/CD pipeline the CHANGELOG.md file will then be automatically updated with the date and version of the module deployed, replacing the `!Deploy` text. 22 | 23 | Note deployments only occur from the Master branch. 24 | -------------------------------------------------------------------------------- /Documentation/ConvertTo-InfluxLineString.md: -------------------------------------------------------------------------------- 1 | # ConvertTo-InfluxLineString 2 | 3 | ## SYNOPSIS 4 | Converts metric objects or data to the Influx line format. 5 | 6 | ## SYNTAX 7 | 8 | ### MetricObject 9 | ``` 10 | ConvertTo-InfluxLineString [-InputObject] [-ExcludeEmptyMetric] [-WhatIf] [-Confirm] 11 | [] 12 | ``` 13 | 14 | ### Measure 15 | ``` 16 | ConvertTo-InfluxLineString [-Measure] [-Tags ] -Metrics [-TimeStamp ] 17 | [-ExcludeEmptyMetric] [-WhatIf] [-Confirm] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Use to convert some metrics in to the Influx line format for later consumption in to Influx such as via the Telegraf exec plugin. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | ConvertTo-InfluxLineString -Measure WebServer -Tags @{Server='Host01'} -Metrics @{CPU=100; Memory=50} 28 | ``` 29 | 30 | Description 31 | ----------- 32 | This command will output the provided tag and metric data for a measure called 'WebServer' as strings in the Influx line format. 33 | 34 | ## PARAMETERS 35 | 36 | ### -InputObject 37 | A metric object (generated by one of the Get-*Metric cmdlets from this module) which can be provided as pipeline input. 38 | 39 | ```yaml 40 | Type: PSObject[] 41 | Parameter Sets: MetricObject 42 | Aliases: 43 | 44 | Required: True 45 | Position: 1 46 | Default value: None 47 | Accept pipeline input: True (ByValue) 48 | Accept wildcard characters: False 49 | ``` 50 | 51 | ### -Measure 52 | The name of the measure to be updated or created. 53 | 54 | ```yaml 55 | Type: String 56 | Parameter Sets: Measure 57 | Aliases: 58 | 59 | Required: True 60 | Position: 1 61 | Default value: None 62 | Accept pipeline input: False 63 | Accept wildcard characters: False 64 | ``` 65 | 66 | ### -Tags 67 | A hashtable of tag names and values. 68 | 69 | ```yaml 70 | Type: Hashtable 71 | Parameter Sets: Measure 72 | Aliases: 73 | 74 | Required: False 75 | Position: Named 76 | Default value: None 77 | Accept pipeline input: False 78 | Accept wildcard characters: False 79 | ``` 80 | 81 | ### -Metrics 82 | A hashtable of metric names and values. 83 | 84 | ```yaml 85 | Type: Hashtable 86 | Parameter Sets: Measure 87 | Aliases: 88 | 89 | Required: True 90 | Position: Named 91 | Default value: None 92 | Accept pipeline input: False 93 | Accept wildcard characters: False 94 | ``` 95 | 96 | ### -TimeStamp 97 | Specify the exact date and time for the measure data point. 98 | If not specified the current date and time is used. 99 | 100 | ```yaml 101 | Type: DateTime 102 | Parameter Sets: Measure 103 | Aliases: 104 | 105 | Required: False 106 | Position: Named 107 | Default value: None 108 | Accept pipeline input: False 109 | Accept wildcard characters: False 110 | ``` 111 | 112 | ### -ExcludeEmptyMetric 113 | Switch: Use to exclude null or empty metric values from being processed. 114 | Useful where a metric is initially created as an integer but then 115 | an empty or null instance of that metric would attempt to be sent as an empty string, resulting in a datatype conflict. 116 | 117 | ```yaml 118 | Type: SwitchParameter 119 | Parameter Sets: (All) 120 | Aliases: 121 | 122 | Required: False 123 | Position: Named 124 | Default value: False 125 | Accept pipeline input: False 126 | Accept wildcard characters: False 127 | ``` 128 | 129 | ### -WhatIf 130 | Shows what would happen if the cmdlet runs. 131 | The cmdlet is not run. 132 | 133 | ```yaml 134 | Type: SwitchParameter 135 | Parameter Sets: (All) 136 | Aliases: wi 137 | 138 | Required: False 139 | Position: Named 140 | Default value: None 141 | Accept pipeline input: False 142 | Accept wildcard characters: False 143 | ``` 144 | 145 | ### -Confirm 146 | Prompts you for confirmation before running the cmdlet. 147 | 148 | ```yaml 149 | Type: SwitchParameter 150 | Parameter Sets: (All) 151 | Aliases: cf 152 | 153 | Required: False 154 | Position: Named 155 | Default value: None 156 | Accept pipeline input: False 157 | Accept wildcard characters: False 158 | ``` 159 | 160 | ### CommonParameters 161 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 162 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 163 | 164 | ## INPUTS 165 | 166 | ## OUTPUTS 167 | 168 | ## NOTES 169 | 170 | ## RELATED LINKS 171 | -------------------------------------------------------------------------------- /Documentation/ConvertTo-Metric.md: -------------------------------------------------------------------------------- 1 | # ConvertTo-Metric 2 | 3 | ## SYNOPSIS 4 | Converts the specified properties of an object to a metric object, which can then be easily transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | ConvertTo-Metric [[-InputObject] ] -Measure -MetricProperty 10 | [-TagProperty ] [-TimeProperty ] [-Tags ] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | Use to convert any PowerShell object in to a Metric object with specified Measure name, Metrics and Tags. 15 | The metrics 16 | are one or more named properties of the object. 17 | The (optional) Tags can be one or more named properties of the object 18 | and/or a provided hashtable of custom tags. 19 | 20 | ## EXAMPLES 21 | 22 | ### EXAMPLE 1 23 | ``` 24 | Get-Process | ConvertTo-Metric -Measure Processes -MetricProperty CPU -TagProperty Name,ID -Tags @{Host = $Env:ComputerName} 25 | ``` 26 | 27 | Description 28 | ----------- 29 | This command will convert the specified object properties in to metrics and tags for a measure called 'Processes'. 30 | 31 | ## PARAMETERS 32 | 33 | ### -InputObject 34 | The object that you want to convert to a metric object. 35 | Can be provided via the pipeline. 36 | 37 | ```yaml 38 | Type: Object 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: False 43 | Position: 1 44 | Default value: None 45 | Accept pipeline input: True (ByValue) 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Measure 50 | The name of the measure to be updated or created. 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -MetricProperty 65 | One or more strings which match property names of the Input Object that you want to convert to Metrics. 66 | 67 | ```yaml 68 | Type: String[] 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: True 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -TagProperty 80 | Optional: One or more strings which match property names of the Input Object, that you want to use as Tag data. 81 | 82 | ```yaml 83 | Type: String[] 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: Named 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -TimeProperty 95 | Optional: A string that matches a property name of the Input Object, that you want to use as the TimeStamp data. 96 | 97 | ```yaml 98 | Type: String 99 | Parameter Sets: (All) 100 | Aliases: 101 | 102 | Required: False 103 | Position: Named 104 | Default value: None 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -Tags 110 | Optional: A hashtable of custom tag names and values. 111 | 112 | ```yaml 113 | Type: Hashtable 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### CommonParameters 125 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 126 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 127 | 128 | ## INPUTS 129 | 130 | ## OUTPUTS 131 | 132 | ## NOTES 133 | 134 | ## RELATED LINKS 135 | -------------------------------------------------------------------------------- /Documentation/ConvertTo-StatsDString.md: -------------------------------------------------------------------------------- 1 | # ConvertTo-StatsDString 2 | 3 | ## SYNOPSIS 4 | Converts a metric object to a StatsD format string which could be used with Write-StatsD. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | ConvertTo-StatsDString [[-InputObject] ] [-Type ] [] 10 | ``` 11 | 12 | ## DESCRIPTION 13 | This is the format a StatsD listener expects for writing metrics. 14 | 15 | ## EXAMPLES 16 | 17 | ### EXAMPLE 1 18 | ``` 19 | Get-HostMetric -Hosts somehost1 -Tags Name,PowerState | ConvertTo-StatsDString 20 | ``` 21 | 22 | Result 23 | ------------------- 24 | CpuUsageMhz,Name=somehost1,PowerState=PoweredOn:305|g 25 | MemoryUsageGB,Name=somehost1,PowerState=PoweredOn:17.0029296875|g 26 | 27 | ## PARAMETERS 28 | 29 | ### -InputObject 30 | The metric object to be converted. 31 | 32 | ```yaml 33 | Type: Object 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: None 40 | Accept pipeline input: True (ByValue) 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Type 45 | The type of StatsD metric. 46 | Default: g (gauge: will record whatever exact value is included with each metric provided). 47 | See Statsd documentation for explanations of the different metric types accepted. 48 | 49 | ```yaml 50 | Type: String 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: False 55 | Position: Named 56 | Default value: G 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ### CommonParameters 62 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 63 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 64 | 65 | ## INPUTS 66 | 67 | ## OUTPUTS 68 | 69 | ### System.String 70 | ## NOTES 71 | 72 | ## RELATED LINKS 73 | -------------------------------------------------------------------------------- /Documentation/Get-3ParSystemMetric.md: -------------------------------------------------------------------------------- 1 | # Get-3ParSystemMetric 2 | 3 | ## SYNOPSIS 4 | Returns 3Par System metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-3ParSystemMetric [[-Measure] ] [[-Tags] ] [-SANIPAddress] 10 | [-SANUserName] [-SANPwdFile] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the HPE3PARPSToolkit module from HP. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-3ParSystemMetric -Measure 'Test3PAR' -Tags System_Name,System_Model,System_ID -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return a metric object with the specified tags and 3PAR metrics for a measure called 'Test3PAR'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: 3PARSystem 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of 3PAR system tags to be included, from those returned by Get-3ParSystem. 46 | 47 | ```yaml 48 | Type: String[] 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: 2 54 | Default value: ('System_Name', 'System_Model') 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -SANIPAddress 60 | The IP address of the 3PAR SAN to be queried. 61 | 62 | ```yaml 63 | Type: String 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: True 68 | Position: 3 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -SANUserName 75 | The username for connecting to the 3PAR. 76 | 77 | ```yaml 78 | Type: String 79 | Parameter Sets: (All) 80 | Aliases: 81 | 82 | Required: True 83 | Position: 4 84 | Default value: None 85 | Accept pipeline input: False 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### -SANPwdFile 90 | The encrypted password file for connecting to the 3PAR. 91 | This should be created with Set-3parPoshSshConnectionPasswordFile. 92 | 93 | ```yaml 94 | Type: String 95 | Parameter Sets: (All) 96 | Aliases: 97 | 98 | Required: True 99 | Position: 5 100 | Default value: None 101 | Accept pipeline input: False 102 | Accept wildcard characters: False 103 | ``` 104 | 105 | ### CommonParameters 106 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 107 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 108 | 109 | ## INPUTS 110 | 111 | ## OUTPUTS 112 | 113 | ## NOTES 114 | 115 | ## RELATED LINKS 116 | -------------------------------------------------------------------------------- /Documentation/Get-3ParVirtualVolumeMetric.md: -------------------------------------------------------------------------------- 1 | # Get-3ParVirtualVolumeMetric 2 | 3 | ## SYNOPSIS 4 | Returns the 3Par Virtual Volume metrics (as returned by Get-3parStatVV) as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-3ParVirtualVolumeMetric [[-Measure] ] [-SANIPAddress] [-SANUserName] 10 | [-SANPwdFile] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the HPE3PARPSToolkit module from HP. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-3ParVirtualVolumeMetric -Measure 'Test3PARVV' -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return a PowerShell object with the 3PAR Virtual Volume metrics for a measure called 'Test3PARVV'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: 3PARVirtualVolume 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -SANIPAddress 45 | The IP address of the 3PAR SAN to be queried. 46 | 47 | ```yaml 48 | Type: String 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: True 53 | Position: 2 54 | Default value: None 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -SANUserName 60 | The username for connecting to the 3PAR. 61 | 62 | ```yaml 63 | Type: String 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: True 68 | Position: 3 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -SANPwdFile 75 | The encrypted password file for connecting to the 3PAR. 76 | This should be created with Set-3parPoshSshConnectionPasswordFile. 77 | 78 | ```yaml 79 | Type: String 80 | Parameter Sets: (All) 81 | Aliases: 82 | 83 | Required: True 84 | Position: 4 85 | Default value: None 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### CommonParameters 91 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 92 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 93 | 94 | ## INPUTS 95 | 96 | ## OUTPUTS 97 | 98 | ## NOTES 99 | 100 | ## RELATED LINKS 101 | -------------------------------------------------------------------------------- /Documentation/Get-DatacenterMetric.md: -------------------------------------------------------------------------------- 1 | # Get-DatacenterMetric 2 | 3 | ## SYNOPSIS 4 | Returns VMWare Datacenter metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-DatacenterMetric [[-Measure] ] [[-Tags] ] [[-Datacenter] ] [] 10 | ``` 11 | 12 | ## DESCRIPTION 13 | By default this cmdlet returns metrics for all Datacenters returned by Get-Datacenter. 14 | 15 | ## EXAMPLES 16 | 17 | ### EXAMPLE 1 18 | ``` 19 | Get-DatacenterMetric -Measure 'TestDatacenter' -Tags Name,NumCpuShares -Datacenter Test* 20 | ``` 21 | 22 | Description 23 | ----------- 24 | This command will return the specified tags and Datacenter metrics for a measure named 'TestDatacenter' for all Datacenters starting with 'Test' 25 | 26 | ## PARAMETERS 27 | 28 | ### -Measure 29 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 30 | 31 | ```yaml 32 | Type: String 33 | Parameter Sets: (All) 34 | Aliases: 35 | 36 | Required: False 37 | Position: 1 38 | Default value: Datacenter 39 | Accept pipeline input: False 40 | Accept wildcard characters: False 41 | ``` 42 | 43 | ### -Tags 44 | An array of Datacenter tags to be included. 45 | Default: 'Name','ParentFolder' 46 | 47 | ```yaml 48 | Type: String[] 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: 2 54 | Default value: ('Name', 'ParentFolder') 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -Datacenter 60 | One or more Datacenters to be queried. 61 | 62 | ```yaml 63 | Type: String[] 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: False 68 | Position: 3 69 | Default value: * 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### CommonParameters 75 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 76 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 77 | 78 | ## INPUTS 79 | 80 | ## OUTPUTS 81 | 82 | ## NOTES 83 | 84 | ## RELATED LINKS 85 | -------------------------------------------------------------------------------- /Documentation/Get-DatastoreClusterMetric.md: -------------------------------------------------------------------------------- 1 | # Get-DatastoreClusterMetric 2 | 3 | ## SYNOPSIS 4 | Returns Datastore Cluster metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-DatastoreClusterMetric [[-Measure] ] [[-Tags] ] [[-DatastoreCluster] ] 10 | [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet returns metrics for all Datastore Clusters returned by Get-DatastoreCluster. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-DatastoreClusterMetric -Measure 'TestDatastoreClusters' -Tags Name,Type -DatastoreCluster Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return the specified tags and DatastoreCluster metrics for a measure called 'TestDatastoreClusters' for all DatastoreClusters starting with 'Test'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: DatastoreCluster 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Datastore Cluster tags to be included. 46 | Default: 'Name' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: Name 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -DatastoreCluster 61 | One or more Datastore Clusters to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### CommonParameters 76 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 77 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 78 | 79 | ## INPUTS 80 | 81 | ## OUTPUTS 82 | 83 | ## NOTES 84 | 85 | ## RELATED LINKS 86 | -------------------------------------------------------------------------------- /Documentation/Get-DatastoreMetric.md: -------------------------------------------------------------------------------- 1 | # Get-DatastoreMetric 2 | 3 | ## SYNOPSIS 4 | Returns Datastore metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-DatastoreMetric [[-Measure] ] [[-Tags] ] [[-Datastore] ] [[-Database] ] 10 | [[-Server] ] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet returns metrics for all Datastores returned by Get-Datastore. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-DatastoreMetric -Measure 'TestDatastores' -Tags Name,Type -Datastore Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tags and datastore metrics to a measure called 'TestDatastores' for all datastores starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: Datastore 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of datastore tags to be included. 46 | Default: 'Name','ParentFolder','Type' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'ParentFolder', 'Type') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -Datastore 61 | One or more datastores to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Database 76 | The name of the Influx database to write to. 77 | Default: 'vmware'. 78 | This must exist in Influx! 79 | 80 | ```yaml 81 | Type: String 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: 4 87 | Default value: Vmware 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -Server 93 | The URL and port for the Influx REST API. 94 | Default: 'http://localhost:8086' 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Http://localhost:8086 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### CommonParameters 109 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 110 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 111 | 112 | ## INPUTS 113 | 114 | ## OUTPUTS 115 | 116 | ## NOTES 117 | 118 | ## RELATED LINKS 119 | -------------------------------------------------------------------------------- /Documentation/Get-HostMetric.md: -------------------------------------------------------------------------------- 1 | # Get-HostMetric 2 | 3 | ## SYNOPSIS 4 | Returns common ESX Host metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-HostMetric [[-Measure] ] [[-Tags] ] [[-Hosts] ] [-Stats] [] 10 | ``` 11 | 12 | ## DESCRIPTION 13 | By default this cmdlet returns metrics for all ESX hosts returned by Get-VMHost. 14 | 15 | ## EXAMPLES 16 | 17 | ### EXAMPLE 1 18 | ``` 19 | Get-HostMetric -Measure 'TestESXHosts' -Tags Name,Parent -Hosts TestHost* 20 | ``` 21 | 22 | Description 23 | ----------- 24 | This command will return the specified tag and common ESX host data for a measure called 'TestESXHosts' for all hosts starting with 'TestHost' 25 | 26 | ## PARAMETERS 27 | 28 | ### -Measure 29 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 30 | 31 | ```yaml 32 | Type: String 33 | Parameter Sets: (All) 34 | Aliases: 35 | 36 | Required: False 37 | Position: 1 38 | Default value: ESXHost 39 | Accept pipeline input: False 40 | Accept wildcard characters: False 41 | ``` 42 | 43 | ### -Tags 44 | An array of host tags to be included. 45 | Default: 'Name','Parent','State','PowerState','Version' 46 | 47 | ```yaml 48 | Type: String[] 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: 2 54 | Default value: ('Name', 'Parent', 'State', 'PowerState', 'Version') 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -Hosts 60 | One or more hosts to be queried. 61 | 62 | ```yaml 63 | Type: String[] 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: False 68 | Position: 3 69 | Default value: * 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -Stats 75 | Use this switch if you want to collect common host stats using Get-Stat. 76 | 77 | ```yaml 78 | Type: SwitchParameter 79 | Parameter Sets: (All) 80 | Aliases: 81 | 82 | Required: False 83 | Position: Named 84 | Default value: False 85 | Accept pipeline input: False 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### CommonParameters 90 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 91 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 92 | 93 | ## INPUTS 94 | 95 | ## OUTPUTS 96 | 97 | ## NOTES 98 | 99 | ## RELATED LINKS 100 | -------------------------------------------------------------------------------- /Documentation/Get-IsilonStoragePoolMetric.md: -------------------------------------------------------------------------------- 1 | # Get-IsilonStoragePoolMetric 2 | 3 | ## SYNOPSIS 4 | Returns Isilon Storage Pool usage metrics returned by the Get-isiStoragepools cmdlet as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-IsilonStoragePoolMetric [[-Measure] ] [-IsilonName] [-IsilonPwdFile] 10 | [-ClusterName] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the IsilonPlatform module from the PSGallery. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-IsilonStoragePoolMetric -Measure 'TestIsilonSP' -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return a PowerShell object with the specified Isilon's Storage Pool metrics for a measure called 'TestIsilonSP'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: IsilonStoragePool 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -IsilonName 45 | The name or IP address of the Isilon to be queried. 46 | 47 | ```yaml 48 | Type: String 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: True 53 | Position: 2 54 | Default value: None 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -IsilonPwdFile 60 | The encrypted credentials file for connecting to the Isilon. 61 | This should be created with Get-Credential | Export-Clixml. 62 | 63 | ```yaml 64 | Type: String 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: True 69 | Position: 3 70 | Default value: None 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -ClusterName 76 | A descriptive name for the Isilon Cluster. 77 | This can be anything and is used for the Cluster tag field. 78 | 79 | ```yaml 80 | Type: String 81 | Parameter Sets: (All) 82 | Aliases: 83 | 84 | Required: True 85 | Position: 4 86 | Default value: None 87 | Accept pipeline input: False 88 | Accept wildcard characters: False 89 | ``` 90 | 91 | ### CommonParameters 92 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 93 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 94 | 95 | ## INPUTS 96 | 97 | ## OUTPUTS 98 | 99 | ## NOTES 100 | 101 | ## RELATED LINKS 102 | -------------------------------------------------------------------------------- /Documentation/Get-ResourcePoolMetric.md: -------------------------------------------------------------------------------- 1 | # Get-ResourcePoolMetric 2 | 3 | ## SYNOPSIS 4 | Returns Resource Pool metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-ResourcePoolMetric [[-Measure] ] [[-Tags] ] [[-ResourcePool] ] 10 | [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet returns metrics for all Resource Pools returned by Get-ResourcePool. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-ResourcePoolMetric -Measure 'TestResources' -Tags Name,NumCpuShares -ResourcePool Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return the specified tags and resource pool metrics for a measure called 'TestResources' for all resource pools starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: ResourcePool 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Resource Pool tags to be included. 46 | Default: 'Name','Parent' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'Parent') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -ResourcePool 61 | One or more Resource Pools to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### CommonParameters 76 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 77 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 78 | 79 | ## INPUTS 80 | 81 | ## OUTPUTS 82 | 83 | ## NOTES 84 | 85 | ## RELATED LINKS 86 | -------------------------------------------------------------------------------- /Documentation/Get-TFSBuildMetric.md: -------------------------------------------------------------------------------- 1 | # Get-TFSBuildMetric 2 | 3 | ## SYNOPSIS 4 | Returns TFS Build metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-TFSBuildMetric [[-Measure] ] [[-Tags] ] [[-Top] ] [-Latest] [-TFSRootURL] 10 | [-TFSCollection] [-TFSProject] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the TFS module (install via Install-Module TFS). 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Get-TFSBuildMetric -Measure 'TestTFS' -Tags Name,Author -TFSRootURL https://localhost:8088/tfs -TFSCollection MyCollection -TFSProject MyProject 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will return the specified tags and build metrics of a measure called 'TestTFS' as a PowerShell object. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: TFSBuild 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Build definition properties to be included, from those returned by Get-TfsBuildDefinitions. 46 | 47 | ```yaml 48 | Type: String[] 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: 2 54 | Default value: ('Definition', 'Id', 'Result') 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -Top 60 | An integer defining the number of most recent builds to return. 61 | Default: 100. 62 | 63 | ```yaml 64 | Type: Int32 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: 100 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Latest 76 | Switch parameter. 77 | When used returns only the most recent build for each distinct definition. 78 | 79 | ```yaml 80 | Type: SwitchParameter 81 | Parameter Sets: (All) 82 | Aliases: 83 | 84 | Required: False 85 | Position: Named 86 | Default value: False 87 | Accept pipeline input: False 88 | Accept wildcard characters: False 89 | ``` 90 | 91 | ### -TFSRootURL 92 | The root URL for TFS, e.g https://yourserver.yoursite.com/TFS 93 | 94 | ```yaml 95 | Type: String 96 | Parameter Sets: (All) 97 | Aliases: 98 | 99 | Required: True 100 | Position: 4 101 | Default value: None 102 | Accept pipeline input: False 103 | Accept wildcard characters: False 104 | ``` 105 | 106 | ### -TFSCollection 107 | The name of the TFS collection to query. 108 | 109 | ```yaml 110 | Type: String 111 | Parameter Sets: (All) 112 | Aliases: 113 | 114 | Required: True 115 | Position: 5 116 | Default value: None 117 | Accept pipeline input: False 118 | Accept wildcard characters: False 119 | ``` 120 | 121 | ### -TFSProject 122 | The name of the TFS project to query. 123 | 124 | ```yaml 125 | Type: String 126 | Parameter Sets: (All) 127 | Aliases: 128 | 129 | Required: True 130 | Position: 6 131 | Default value: None 132 | Accept pipeline input: False 133 | Accept wildcard characters: False 134 | ``` 135 | 136 | ### CommonParameters 137 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 138 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 139 | 140 | ## INPUTS 141 | 142 | ## OUTPUTS 143 | 144 | ## NOTES 145 | 146 | ## RELATED LINKS 147 | -------------------------------------------------------------------------------- /Documentation/Get-VMMetric.md: -------------------------------------------------------------------------------- 1 | # Get-VMMetric 2 | 3 | ## SYNOPSIS 4 | Returns Virtual Machine metrics as a metric object which can then be transmitted to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Get-VMMetric [[-Measure] ] [[-Tags] ] [[-VMs] ] [-Stats] [] 10 | ``` 11 | 12 | ## DESCRIPTION 13 | By default this cmdlet returns metrics for all Virtual Machines returned by Get-VM. 14 | 15 | ## EXAMPLES 16 | 17 | ### EXAMPLE 1 18 | ``` 19 | Get-VMMetric -Measure 'TestVirtualMachines' -Tags Name,ResourcePool -Hosts TestVM* 20 | ``` 21 | 22 | Description 23 | ----------- 24 | This command will return the specified tag and common VM host data for a measure called 'TestVirtualMachines' for all VMs starting with 'TestVM' 25 | 26 | ## PARAMETERS 27 | 28 | ### -Measure 29 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 30 | 31 | ```yaml 32 | Type: String 33 | Parameter Sets: (All) 34 | Aliases: 35 | 36 | Required: False 37 | Position: 1 38 | Default value: VirtualMachine 39 | Accept pipeline input: False 40 | Accept wildcard characters: False 41 | ``` 42 | 43 | ### -Tags 44 | An array of virtual machine tags to be included. 45 | Default: 'Name','Folder','ResourcePool','PowerState','Guest','VMHost' 46 | 47 | ```yaml 48 | Type: String[] 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: False 53 | Position: 2 54 | Default value: ('Name', 'Folder', 'ResourcePool', 'PowerState', 'Guest', 'VMHost') 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -VMs 60 | One or more Virtual Machines to be queried. 61 | 62 | ```yaml 63 | Type: String[] 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: False 68 | Position: 3 69 | Default value: * 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -Stats 75 | Use to enable the collection of VM statistics via Get-Stat for each VM. 76 | 77 | ```yaml 78 | Type: SwitchParameter 79 | Parameter Sets: (All) 80 | Aliases: 81 | 82 | Required: False 83 | Position: Named 84 | Default value: False 85 | Accept pipeline input: False 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### CommonParameters 90 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 91 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 92 | 93 | ## INPUTS 94 | 95 | ## OUTPUTS 96 | 97 | ## NOTES 98 | 99 | ## RELATED LINKS 100 | -------------------------------------------------------------------------------- /Documentation/Send-3ParSystemMetric.md: -------------------------------------------------------------------------------- 1 | # Send-3ParSystemMetric 2 | 3 | ## SYNOPSIS 4 | Sends 3Par System metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-3ParSystemMetric [[-Measure] ] [[-Tags] ] [-SANIPAddress] 10 | [-SANUserName] [-SANPwdFile] [[-Database] ] [[-Server] ] [-WhatIf] 11 | [-Confirm] [] 12 | ``` 13 | 14 | ## DESCRIPTION 15 | This function requires the HPE3PARPSToolkit module from HP. 16 | 17 | ## EXAMPLES 18 | 19 | ### EXAMPLE 1 20 | ``` 21 | Send-3ParSystemMetric -Measure 'Test3PAR' -Tags System_Name,System_Model,System_ID -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 22 | ``` 23 | 24 | Description 25 | ----------- 26 | This command will submit the specified tags and 3PAR metrics to a measure called 'Test3PAR'. 27 | 28 | ## PARAMETERS 29 | 30 | ### -Measure 31 | The name of the measure to be updated or created. 32 | 33 | ```yaml 34 | Type: String 35 | Parameter Sets: (All) 36 | Aliases: 37 | 38 | Required: False 39 | Position: 1 40 | Default value: 3PARSystem 41 | Accept pipeline input: False 42 | Accept wildcard characters: False 43 | ``` 44 | 45 | ### -Tags 46 | An array of 3PAR system tags to be included, from those returned by Get-3ParSystem. 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('System_Name', 'System_Model') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -SANIPAddress 61 | The IP address of the 3PAR SAN to be queried. 62 | 63 | ```yaml 64 | Type: String 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: True 69 | Position: 3 70 | Default value: None 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -SANUserName 76 | The username for connecting to the 3PAR. 77 | 78 | ```yaml 79 | Type: String 80 | Parameter Sets: (All) 81 | Aliases: 82 | 83 | Required: True 84 | Position: 4 85 | Default value: None 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### -SANPwdFile 91 | The encrypted password file for connecting to the 3PAR. 92 | This should be created with Set-3parPoshSshConnectionPasswordFile. 93 | 94 | ```yaml 95 | Type: String 96 | Parameter Sets: (All) 97 | Aliases: 98 | 99 | Required: True 100 | Position: 5 101 | Default value: None 102 | Accept pipeline input: False 103 | Accept wildcard characters: False 104 | ``` 105 | 106 | ### -Database 107 | The name of the Influx database to write to. 108 | Default: 'storage'. 109 | This must exist in Influx! 110 | 111 | ```yaml 112 | Type: String 113 | Parameter Sets: (All) 114 | Aliases: 115 | 116 | Required: False 117 | Position: 6 118 | Default value: Storage 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -Server 124 | The URL and port for the Influx REST API. 125 | Default: 'http://localhost:8086' 126 | 127 | ```yaml 128 | Type: String 129 | Parameter Sets: (All) 130 | Aliases: 131 | 132 | Required: False 133 | Position: 7 134 | Default value: Http://localhost:8086 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### -WhatIf 140 | Shows what would happen if the cmdlet runs. 141 | The cmdlet is not run. 142 | 143 | ```yaml 144 | Type: SwitchParameter 145 | Parameter Sets: (All) 146 | Aliases: wi 147 | 148 | Required: False 149 | Position: Named 150 | Default value: None 151 | Accept pipeline input: False 152 | Accept wildcard characters: False 153 | ``` 154 | 155 | ### -Confirm 156 | Prompts you for confirmation before running the cmdlet. 157 | 158 | ```yaml 159 | Type: SwitchParameter 160 | Parameter Sets: (All) 161 | Aliases: cf 162 | 163 | Required: False 164 | Position: Named 165 | Default value: None 166 | Accept pipeline input: False 167 | Accept wildcard characters: False 168 | ``` 169 | 170 | ### CommonParameters 171 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 172 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 173 | 174 | ## INPUTS 175 | 176 | ## OUTPUTS 177 | 178 | ## NOTES 179 | 180 | ## RELATED LINKS 181 | -------------------------------------------------------------------------------- /Documentation/Send-3ParVirtualVolumeMetric.md: -------------------------------------------------------------------------------- 1 | # Send-3ParVirtualVolumeMetric 2 | 3 | ## SYNOPSIS 4 | Sends the 3Par Virtual Volume metrics returned by Get-3parStatVV to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-3ParVirtualVolumeMetric [[-Measure] ] [-SANIPAddress] [-SANUserName] 10 | [-SANPwdFile] [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the HPE3PARPSToolkit module from HP. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-3ParVirtualVolumeMetric -Measure 'Test3PARVV' -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the 3PAR Virtual Volume metrics to a measure called 'Test3PARVV'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: 3PARVirtualVolume 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -SANIPAddress 45 | The IP address of the 3PAR SAN to be queried. 46 | 47 | ```yaml 48 | Type: String 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: True 53 | Position: 2 54 | Default value: None 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -SANUserName 60 | The username for connecting to the 3PAR. 61 | 62 | ```yaml 63 | Type: String 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: True 68 | Position: 3 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -SANPwdFile 75 | The encrypted password file for connecting to the 3PAR. 76 | This should be created with Set-3parPoshSshConnectionPasswordFile. 77 | 78 | ```yaml 79 | Type: String 80 | Parameter Sets: (All) 81 | Aliases: 82 | 83 | Required: True 84 | Position: 4 85 | Default value: None 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### -Database 91 | The name of the Influx database to write to. 92 | Default: 'storage'. 93 | This must exist in Influx! 94 | 95 | ```yaml 96 | Type: String 97 | Parameter Sets: (All) 98 | Aliases: 99 | 100 | Required: False 101 | Position: 5 102 | Default value: Storage 103 | Accept pipeline input: False 104 | Accept wildcard characters: False 105 | ``` 106 | 107 | ### -Server 108 | The URL and port for the Influx REST API. 109 | Default: 'http://localhost:8086' 110 | 111 | ```yaml 112 | Type: String 113 | Parameter Sets: (All) 114 | Aliases: 115 | 116 | Required: False 117 | Position: 6 118 | Default value: Http://localhost:8086 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -WhatIf 124 | Shows what would happen if the cmdlet runs. 125 | The cmdlet is not run. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: wi 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### -Confirm 140 | Prompts you for confirmation before running the cmdlet. 141 | 142 | ```yaml 143 | Type: SwitchParameter 144 | Parameter Sets: (All) 145 | Aliases: cf 146 | 147 | Required: False 148 | Position: Named 149 | Default value: None 150 | Accept pipeline input: False 151 | Accept wildcard characters: False 152 | ``` 153 | 154 | ### CommonParameters 155 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 156 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 157 | 158 | ## INPUTS 159 | 160 | ## OUTPUTS 161 | 162 | ## NOTES 163 | 164 | ## RELATED LINKS 165 | -------------------------------------------------------------------------------- /Documentation/Send-DatacenterMetric.md: -------------------------------------------------------------------------------- 1 | # Send-DatacenterMetric 2 | 3 | ## SYNOPSIS 4 | Sends Datacenter metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-DatacenterMetric [[-Measure] ] [[-Tags] ] [[-Datacenter] ] 10 | [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all Datacenter returned by Get-Datacenter. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-DatacenterMetric -Measure 'TestDatacenter' -Tags Name,NumCpuShares -Datacenter Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tags and Datacenter metrics to a measure called 'TestDatacenter' for all Datacenters starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: Datacenter 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Datacenter tags to be included. 46 | Default: 'Name','ParentFolder' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'ParentFolder') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -Datacenter 61 | One or more Datacenters to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Database 76 | The name of the Influx database to write to. 77 | Default: 'vmware'. 78 | This must exist in Influx! 79 | 80 | ```yaml 81 | Type: String 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: 4 87 | Default value: Vmware 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -Server 93 | The URL and port for the Influx REST API. 94 | Default: 'http://localhost:8086' 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Http://localhost:8086 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -WhatIf 109 | Shows what would happen if the cmdlet runs. 110 | The cmdlet is not run. 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: wi 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Confirm 125 | Prompts you for confirmation before running the cmdlet. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: cf 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 141 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ## NOTES 148 | 149 | ## RELATED LINKS 150 | -------------------------------------------------------------------------------- /Documentation/Send-DatastoreClusterMetric.md: -------------------------------------------------------------------------------- 1 | # Send-DatastoreClusterMetric 2 | 3 | ## SYNOPSIS 4 | Sends Datastore Cluster metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-DatastoreClusterMetric [[-Measure] ] [[-Tags] ] [[-DatastoreCluster] ] 10 | [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all Datastore Clusters returned by Get-DatastoreCluster. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-DatastoreClusterMetric -Measure 'TestDatastoreClusters' -Tags Name,Type -DatastoreCluster Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tags and DatastoreCluster metrics to a measure called 'TestDatastoreClusters' for all DatastoreClusters starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: DatastoreCluster 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Datastore Cluster tags to be included. 46 | Default: 'Name' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: Name 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -DatastoreCluster 61 | One or more Datastore Clusters to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Database 76 | The name of the Influx database to write to. 77 | Default: 'vmware'. 78 | This must exist in Influx! 79 | 80 | ```yaml 81 | Type: String 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: 4 87 | Default value: Vmware 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -Server 93 | The URL and port for the Influx REST API. 94 | Default: 'http://localhost:8086' 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Http://localhost:8086 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -WhatIf 109 | Shows what would happen if the cmdlet runs. 110 | The cmdlet is not run. 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: wi 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Confirm 125 | Prompts you for confirmation before running the cmdlet. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: cf 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 141 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ## NOTES 148 | 149 | ## RELATED LINKS 150 | -------------------------------------------------------------------------------- /Documentation/Send-DatastoreMetric.md: -------------------------------------------------------------------------------- 1 | # Send-DatastoreMetric 2 | 3 | ## SYNOPSIS 4 | Sends Datastore metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-DatastoreMetric [[-Measure] ] [[-Tags] ] [[-Datastore] ] 10 | [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all Datastores returned by Get-Datastore. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-DatastoreMetric -Measure 'TestDatastores' -Tags Name,Type -Datastore Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tags and datastore metrics to a measure called 'TestDatastores' for all datastores starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: Datastore 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of datastore tags to be included. 46 | Default: 'Name','ParentFolder','Type' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'ParentFolder', 'Type') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -Datastore 61 | One or more datastores to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Database 76 | The name of the Influx database to write to. 77 | Default: 'vmware'. 78 | This must exist in Influx! 79 | 80 | ```yaml 81 | Type: String 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: 4 87 | Default value: Vmware 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -Server 93 | The URL and port for the Influx REST API. 94 | Default: 'http://localhost:8086' 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Http://localhost:8086 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -WhatIf 109 | Shows what would happen if the cmdlet runs. 110 | The cmdlet is not run. 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: wi 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Confirm 125 | Prompts you for confirmation before running the cmdlet. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: cf 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 141 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ## NOTES 148 | 149 | ## RELATED LINKS 150 | -------------------------------------------------------------------------------- /Documentation/Send-HostMetric.md: -------------------------------------------------------------------------------- 1 | # Send-HostMetric 2 | 3 | ## SYNOPSIS 4 | Sends common ESX Host metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-HostMetric [[-Measure] ] [[-Tags] ] [[-Hosts] ] [-Stats] 10 | [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all ESX hosts returned by Get-VMHost. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-HostMetric -Measure 'TestESXHosts' -Tags Name,Parent -Hosts TestHost* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tag and common ESX host data to a measure called 'TestESXHosts' for all hosts starting with 'TestHost' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: ESXHost 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of host tags to be included. 46 | Default: 'Name','Parent','State','PowerState','Version' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'Parent', 'State', 'PowerState', 'Version') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -Hosts 61 | One or more hosts to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Stats 76 | Use this switch if you want to collect common host stats using Get-Stat. 77 | 78 | ```yaml 79 | Type: SwitchParameter 80 | Parameter Sets: (All) 81 | Aliases: 82 | 83 | Required: False 84 | Position: Named 85 | Default value: False 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### -Database 91 | The name of the Influx database to write to. 92 | Default: 'vmware'. 93 | This must exist in Influx! 94 | 95 | ```yaml 96 | Type: String 97 | Parameter Sets: (All) 98 | Aliases: 99 | 100 | Required: False 101 | Position: 4 102 | Default value: Vmware 103 | Accept pipeline input: False 104 | Accept wildcard characters: False 105 | ``` 106 | 107 | ### -Server 108 | The URL and port for the Influx REST API. 109 | Default: 'http://localhost:8086' 110 | 111 | ```yaml 112 | Type: String 113 | Parameter Sets: (All) 114 | Aliases: 115 | 116 | Required: False 117 | Position: 5 118 | Default value: Http://localhost:8086 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -WhatIf 124 | Shows what would happen if the cmdlet runs. 125 | The cmdlet is not run. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: wi 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### -Confirm 140 | Prompts you for confirmation before running the cmdlet. 141 | 142 | ```yaml 143 | Type: SwitchParameter 144 | Parameter Sets: (All) 145 | Aliases: cf 146 | 147 | Required: False 148 | Position: Named 149 | Default value: None 150 | Accept pipeline input: False 151 | Accept wildcard characters: False 152 | ``` 153 | 154 | ### CommonParameters 155 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 156 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 157 | 158 | ## INPUTS 159 | 160 | ## OUTPUTS 161 | 162 | ## NOTES 163 | 164 | ## RELATED LINKS 165 | -------------------------------------------------------------------------------- /Documentation/Send-IsilonStoragePoolMetric.md: -------------------------------------------------------------------------------- 1 | # Send-IsilonStoragePoolMetric 2 | 3 | ## SYNOPSIS 4 | Sends Isilon Storage Pool usage metrics returned by the Get-isiStoragepools cmdlet from the IsilonPlatform module to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-IsilonStoragePoolMetric [[-Measure] ] [-IsilonName] [-IsilonPwdFile] 10 | [-ClusterName] [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | This function requires the IsilonPlatform module from the PSGallery. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-IsilonStoragePoolMetric -Measure 'TestIsilonSP' -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified Isilon's Storage Pool metrics to a measure called 'TestIsilonSP'. 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: IsilonStoragePool 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -IsilonName 45 | The name or IP address of the Isilon to be queried. 46 | 47 | ```yaml 48 | Type: String 49 | Parameter Sets: (All) 50 | Aliases: 51 | 52 | Required: True 53 | Position: 2 54 | Default value: None 55 | Accept pipeline input: False 56 | Accept wildcard characters: False 57 | ``` 58 | 59 | ### -IsilonPwdFile 60 | The encrypted credentials file for connecting to the Isilon. 61 | This should be created with Get-Credential | Export-Clixml. 62 | 63 | ```yaml 64 | Type: String 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: True 69 | Position: 3 70 | Default value: None 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -ClusterName 76 | A descriptive name for the Isilon Cluster. 77 | This can be anything and is used for the Cluster tag field. 78 | 79 | ```yaml 80 | Type: String 81 | Parameter Sets: (All) 82 | Aliases: 83 | 84 | Required: True 85 | Position: 4 86 | Default value: None 87 | Accept pipeline input: False 88 | Accept wildcard characters: False 89 | ``` 90 | 91 | ### -Database 92 | The name of the Influx database to write to. 93 | Default: 'storage'. 94 | This must exist in Influx! 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Storage 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -Server 109 | The URL and port for the Influx REST API. 110 | Default: 'http://localhost:8086' 111 | 112 | ```yaml 113 | Type: String 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: 6 119 | Default value: Http://localhost:8086 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -WhatIf 125 | Shows what would happen if the cmdlet runs. 126 | The cmdlet is not run. 127 | 128 | ```yaml 129 | Type: SwitchParameter 130 | Parameter Sets: (All) 131 | Aliases: wi 132 | 133 | Required: False 134 | Position: Named 135 | Default value: None 136 | Accept pipeline input: False 137 | Accept wildcard characters: False 138 | ``` 139 | 140 | ### -Confirm 141 | Prompts you for confirmation before running the cmdlet. 142 | 143 | ```yaml 144 | Type: SwitchParameter 145 | Parameter Sets: (All) 146 | Aliases: cf 147 | 148 | Required: False 149 | Position: Named 150 | Default value: None 151 | Accept pipeline input: False 152 | Accept wildcard characters: False 153 | ``` 154 | 155 | ### CommonParameters 156 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 157 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 158 | 159 | ## INPUTS 160 | 161 | ## OUTPUTS 162 | 163 | ## NOTES 164 | 165 | ## RELATED LINKS 166 | -------------------------------------------------------------------------------- /Documentation/Send-ResourcePoolMetric.md: -------------------------------------------------------------------------------- 1 | # Send-ResourcePoolMetric 2 | 3 | ## SYNOPSIS 4 | Sends Resource Pool metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-ResourcePoolMetric [[-Measure] ] [[-Tags] ] [[-ResourcePool] ] 10 | [[-Database] ] [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all Resource Pool returned by Get-ResourcePool. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-ResourcePoolMetric -Measure 'TestResources' -Tags Name,NumCpuShares -ResourcePool Test* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tags and resource pool metrics to a measure called 'TestResources' for all resource pools starting with 'Test' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: ResourcePool 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of Resource Pool tags to be included. 46 | Default: 'Name','Parent' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'Parent') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -ResourcePool 61 | One or more Resource Pools to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Database 76 | The name of the Influx database to write to. 77 | Default: 'vmware'. 78 | This must exist in Influx! 79 | 80 | ```yaml 81 | Type: String 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: 4 87 | Default value: Vmware 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -Server 93 | The URL and port for the Influx REST API. 94 | Default: 'http://localhost:8086' 95 | 96 | ```yaml 97 | Type: String 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: 5 103 | Default value: Http://localhost:8086 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -WhatIf 109 | Shows what would happen if the cmdlet runs. 110 | The cmdlet is not run. 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: wi 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Confirm 125 | Prompts you for confirmation before running the cmdlet. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: cf 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 141 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ## NOTES 148 | 149 | ## RELATED LINKS 150 | -------------------------------------------------------------------------------- /Documentation/Send-TFSBuildMetric.md: -------------------------------------------------------------------------------- 1 | # Send-TFSBuildMetric 2 | 3 | ## SYNOPSIS 4 | Sends TFS Build metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-TFSBuildMetric [[-Measure] ] [[-Tags] ] [[-Top] ] [-Latest] 10 | [-TFSRootURL] [-TFSCollection] [-TFSProject] [[-Database] ] 11 | [[-Server] ] [-WhatIf] [-Confirm] [] 12 | ``` 13 | 14 | ## DESCRIPTION 15 | This function requires the TFS module (install via Install-Module TFS). 16 | 17 | ## EXAMPLES 18 | 19 | ### EXAMPLE 1 20 | ``` 21 | Send-TFSBuildMetric -Measure 'TestTFS' -Tags Name,Author -TFSRootURL https://localhost:8088/tfs -TFSCollection MyCollection -TFSProject MyProject 22 | ``` 23 | 24 | Description 25 | ----------- 26 | This command will submit the specified tags and Build metrics to a measure called 'TestTFS'. 27 | 28 | ## PARAMETERS 29 | 30 | ### -Measure 31 | The name of the measure to be updated or created. 32 | 33 | ```yaml 34 | Type: String 35 | Parameter Sets: (All) 36 | Aliases: 37 | 38 | Required: False 39 | Position: 1 40 | Default value: TFSBuild 41 | Accept pipeline input: False 42 | Accept wildcard characters: False 43 | ``` 44 | 45 | ### -Tags 46 | An array of Build definition properties to be included, from those returned by Get-TfsBuildDefinitions. 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Definition', 'Id', 'Result') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -Top 61 | An integer defining the number of most recent builds to return. 62 | Default: 100. 63 | 64 | ```yaml 65 | Type: Int32 66 | Parameter Sets: (All) 67 | Aliases: 68 | 69 | Required: False 70 | Position: 3 71 | Default value: 100 72 | Accept pipeline input: False 73 | Accept wildcard characters: False 74 | ``` 75 | 76 | ### -Latest 77 | Switch parameter. 78 | When used returns only the most recent build for each distinct definition. 79 | 80 | ```yaml 81 | Type: SwitchParameter 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: Named 87 | Default value: False 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### -TFSRootURL 93 | The root URL for TFS, e.g https://yourserver.yoursite.com/TFS 94 | 95 | ```yaml 96 | Type: String 97 | Parameter Sets: (All) 98 | Aliases: 99 | 100 | Required: True 101 | Position: 4 102 | Default value: None 103 | Accept pipeline input: False 104 | Accept wildcard characters: False 105 | ``` 106 | 107 | ### -TFSCollection 108 | The name of the TFS collection to query. 109 | 110 | ```yaml 111 | Type: String 112 | Parameter Sets: (All) 113 | Aliases: 114 | 115 | Required: True 116 | Position: 5 117 | Default value: None 118 | Accept pipeline input: False 119 | Accept wildcard characters: False 120 | ``` 121 | 122 | ### -TFSProject 123 | The name of the TFS project to query. 124 | 125 | ```yaml 126 | Type: String 127 | Parameter Sets: (All) 128 | Aliases: 129 | 130 | Required: True 131 | Position: 6 132 | Default value: None 133 | Accept pipeline input: False 134 | Accept wildcard characters: False 135 | ``` 136 | 137 | ### -Database 138 | The name of the Influx database to write to. 139 | Default: 'TFS'. 140 | This must exist in Influx! 141 | 142 | ```yaml 143 | Type: String 144 | Parameter Sets: (All) 145 | Aliases: 146 | 147 | Required: False 148 | Position: 7 149 | Default value: Tfs 150 | Accept pipeline input: False 151 | Accept wildcard characters: False 152 | ``` 153 | 154 | ### -Server 155 | The URL and port for the Influx REST API. 156 | Default: 'http://localhost:8086' 157 | 158 | ```yaml 159 | Type: String 160 | Parameter Sets: (All) 161 | Aliases: 162 | 163 | Required: False 164 | Position: 8 165 | Default value: Http://localhost:8086 166 | Accept pipeline input: False 167 | Accept wildcard characters: False 168 | ``` 169 | 170 | ### -WhatIf 171 | Shows what would happen if the cmdlet runs. 172 | The cmdlet is not run. 173 | 174 | ```yaml 175 | Type: SwitchParameter 176 | Parameter Sets: (All) 177 | Aliases: wi 178 | 179 | Required: False 180 | Position: Named 181 | Default value: None 182 | Accept pipeline input: False 183 | Accept wildcard characters: False 184 | ``` 185 | 186 | ### -Confirm 187 | Prompts you for confirmation before running the cmdlet. 188 | 189 | ```yaml 190 | Type: SwitchParameter 191 | Parameter Sets: (All) 192 | Aliases: cf 193 | 194 | Required: False 195 | Position: Named 196 | Default value: None 197 | Accept pipeline input: False 198 | Accept wildcard characters: False 199 | ``` 200 | 201 | ### CommonParameters 202 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 203 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 204 | 205 | ## INPUTS 206 | 207 | ## OUTPUTS 208 | 209 | ## NOTES 210 | 211 | ## RELATED LINKS 212 | -------------------------------------------------------------------------------- /Documentation/Send-VMMetric.md: -------------------------------------------------------------------------------- 1 | # Send-VMMetric 2 | 3 | ## SYNOPSIS 4 | Sends Virtual Machine metrics to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ``` 9 | Send-VMMetric [[-Measure] ] [[-Tags] ] [[-VMs] ] [-Stats] [[-Database] ] 10 | [[-Server] ] [-WhatIf] [-Confirm] [] 11 | ``` 12 | 13 | ## DESCRIPTION 14 | By default this cmdlet sends metrics for all Virtual Machines returned by Get-VM. 15 | 16 | ## EXAMPLES 17 | 18 | ### EXAMPLE 1 19 | ``` 20 | Send-VMMetric -Measure 'TestVirtualMachines' -Tags Name,ResourcePool -Hosts TestVM* 21 | ``` 22 | 23 | Description 24 | ----------- 25 | This command will submit the specified tag and common VM host data to a measure called 'TestVirtualMachines' for all VMs starting with 'TestVM' 26 | 27 | ## PARAMETERS 28 | 29 | ### -Measure 30 | The name of the measure to be updated or created. 31 | 32 | ```yaml 33 | Type: String 34 | Parameter Sets: (All) 35 | Aliases: 36 | 37 | Required: False 38 | Position: 1 39 | Default value: VirtualMachine 40 | Accept pipeline input: False 41 | Accept wildcard characters: False 42 | ``` 43 | 44 | ### -Tags 45 | An array of virtual machine tags to be included. 46 | Default: 'Name','Folder','ResourcePool','PowerState','Guest','VMHost' 47 | 48 | ```yaml 49 | Type: String[] 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 2 55 | Default value: ('Name', 'Folder', 'ResourcePool', 'PowerState', 'Guest', 'VMHost') 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### -VMs 61 | One or more Virtual Machines to be queried. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 3 70 | Default value: * 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Stats 76 | Use to enable the collection of VM statistics via Get-Stat for each VM. 77 | 78 | ```yaml 79 | Type: SwitchParameter 80 | Parameter Sets: (All) 81 | Aliases: 82 | 83 | Required: False 84 | Position: Named 85 | Default value: False 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### -Database 91 | The name of the Influx database to write to. 92 | Default: 'vmware'. 93 | This must exist in Influx! 94 | 95 | ```yaml 96 | Type: String 97 | Parameter Sets: (All) 98 | Aliases: 99 | 100 | Required: False 101 | Position: 4 102 | Default value: Vmware 103 | Accept pipeline input: False 104 | Accept wildcard characters: False 105 | ``` 106 | 107 | ### -Server 108 | The URL and port for the Influx REST API. 109 | Default: 'http://localhost:8086' 110 | 111 | ```yaml 112 | Type: String 113 | Parameter Sets: (All) 114 | Aliases: 115 | 116 | Required: False 117 | Position: 5 118 | Default value: Http://localhost:8086 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -WhatIf 124 | Shows what would happen if the cmdlet runs. 125 | The cmdlet is not run. 126 | 127 | ```yaml 128 | Type: SwitchParameter 129 | Parameter Sets: (All) 130 | Aliases: wi 131 | 132 | Required: False 133 | Position: Named 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### -Confirm 140 | Prompts you for confirmation before running the cmdlet. 141 | 142 | ```yaml 143 | Type: SwitchParameter 144 | Parameter Sets: (All) 145 | Aliases: cf 146 | 147 | Required: False 148 | Position: Named 149 | Default value: None 150 | Accept pipeline input: False 151 | Accept wildcard characters: False 152 | ``` 153 | 154 | ### CommonParameters 155 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 156 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 157 | 158 | ## INPUTS 159 | 160 | ## OUTPUTS 161 | 162 | ## NOTES 163 | 164 | ## RELATED LINKS 165 | -------------------------------------------------------------------------------- /Documentation/Write-InfluxUDP.md: -------------------------------------------------------------------------------- 1 | # Write-InfluxUDP 2 | 3 | ## SYNOPSIS 4 | Send metrics to the Influx UDP listener (UDP must be enabled in influxdb.conf) for writing to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ### MetricObject 9 | ``` 10 | Write-InfluxUDP [-InputObject] [-IP ] [-Port ] [-ExcludeEmptyMetric] [-WhatIf] 11 | [-Confirm] [] 12 | ``` 13 | 14 | ### Measure 15 | ``` 16 | Write-InfluxUDP [-Measure] [-Tags ] -Metrics [-TimeStamp ] 17 | [-IP ] [-Port ] [-ExcludeEmptyMetric] [-WhatIf] [-Confirm] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Use to write data in to an Influx database via UDP by providing a hashtable of tags and values. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Write-InfluxUDP -Measure WebServer -Tags @{Server='Host01'} -Metrics @{CPU=100; Memory=50} -IP 1.2.3.4 -Port 8089 28 | ``` 29 | 30 | Description 31 | ----------- 32 | This command will submit the provided tag and metric data for a measure called 'WebServer' via the endpoint 'udp://1.2.3.4:8089' 33 | 34 | ## PARAMETERS 35 | 36 | ### -InputObject 37 | A metric object (generated by one of the Get-*Metric cmdlets from this module) which can be provided as pipeline input. 38 | 39 | ```yaml 40 | Type: PSObject[] 41 | Parameter Sets: MetricObject 42 | Aliases: 43 | 44 | Required: True 45 | Position: 1 46 | Default value: None 47 | Accept pipeline input: True (ByValue) 48 | Accept wildcard characters: False 49 | ``` 50 | 51 | ### -Measure 52 | The name of the measure to be updated or created. 53 | 54 | ```yaml 55 | Type: String 56 | Parameter Sets: Measure 57 | Aliases: 58 | 59 | Required: True 60 | Position: 1 61 | Default value: None 62 | Accept pipeline input: False 63 | Accept wildcard characters: False 64 | ``` 65 | 66 | ### -Tags 67 | A hashtable of tag names and values. 68 | 69 | ```yaml 70 | Type: Hashtable 71 | Parameter Sets: Measure 72 | Aliases: 73 | 74 | Required: False 75 | Position: Named 76 | Default value: None 77 | Accept pipeline input: False 78 | Accept wildcard characters: False 79 | ``` 80 | 81 | ### -Metrics 82 | A hashtable of metric names and values. 83 | 84 | ```yaml 85 | Type: Hashtable 86 | Parameter Sets: Measure 87 | Aliases: 88 | 89 | Required: True 90 | Position: Named 91 | Default value: None 92 | Accept pipeline input: False 93 | Accept wildcard characters: False 94 | ``` 95 | 96 | ### -TimeStamp 97 | Specify the exact date and time for the measure data point. 98 | If not specified the current date and time is used. 99 | 100 | ```yaml 101 | Type: DateTime 102 | Parameter Sets: Measure 103 | Aliases: 104 | 105 | Required: False 106 | Position: Named 107 | Default value: None 108 | Accept pipeline input: False 109 | Accept wildcard characters: False 110 | ``` 111 | 112 | ### -IP 113 | IP address for InfluxDB UDP listener. 114 | 115 | ```yaml 116 | Type: IPAddress 117 | Parameter Sets: (All) 118 | Aliases: 119 | 120 | Required: False 121 | Position: Named 122 | Default value: 127.0.0.1 123 | Accept pipeline input: False 124 | Accept wildcard characters: False 125 | ``` 126 | 127 | ### -Port 128 | Port for InfluxDB UDP listener. 129 | 130 | ```yaml 131 | Type: Int32 132 | Parameter Sets: (All) 133 | Aliases: 134 | 135 | Required: False 136 | Position: Named 137 | Default value: 8089 138 | Accept pipeline input: False 139 | Accept wildcard characters: False 140 | ``` 141 | 142 | ### -ExcludeEmptyMetric 143 | Switch: Use to exclude null or empty metric values from being sent. 144 | Useful where a metric is initially created as an integer but then 145 | an empty or null instance of that metric would attempt to be sent as an empty string, resulting in a datatype conflict. 146 | 147 | ```yaml 148 | Type: SwitchParameter 149 | Parameter Sets: (All) 150 | Aliases: 151 | 152 | Required: False 153 | Position: Named 154 | Default value: False 155 | Accept pipeline input: False 156 | Accept wildcard characters: False 157 | ``` 158 | 159 | ### -WhatIf 160 | Shows what would happen if the cmdlet runs. 161 | The cmdlet is not run. 162 | 163 | ```yaml 164 | Type: SwitchParameter 165 | Parameter Sets: (All) 166 | Aliases: wi 167 | 168 | Required: False 169 | Position: Named 170 | Default value: None 171 | Accept pipeline input: False 172 | Accept wildcard characters: False 173 | ``` 174 | 175 | ### -Confirm 176 | Prompts you for confirmation before running the cmdlet. 177 | 178 | ```yaml 179 | Type: SwitchParameter 180 | Parameter Sets: (All) 181 | Aliases: cf 182 | 183 | Required: False 184 | Position: Named 185 | Default value: None 186 | Accept pipeline input: False 187 | Accept wildcard characters: False 188 | ``` 189 | 190 | ### CommonParameters 191 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 192 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 193 | 194 | ## INPUTS 195 | 196 | ## OUTPUTS 197 | 198 | ## NOTES 199 | 200 | ## RELATED LINKS 201 | -------------------------------------------------------------------------------- /Documentation/Write-StatsD.md: -------------------------------------------------------------------------------- 1 | # Write-StatsD 2 | 3 | ## SYNOPSIS 4 | Send metrics to a statsd server via UDP for writing to Influx. 5 | 6 | ## SYNTAX 7 | 8 | ### MetricObject 9 | ``` 10 | Write-StatsD [-InputObject] [-IP ] [-Port ] [-WhatIf] [-Confirm] 11 | [] 12 | ``` 13 | 14 | ### StatsDString 15 | ``` 16 | Write-StatsD [-Data] [-IP ] [-Port ] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | PowerShell cmdlet to send metric data to a statsd server. 21 | Unless server or port is passed, uses the default 127.0.0.1 and port of 8125. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Write-StatsD 'my_metric:123|g' 28 | ``` 29 | 30 | This will write a value to a gauge metric named my_metric. 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | Write-StatsD 'my_metric:321|g' -ip 10.0.0.10 -port 8180 35 | ``` 36 | 37 | This will write a value to a gauge metric named my_metric via the specified IP and port. 38 | 39 | ### EXAMPLE 3 40 | ``` 41 | 'my_metric:1|c' | Write-StatsD 42 | ``` 43 | 44 | This will write a value to a counter metric, using the piepline as input for the cmdlet. 45 | 46 | ## PARAMETERS 47 | 48 | ### -InputObject 49 | A metric object (generated by one of the Get-*Metric cmdlets from this module) which can be provided as pipeline input 50 | and will be automatically converted to StatsD strings. 51 | 52 | ```yaml 53 | Type: PSObject[] 54 | Parameter Sets: MetricObject 55 | Aliases: 56 | 57 | Required: True 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: True (ByValue) 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Data 65 | Metric data to send to statsd. 66 | If string is not enclosed in quotes (single or double), the pipe character needs to be escaped. 67 | 68 | ```yaml 69 | Type: String[] 70 | Parameter Sets: StatsDString 71 | Aliases: 72 | 73 | Required: True 74 | Position: 1 75 | Default value: None 76 | Accept pipeline input: True (ByValue) 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### -IP 81 | IP address for statsd server 82 | 83 | ```yaml 84 | Type: IPAddress 85 | Parameter Sets: (All) 86 | Aliases: 87 | 88 | Required: False 89 | Position: Named 90 | Default value: 127.0.0.1 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -Port 96 | Port that statsd server is listening to 97 | 98 | ```yaml 99 | Type: Int32 100 | Parameter Sets: (All) 101 | Aliases: 102 | 103 | Required: False 104 | Position: Named 105 | Default value: 8125 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### -WhatIf 111 | Shows what would happen if the cmdlet runs. 112 | The cmdlet is not run. 113 | 114 | ```yaml 115 | Type: SwitchParameter 116 | Parameter Sets: (All) 117 | Aliases: wi 118 | 119 | Required: False 120 | Position: Named 121 | Default value: None 122 | Accept pipeline input: False 123 | Accept wildcard characters: False 124 | ``` 125 | 126 | ### -Confirm 127 | Prompts you for confirmation before running the cmdlet. 128 | 129 | ```yaml 130 | Type: SwitchParameter 131 | Parameter Sets: (All) 132 | Aliases: cf 133 | 134 | Required: False 135 | Position: Named 136 | Default value: None 137 | Accept pipeline input: False 138 | Accept wildcard characters: False 139 | ``` 140 | 141 | ### CommonParameters 142 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 143 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 144 | 145 | ## INPUTS 146 | 147 | ## OUTPUTS 148 | 149 | ## NOTES 150 | 151 | ## RELATED LINKS 152 | -------------------------------------------------------------------------------- /Influx/Influx.psm1: -------------------------------------------------------------------------------- 1 | $Public = @( Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -Recurse ) 2 | $Private = @( Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -Recurse ) 3 | 4 | @($Public + $Private) | ForEach-Object { 5 | Try { 6 | . $_.FullName 7 | } 8 | Catch { 9 | Write-Error -Message "Failed to import function $($_.FullName): $_" 10 | } 11 | } 12 | 13 | New-Alias -Name 'Send-Statsd' -Value 'Write-Statsd' 14 | 15 | Export-ModuleMember -Function $Public.BaseName -Alias 'Send-Statsd' -------------------------------------------------------------------------------- /Influx/Private/ConvertTo-UnixTimeMillisecond.ps1: -------------------------------------------------------------------------------- 1 | Function ConvertTo-UnixTimeMillisecond { 2 | <# 3 | .SYNOPSIS 4 | Converts a datetime string to a Unix time code in milliseconds. 5 | 6 | .DESCRIPTION 7 | This is the datetime format Influx expects by default for writing datetime fields. 8 | 9 | .PARAMETER Date 10 | The date/time to be converted. 11 | 12 | .EXAMPLE 13 | '01-01-2017 12:34:22.12' | ConvertTo-UnixTimeMillisecond 14 | 15 | Result 16 | ----------- 17 | 1483274062120 18 | #> 19 | [cmdletbinding()] 20 | [OutputType([double])] 21 | Param( 22 | [parameter(ValueFromPipeline)] 23 | $Date 24 | ) 25 | Process { 26 | (New-TimeSpan -Start (Get-Date -Date '01/01/1970') -End $Date).TotalMilliseconds 27 | } 28 | } -------------------------------------------------------------------------------- /Influx/Private/ConvertTo-UnixTimeNanosecond.ps1: -------------------------------------------------------------------------------- 1 | Function ConvertTo-UnixTimeNanosecond { 2 | <# 3 | .SYNOPSIS 4 | Converts a datetime object to a Unix time code in nanoseconds. 5 | 6 | .DESCRIPTION 7 | This is the datetime format Influx expects for writing the (optional) timestamp field. 8 | 9 | .PARAMETER Date 10 | The date/time to be converted. 11 | 12 | .EXAMPLE 13 | '01-01-2017 12:34:22.12' | ConvertTo-UnixTimeNanosecond 14 | 15 | Result 16 | ------------------- 17 | 1483274062120000000 18 | #> 19 | [cmdletbinding()] 20 | [OutputType([long])] 21 | Param( 22 | [parameter(ValueFromPipeline)] 23 | [datetime] 24 | $Date 25 | ) 26 | Process { 27 | [long]((New-TimeSpan -Start (Get-Date -Date '1970-01-01') -End (($Date).ToUniversalTime())).TotalSeconds * 1E9) 28 | } 29 | } -------------------------------------------------------------------------------- /Influx/Private/Invoke-UDPSendMethod.ps1: -------------------------------------------------------------------------------- 1 | Function Invoke-UDPSendMethod { 2 | <# 3 | .SYNOPSIS 4 | Send data to a UDP listener. 5 | 6 | .DESCRIPTION 7 | Uses the System.Net.IPEndPoint and System.Net.Sockets.UdpClient .NET methods to transmit data via UDP. 8 | 9 | .PARAMETER Data 10 | String data to be transmitted via UDP. 11 | 12 | .PARAMETER IP 13 | IP address for UDP listener. 127.0.0.1 by default. 14 | 15 | .PARAMETER Port 16 | Port for UDP listener. 8089 by default. 17 | 18 | .EXAMPLE 19 | 'Some Data' | Invoke-UDPSendMethod -IP 1.2.3.4 -Port 1234 20 | 21 | Description 22 | ----------- 23 | This command will transmit the data provided via the pipeline to the specified IP address and port via UDP. 24 | #> 25 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact='Medium')] 26 | param( 27 | [parameter(Mandatory,ValueFromPipeline)] 28 | [string[]] 29 | $Data, 30 | 31 | [ipaddress] 32 | $IP = '127.0.0.1', 33 | 34 | [int] 35 | $Port = 8089 36 | ) 37 | Begin { 38 | $Endpoint = New-Object System.Net.IPEndPoint($IP, $Port) 39 | $UDPClient = New-Object System.Net.Sockets.UdpClient 40 | } 41 | Process { 42 | ForEach ($DataItem in $Data) { 43 | $EncodedData = [System.Text.Encoding]::ASCII.GetBytes($DataItem) 44 | 45 | if ($PSCmdlet.ShouldProcess("$($IP):$Port","$DataItem")) { 46 | $BytesSent = $UDPClient.Send($EncodedData, $EncodedData.length, $Endpoint) 47 | Write-Verbose "Transmitted $BytesSent Bytes." 48 | } 49 | } 50 | } 51 | End { 52 | $UDPClient.Close() 53 | } 54 | } -------------------------------------------------------------------------------- /Influx/Private/Out-InfluxEscapeString.ps1: -------------------------------------------------------------------------------- 1 | Function Out-InfluxEscapeString { 2 | <# 3 | .SYNOPSIS 4 | Escapes the Influx REST API illegal characters using '\', several options are available based on the influx object to escape (measurement, field name, field value, etc) 5 | 6 | .DESCRIPTION 7 | Used in the Write-Influx function to escape measurement, tag and metric names and values before submitting them to the REST API. 8 | 9 | .PARAMETER String 10 | The string to be escaped. 11 | 12 | .PARAMETER StringType 13 | The influx object to be escaped: Measurement / FieldTextValue / Other. if not specified defaults to "Other" 14 | 15 | .EXAMPLE 16 | 'Some ,string=' | Out-InfluxEscapeString 17 | 18 | Result 19 | ----------- 20 | Some\ \,string\= 21 | #> 22 | [cmdletbinding()] 23 | [OutputType([string])] 24 | param( 25 | [parameter(ValueFromPipeline)] 26 | [string] 27 | $String, 28 | [parameter()] 29 | [ValidateSet("Measurement","FieldTextValue","Other")] 30 | [string] 31 | $StringType 32 | ) 33 | process { 34 | Switch ($StringType) { 35 | "Measurement" { $String -Replace '(\s|,|\\)', '\$1' } 36 | "FieldTextValue" { $String -Replace '("|\\)', '\$1' } 37 | "Other" { $String -Replace '(\s|=|,|\\|")', '\$1' } 38 | default { $String -Replace '(\s|=|,|\\|")', '\$1' } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Influx/Public/3PAR/Get-3ParSystemMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-3ParSystemMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns 3Par System metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the HPE3PARPSToolkit module from HP. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of 3PAR system tags to be included, from those returned by Get-3ParSystem. 14 | 15 | .PARAMETER SANIPAddress 16 | The IP address of the 3PAR SAN to be queried. 17 | 18 | .PARAMETER SANUserName 19 | The username for connecting to the 3PAR. 20 | 21 | .PARAMETER SANPwdFile 22 | The encrypted password file for connecting to the 3PAR. This should be created with Set-3parPoshSshConnectionPasswordFile. 23 | 24 | .EXAMPLE 25 | Get-3ParSystemMetric -Measure 'Test3PAR' -Tags System_Name,System_Model,System_ID -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 26 | 27 | Description 28 | ----------- 29 | This command will return a metric object with the specified tags and 3PAR metrics for a measure called 'Test3PAR'. 30 | #> 31 | [cmdletbinding()] 32 | param( 33 | [String] 34 | $Measure = '3PARSystem', 35 | 36 | [String[]] 37 | $Tags = ('System_Name', 'System_Model'), 38 | 39 | [Parameter(Mandatory = $true)] 40 | [String] 41 | $SANIPAddress, 42 | 43 | [Parameter(Mandatory = $true)] 44 | [String] 45 | $SANUserName, 46 | 47 | [Parameter(Mandatory = $true)] 48 | [String] 49 | $SANPwdFile 50 | ) 51 | 52 | try { 53 | Import-Module HPE3PARPSToolkit -ErrorAction Stop 54 | 55 | Set-3parPoshSshConnectionUsingPasswordFile -SANIPAddress $SANIPAddress -SANUserName $SANUserName -epwdFile $SANPwdFile -ErrorAction Stop | Out-Null 56 | } 57 | catch { 58 | throw $_ 59 | } 60 | 61 | $3Par = Get-3parSystem 62 | 63 | if ($3Par) { 64 | 65 | $TagData = @{} 66 | $3Par.GetEnumerator() | Where-Object {$_.Name -in $Tags} | ForEach-Object { 67 | if ($_.Value) { 68 | $TagData.Add($_.Name, $_.Value) 69 | } 70 | } 71 | 72 | $3ParSpace = Get-3parSpace 73 | 74 | [pscustomobject]@{ 75 | PSTypeName = 'Metric' 76 | Measure = $Measure 77 | Tags = $TagData 78 | Metrics = @{ 79 | System_RawFreeMB = [float]$3ParSpace."RawFree(MB)" 80 | System_UsableFreeMB = [float]$3ParSpace."UsableFree(MB)" 81 | } 82 | } 83 | } 84 | else { 85 | Write-Verbose 'No 3par system data returned' 86 | } 87 | } -------------------------------------------------------------------------------- /Influx/Public/3PAR/Get-3ParVirtualVolumeMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-3ParVirtualVolumeMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns the 3Par Virtual Volume metrics (as returned by Get-3parStatVV) as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the HPE3PARPSToolkit module from HP. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER SANIPAddress 13 | The IP address of the 3PAR SAN to be queried. 14 | 15 | .PARAMETER SANUserName 16 | The username for connecting to the 3PAR. 17 | 18 | .PARAMETER SANPwdFile 19 | The encrypted password file for connecting to the 3PAR. This should be created with Set-3parPoshSshConnectionPasswordFile. 20 | 21 | .EXAMPLE 22 | Get-3ParVirtualVolumeMetric -Measure 'Test3PARVV' -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 23 | 24 | Description 25 | ----------- 26 | This command will return a PowerShell object with the 3PAR Virtual Volume metrics for a measure called 'Test3PARVV'. 27 | #> 28 | [cmdletbinding()] 29 | param( 30 | [String] 31 | $Measure = '3PARVirtualVolume', 32 | 33 | [Parameter(Mandatory = $true)] 34 | [String] 35 | $SANIPAddress, 36 | 37 | [Parameter(Mandatory = $true)] 38 | [String] 39 | $SANUserName, 40 | 41 | [Parameter(Mandatory = $true)] 42 | [String] 43 | $SANPwdFile 44 | ) 45 | 46 | try { 47 | Import-Module HPE3PARPSToolkit -ErrorAction Stop 48 | 49 | Set-3parPoshSshConnectionUsingPasswordFile -SANIPAddress $SANIPAddress -SANUserName $SANUserName -epwdFile $SANPwdFile -ErrorAction Stop | Out-Null 50 | } 51 | catch { 52 | throw $_ 53 | } 54 | 55 | $3Par = Get-3parSystem 56 | 57 | if ($3Par) { 58 | 59 | $VVStats = (Get-3parStatVV -Iteration 1) | Where-Object {$_.VVname -notin 'admin', '.srdata'} 60 | 61 | if ($VVStats) { 62 | 63 | ForEach ($VV in $VVStats) { 64 | 65 | $TagData = @{ 66 | System_Name = $3Par.System_Name 67 | VVname = $VV.VVname 68 | } 69 | 70 | $Metrics = @{} 71 | 72 | $VV.PSObject.Properties | Where-Object {$_.Name -notin 'VVname', 'Time', 'Date', 'r/w'} | ForEach-Object { 73 | if ($_.Value) { 74 | $Metrics.Add($_.Name, [float]$_.Value) 75 | } 76 | } 77 | 78 | [pscustomobject]@{ 79 | PSTypeName = 'Metric' 80 | Measure = $Measure 81 | Tags = $TagData 82 | Metrics = $Metrics 83 | } 84 | } 85 | } 86 | else { 87 | Write-Verbose 'No Virtual Volume data returned' 88 | } 89 | } 90 | else { 91 | Write-Verbose 'No 3par system data returned' 92 | } 93 | } -------------------------------------------------------------------------------- /Influx/Public/3PAR/Send-3ParSystemMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-3ParSystemMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends 3Par System metrics to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the HPE3PARPSToolkit module from HP. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of 3PAR system tags to be included, from those returned by Get-3ParSystem. 14 | 15 | .PARAMETER SANIPAddress 16 | The IP address of the 3PAR SAN to be queried. 17 | 18 | .PARAMETER SANUserName 19 | The username for connecting to the 3PAR. 20 | 21 | .PARAMETER SANPwdFile 22 | The encrypted password file for connecting to the 3PAR. This should be created with Set-3parPoshSshConnectionPasswordFile. 23 | 24 | .PARAMETER Server 25 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 26 | 27 | .PARAMETER Database 28 | The name of the Influx database to write to. Default: 'storage'. This must exist in Influx! 29 | 30 | .EXAMPLE 31 | Send-3ParSystemMetric -Measure 'Test3PAR' -Tags System_Name,System_Model,System_ID -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 32 | 33 | Description 34 | ----------- 35 | This command will submit the specified tags and 3PAR metrics to a measure called 'Test3PAR'. 36 | #> 37 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 38 | param( 39 | [String] 40 | $Measure = '3PARSystem', 41 | 42 | [String[]] 43 | $Tags = ('System_Name', 'System_Model'), 44 | 45 | [Parameter(Mandatory = $true)] 46 | [String] 47 | $SANIPAddress, 48 | 49 | [Parameter(Mandatory = $true)] 50 | [String] 51 | $SANUserName, 52 | 53 | [Parameter(Mandatory = $true)] 54 | [String] 55 | $SANPwdFile, 56 | 57 | [string] 58 | $Database = 'storage', 59 | 60 | [string] 61 | $Server = 'http://localhost:8086' 62 | 63 | ) 64 | 65 | $MetricParams = @{ 66 | Measure = $Measure 67 | Tags = $Tags 68 | SANIPAddress = $SANIPAddress 69 | SANUserName = $SANUserName 70 | SANPwdFile = $SANPwdFile 71 | } 72 | 73 | $Metric = Get-3ParSystemMetric @MetricParams 74 | 75 | if ($Metric.Measure) { 76 | 77 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 78 | $Metric | Write-Influx -Database $Database -Server $Server 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /Influx/Public/3PAR/Send-3ParVirtualVolumeMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-3ParVirtualVolumeMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends the 3Par Virtual Volume metrics returned by Get-3parStatVV to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the HPE3PARPSToolkit module from HP. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER SANIPAddress 13 | The IP address of the 3PAR SAN to be queried. 14 | 15 | .PARAMETER SANUserName 16 | The username for connecting to the 3PAR. 17 | 18 | .PARAMETER SANPwdFile 19 | The encrypted password file for connecting to the 3PAR. This should be created with Set-3parPoshSshConnectionPasswordFile. 20 | 21 | .PARAMETER Server 22 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 23 | 24 | .PARAMETER Database 25 | The name of the Influx database to write to. Default: 'storage'. This must exist in Influx! 26 | 27 | .EXAMPLE 28 | Send-3ParVirtualVolumeMetric -Measure 'Test3PARVV' -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 29 | 30 | Description 31 | ----------- 32 | This command will submit the 3PAR Virtual Volume metrics to a measure called 'Test3PARVV'. 33 | #> 34 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 35 | param( 36 | [String] 37 | $Measure = '3PARVirtualVolume', 38 | 39 | [Parameter(Mandatory = $true)] 40 | [String] 41 | $SANIPAddress, 42 | 43 | [Parameter(Mandatory = $true)] 44 | [String] 45 | $SANUserName, 46 | 47 | [Parameter(Mandatory = $true)] 48 | [String] 49 | $SANPwdFile, 50 | 51 | [string] 52 | $Database = 'storage', 53 | 54 | [string] 55 | $Server = 'http://localhost:8086' 56 | 57 | ) 58 | 59 | $MetricParams = @{ 60 | Measure = $Measure 61 | SANIPAddress = $SANIPAddress 62 | SANUserName = $SANUserName 63 | SANPwdFile = $SANPwdFile 64 | } 65 | 66 | $Metric = Get-3ParVirtualVolumeMetric @MetricParams 67 | 68 | if ($Metric.Measure) { 69 | 70 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 71 | $Metric | Write-Influx -Database $Database -Server $Server 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Influx/Public/ConvertTo-Metric.ps1: -------------------------------------------------------------------------------- 1 | Function ConvertTo-Metric { 2 | <# 3 | .SYNOPSIS 4 | Converts the specified properties of an object to a metric object, which can then be easily transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | Use to convert any PowerShell object in to a Metric object with specified Measure name, Metrics and Tags. The metrics 8 | are one or more named properties of the object. The (optional) Tags can be one or more named properties of the object 9 | and/or a provided hashtable of custom tags. 10 | 11 | .PARAMETER InputObject 12 | The object that you want to convert to a metric object. Can be provided via the pipeline. 13 | 14 | .PARAMETER Measure 15 | The name of the measure to be updated or created. 16 | 17 | .PARAMETER MetricProperty 18 | One or more strings which match property names of the Input Object that you want to convert to Metrics. 19 | 20 | .PARAMETER TagProperty 21 | Optional: One or more strings which match property names of the Input Object, that you want to use as Tag data. 22 | 23 | .PARAMETER TimeProperty 24 | Optional: A string that matches a property name of the Input Object, that you want to use as the TimeStamp data. 25 | 26 | .PARAMETER Tags 27 | Optional: A hashtable of custom tag names and values. 28 | 29 | .EXAMPLE 30 | Get-Process | ConvertTo-Metric -Measure Processes -MetricProperty CPU -TagProperty Name,ID -Tags @{Host = $Env:ComputerName} 31 | 32 | Description 33 | ----------- 34 | This command will convert the specified object properties in to metrics and tags for a measure called 'Processes'. 35 | #> 36 | [cmdletbinding()] 37 | param( 38 | [Parameter(ValueFromPipeline = $True, Position = 0)] 39 | [Object] 40 | $InputObject, 41 | 42 | [Parameter(Mandatory = $true)] 43 | [String] 44 | $Measure, 45 | 46 | [Parameter(Mandatory = $true)] 47 | [String[]] 48 | $MetricProperty, 49 | 50 | [String[]] 51 | $TagProperty, 52 | 53 | [String] 54 | $TimeProperty, 55 | 56 | [hashtable] 57 | $Tags 58 | ) 59 | Process { 60 | 61 | ForEach ($ItemObject in $InputObject) { 62 | 63 | $Metrics = @{} 64 | 65 | ForEach ($Metric in $MetricProperty) { 66 | If ($Metric -in $ItemObject.PSobject.Properties.Name) { 67 | $Metrics.Add($Metric, $ItemObject.$Metric) 68 | } 69 | Else { 70 | Write-Error "$Metric is not a valid property for InputObject." 71 | } 72 | } 73 | $TagData = @{} 74 | 75 | ForEach ($Tag in $TagProperty) { 76 | If ($Tag -in $ItemObject.PSobject.Properties.Name) { 77 | $TagData.Add($Tag, $ItemObject.$Tag) 78 | } 79 | Else { 80 | Write-Error "$Tag is not a valid property for InputObject." 81 | } 82 | } 83 | 84 | If ($Tags.Count -ne 0) { $TagData += $Tags } 85 | 86 | $Result = @{ 87 | PSTypeName = 'Metric' 88 | Measure = $Measure 89 | Tags = $TagData 90 | Metrics = $Metrics 91 | } 92 | 93 | if ($ItemObject.$TimeProperty) { 94 | $Result.add('TimeStamp', $(Get-Date $ItemObject.$TimeProperty)) 95 | } 96 | 97 | [PSCustomObject]$Result 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /Influx/Public/ConvertTo-StatsDString.ps1: -------------------------------------------------------------------------------- 1 | Function ConvertTo-StatsDString { 2 | <# 3 | .SYNOPSIS 4 | Converts a metric object to a StatsD format string which could be used with Write-StatsD. 5 | 6 | .DESCRIPTION 7 | This is the format a StatsD listener expects for writing metrics. 8 | 9 | .PARAMETER InputObject 10 | The metric object to be converted. 11 | 12 | .PARAMETER Type 13 | The type of StatsD metric. Default: g (gauge: will record whatever exact value is included with each metric provided). 14 | See Statsd documentation for explanations of the different metric types accepted. 15 | 16 | .EXAMPLE 17 | Get-HostMetric -Hosts somehost1 -Tags Name,PowerState | ConvertTo-StatsDString 18 | 19 | Result 20 | ------------------- 21 | CpuUsageMhz,Name=somehost1,PowerState=PoweredOn:305|g 22 | MemoryUsageGB,Name=somehost1,PowerState=PoweredOn:17.0029296875|g 23 | #> 24 | [cmdletbinding()] 25 | [OutputType([String])] 26 | Param( 27 | [Parameter(ValueFromPipeline = $True, Position = 0)] 28 | [PSTypeName('Metric')] 29 | $InputObject, 30 | 31 | [string] 32 | $Type = 'g' 33 | ) 34 | Process { 35 | $InputObject | ForEach-Object { 36 | 37 | $Tags = @() 38 | ForEach ($Tag in $_.Tags.GetEnumerator() | Sort-Object Key) { 39 | $Tags += "$($Tag.Key)=$($Tag.Value)" 40 | } 41 | 42 | $TagData = ',' + ($Tags -Join ',') 43 | 44 | ForEach ($Metric in $_.Metrics.GetEnumerator() | Sort-Object Key) { 45 | "$($_.Measure).$($Metric.Key)$TagData`:$($Metric.Value)|$Type" 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Influx/Public/Isilon/Get-IsilonStoragePoolMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-IsilonStoragePoolMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns Isilon Storage Pool usage metrics returned by the Get-isiStoragepools cmdlet as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the IsilonPlatform module from the PSGallery. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER IsilonName 13 | The name or IP address of the Isilon to be queried. 14 | 15 | .PARAMETER IsilonPwdFile 16 | The encrypted credentials file for connecting to the Isilon. This should be created with Get-Credential | Export-Clixml. 17 | 18 | .PARAMETER ClusterName 19 | A descriptive name for the Isilon Cluster. This can be anything and is used for the Cluster tag field. 20 | 21 | .EXAMPLE 22 | Get-IsilonStoragePoolMetric -Measure 'TestIsilonSP' -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 23 | 24 | Description 25 | ----------- 26 | This command will return a PowerShell object with the specified Isilon's Storage Pool metrics for a measure called 'TestIsilonSP'. 27 | #> 28 | [cmdletbinding()] 29 | param( 30 | [String] 31 | $Measure = 'IsilonStoragePool', 32 | 33 | [Parameter(Mandatory = $true)] 34 | [String] 35 | $IsilonName, 36 | 37 | [Parameter(Mandatory = $true)] 38 | [String] 39 | $IsilonPwdFile, 40 | 41 | [Parameter(Mandatory = $true)] 42 | [String] 43 | $ClusterName 44 | 45 | ) 46 | 47 | Try { 48 | Import-Module IsilonPlatform -ErrorAction Stop 49 | 50 | New-isiSession -ComputerName $IsilonName -Credential ($IsilonPwdFile | Import-Clixml) -Cluster $ClusterName 51 | } 52 | Catch { 53 | Throw $_ 54 | } 55 | 56 | $StoragePools = Get-isiStoragepools 57 | 58 | if ($StoragePools) { 59 | 60 | ForEach ($StoragePool in $StoragePools) { 61 | 62 | $TagData = @{ 63 | Name = $IsilonName 64 | Cluster = $ClusterName 65 | StoragePool = $StoragePool.name 66 | Id = $StoragePool.id 67 | } 68 | 69 | $Metrics = @{} 70 | 71 | $StoragePool.usage.PSObject.Properties | Where-Object {$_.Name -notin 'balanced'} | ForEach-Object { 72 | if ($_.Value) { 73 | $Metrics.Add($_.Name, [long]$_.Value) 74 | } 75 | } 76 | 77 | [pscustomobject]@{ 78 | PSTypeName = 'Metric' 79 | Measure = $Measure 80 | Tags = $TagData 81 | Metrics = $Metrics 82 | } 83 | } 84 | } 85 | else { 86 | Write-Verbose 'No Storage Pool data returned' 87 | } 88 | 89 | Remove-isiSession -Cluster $ClusterName 90 | } -------------------------------------------------------------------------------- /Influx/Public/Isilon/Send-IsilonStoragePoolMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-IsilonStoragePoolMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Isilon Storage Pool usage metrics returned by the Get-isiStoragepools cmdlet from the IsilonPlatform module to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the IsilonPlatform module from the PSGallery. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER IsilonName 13 | The name or IP address of the Isilon to be queried. 14 | 15 | .PARAMETER IsilonPwdFile 16 | The encrypted credentials file for connecting to the Isilon. This should be created with Get-Credential | Export-Clixml. 17 | 18 | .PARAMETER ClusterName 19 | A descriptive name for the Isilon Cluster. This can be anything and is used for the Cluster tag field. 20 | 21 | .PARAMETER Server 22 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 23 | 24 | .PARAMETER Database 25 | The name of the Influx database to write to. Default: 'storage'. This must exist in Influx! 26 | 27 | .EXAMPLE 28 | Send-IsilonStoragePoolMetric -Measure 'TestIsilonSP' -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 29 | 30 | Description 31 | ----------- 32 | This command will submit the specified Isilon's Storage Pool metrics to a measure called 'TestIsilonSP'. 33 | #> 34 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 35 | param( 36 | [String] 37 | $Measure = 'IsilonStoragePool', 38 | 39 | [Parameter(Mandatory = $true)] 40 | [String] 41 | $IsilonName, 42 | 43 | [Parameter(Mandatory = $true)] 44 | [String] 45 | $IsilonPwdFile, 46 | 47 | [Parameter(Mandatory = $true)] 48 | [String] 49 | $ClusterName, 50 | 51 | [string] 52 | $Database = 'storage', 53 | 54 | [string] 55 | $Server = 'http://localhost:8086' 56 | 57 | ) 58 | 59 | $MetricParams = @{ 60 | Measure = $Measure 61 | IsilonName = $IsilonName 62 | IsilonPwdFile = $IsilonPwdFile 63 | ClusterName = $ClusterName 64 | } 65 | 66 | $Metric = Get-IsilonStoragePoolMetric @MetricParams 67 | 68 | if ($Metric.Measure) { 69 | 70 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 71 | $Metric | Write-Influx -Database $Database -Server $Server 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Influx/Public/TFS/Get-TFSBuildMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-TFSBuildMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns TFS Build metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the TFS module (install via Install-Module TFS). 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of Build definition properties to be included, from those returned by Get-TfsBuildDefinitions. 14 | 15 | .PARAMETER Top 16 | An integer defining the number of most recent builds to return. Default: 100. 17 | 18 | .PARAMETER Latest 19 | Switch parameter. When used returns only the most recent build for each distinct definition. 20 | 21 | .PARAMETER TFSRootURL 22 | The root URL for TFS, e.g https://yourserver.yoursite.com/TFS 23 | 24 | .PARAMETER TFSCollection 25 | The name of the TFS collection to query. 26 | 27 | .PARAMETER TFSProject 28 | The name of the TFS project to query. 29 | 30 | .EXAMPLE 31 | Get-TFSBuildMetric -Measure 'TestTFS' -Tags Name,Author -TFSRootURL https://localhost:8088/tfs -TFSCollection MyCollection -TFSProject MyProject 32 | 33 | Description 34 | ----------- 35 | This command will return the specified tags and build metrics of a measure called 'TestTFS' as a PowerShell object. 36 | #> 37 | [cmdletbinding()] 38 | param( 39 | [String] 40 | $Measure = 'TFSBuild', 41 | 42 | [String[]] 43 | $Tags = ('Definition', 'Id', 'Result'), 44 | 45 | [int] 46 | $Top = 100, 47 | 48 | [switch] 49 | $Latest, 50 | 51 | [Parameter(Mandatory = $true)] 52 | [string] 53 | $TFSRootURL, 54 | 55 | [Parameter(Mandatory = $true)] 56 | [string] 57 | $TFSCollection, 58 | 59 | [Parameter(Mandatory = $true)] 60 | [string] 61 | $TFSProject 62 | ) 63 | 64 | try { 65 | Import-Module TFS -ErrorAction Stop 66 | } 67 | catch { 68 | throw $_ 69 | } 70 | 71 | $global:tfs = @{ 72 | root_url = $TFSRootURL 73 | collection = $TFSCollection 74 | project = $TFSProject 75 | } 76 | 77 | Write-Verbose "TFS settings:`n`n$($global:tfs)" 78 | 79 | Write-Verbose "`nGetting builds.." 80 | $Builds = Get-TFSBuilds -Top $Top | Where-Object { $_.StartTime } 81 | 82 | If ($Latest) { 83 | $Builds = $Builds | Group-Object Definition | ForEach-Object { $_.Group | Sort-Object StartTime -Descending | Select-Object -First 1 } 84 | } 85 | 86 | if ($Builds) { 87 | 88 | ForEach ($Build in $Builds) { 89 | 90 | $TagData = @{ 91 | Collection = $TFSCollection 92 | Project = $TFSProject 93 | RequestedBy = $Build.raw.requestedBy.displayname 94 | } 95 | 96 | ($Build | Select-Object $Tags).PsObject.Properties | ForEach-Object { 97 | if ($_.Value) { 98 | $TagData.Add($_.Name, $_.Value) 99 | } 100 | } 101 | 102 | #Used to support row highlighting for non-successful builds 103 | $ResultNumeric = Switch ($Build.Result) { 104 | 'partiallySucceeded' { 1 } 105 | 'failed' { 2 } 106 | default { $null } 107 | } 108 | 109 | $Metrics = @{ 110 | Name = $Build.Definition 111 | Result = $Build.Result 112 | ResultNumeric = $ResultNumeric 113 | Duration = $Build.Duration 114 | sourceBranch = $Build.raw.sourceBranch 115 | sourceVersion = $Build.raw.sourceVersion 116 | Id = $Build.Id 117 | RequestedBy = $Build.raw.requestedBy.displayname 118 | } 119 | 120 | 'StartTime', 'FinishTime' | ForEach-Object { 121 | If ($Build.$_ -is [datetime]) { 122 | $Metrics.Add($_, ($Build.$_ | ConvertTo-UnixTimeMillisecond)) 123 | } 124 | } 125 | 126 | [pscustomobject]@{ 127 | PSTypeName = 'Metric' 128 | Measure = $Measure 129 | Tags = $TagData 130 | Metrics = $Metrics 131 | TimeStamp = $Build.StartTime 132 | } 133 | } 134 | } 135 | else { 136 | Write-Verbose 'No build data returned' 137 | } 138 | } -------------------------------------------------------------------------------- /Influx/Public/TFS/Send-TFSBuildMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-TFSBuildMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends TFS Build metrics to Influx. 5 | 6 | .DESCRIPTION 7 | This function requires the TFS module (install via Install-Module TFS). 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of Build definition properties to be included, from those returned by Get-TfsBuildDefinitions. 14 | 15 | .PARAMETER Top 16 | An integer defining the number of most recent builds to return. Default: 100. 17 | 18 | .PARAMETER Latest 19 | Switch parameter. When used returns only the most recent build for each distinct definition. 20 | 21 | .PARAMETER TFSRootURL 22 | The root URL for TFS, e.g https://yourserver.yoursite.com/TFS 23 | 24 | .PARAMETER TFSCollection 25 | The name of the TFS collection to query. 26 | 27 | .PARAMETER TFSProject 28 | The name of the TFS project to query. 29 | 30 | .PARAMETER Server 31 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 32 | 33 | .PARAMETER Database 34 | The name of the Influx database to write to. Default: 'TFS'. This must exist in Influx! 35 | 36 | .EXAMPLE 37 | Send-TFSBuildMetric -Measure 'TestTFS' -Tags Name,Author -TFSRootURL https://localhost:8088/tfs -TFSCollection MyCollection -TFSProject MyProject 38 | 39 | Description 40 | ----------- 41 | This command will submit the specified tags and Build metrics to a measure called 'TestTFS'. 42 | #> 43 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 44 | param( 45 | [String] 46 | $Measure = 'TFSBuild', 47 | 48 | [String[]] 49 | $Tags = ('Definition', 'Id', 'Result'), 50 | 51 | [int] 52 | $Top = 100, 53 | 54 | [switch] 55 | $Latest, 56 | 57 | [Parameter(Mandatory = $true)] 58 | [string] 59 | $TFSRootURL, 60 | 61 | [Parameter(Mandatory = $true)] 62 | [string] 63 | $TFSCollection, 64 | 65 | [Parameter(Mandatory = $true)] 66 | [string] 67 | $TFSProject, 68 | 69 | [string] 70 | $Database = 'tfs', 71 | 72 | [string] 73 | $Server = 'http://localhost:8086' 74 | 75 | ) 76 | 77 | $MetricParams = @{ 78 | Measure = $Measure 79 | Tags = $Tags 80 | Top = $Top 81 | Latest = $Latest 82 | TFSRootURL = $TFSRootURL 83 | TFSCollection = $TFSCollection 84 | TFSProject = $TFSProject 85 | } 86 | 87 | $Metric = Get-TFSBuildMetric @MetricParams 88 | 89 | if ($Metric.Measure) { 90 | 91 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 92 | $Metric | Write-Influx -Database $Database -Server $Server 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-DatacenterMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-DatacenterMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns VMWare Datacenter metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all Datacenters returned by Get-Datacenter. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of Datacenter tags to be included. Default: 'Name','ParentFolder' 14 | 15 | .PARAMETER Datacenter 16 | One or more Datacenters to be queried. 17 | 18 | .EXAMPLE 19 | Get-DatacenterMetric -Measure 'TestDatacenter' -Tags Name,NumCpuShares -Datacenter Test* 20 | 21 | Description 22 | ----------- 23 | This command will return the specified tags and Datacenter metrics for a measure named 'TestDatacenter' for all Datacenters starting with 'Test' 24 | #> 25 | [cmdletbinding()] 26 | param( 27 | [String] 28 | $Measure = 'Datacenter', 29 | 30 | [String[]] 31 | $Tags = ('Name', 'ParentFolder'), 32 | 33 | [String[]] 34 | $Datacenter = '*' 35 | ) 36 | 37 | Write-Verbose 'Getting Datacenters..' 38 | $Datacenters = Get-Datacenter $Datacenter 39 | 40 | if ($Datacenters) { 41 | 42 | foreach ($DC in $Datacenters) { 43 | 44 | $TagData = @{} 45 | ($DC | Select-Object $Tags).PSObject.Properties | ForEach-Object { 46 | if ($_.Value) { 47 | $TagData.Add($_.Name, $_.Value) 48 | } 49 | } 50 | 51 | $VMs = $DC | Get-VM 52 | 53 | $Metrics = @{ VMs_Count = $VMs.count } 54 | 55 | If ($VMs.count -gt 0) { 56 | $Metrics.Add('VMs_MemoryGB_Total', ($VMs | Measure-Object MemoryGB -Sum).Sum) 57 | $Metrics.Add('VMs_NumCPU_Total', ($VMs | Measure-Object NumCPU -Sum).Sum) 58 | } 59 | 60 | $VMS | Group-Object PowerState | ForEach-Object { 61 | $Metrics.Add("$($_.Name)_VMs_Count", $_.Count) 62 | If ($_.count -gt 0) { 63 | $Metrics.Add("$($_.Name)_VMs_MemoryGB_Total", ($_.Group | Measure-Object MemoryGB -Sum).Sum) 64 | $Metrics.Add("$($_.Name)_VMs_NumCPU_Total", ($_.Group | Measure-Object NumCPU -Sum).Sum) 65 | } 66 | } 67 | 68 | [pscustomobject]@{ 69 | PSTypeName = 'Metric' 70 | Measure = $Measure 71 | Tags = $TagData 72 | Metrics = $Metrics 73 | } 74 | } 75 | } 76 | else { 77 | Write-Verbose 'No Datacenter data returned' 78 | } 79 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-DatastoreClusterMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-DatastoreClusterMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns Datastore Cluster metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all Datastore Clusters returned by Get-DatastoreCluster. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of Datastore Cluster tags to be included. Default: 'Name' 14 | 15 | .PARAMETER DatastoreCluster 16 | One or more Datastore Clusters to be queried. 17 | 18 | .EXAMPLE 19 | Get-DatastoreClusterMetric -Measure 'TestDatastoreClusters' -Tags Name,Type -DatastoreCluster Test* 20 | 21 | Description 22 | ----------- 23 | This command will return the specified tags and DatastoreCluster metrics for a measure called 'TestDatastoreClusters' for all DatastoreClusters starting with 'Test'. 24 | #> 25 | [cmdletbinding()] 26 | param( 27 | [String] 28 | $Measure = 'DatastoreCluster', 29 | 30 | [String[]] 31 | $Tags = 'Name', 32 | 33 | [String[]] 34 | $DatastoreCluster = '*' 35 | ) 36 | 37 | Write-Verbose 'Getting DatastoreClusters..' 38 | $DatastoreClusters = Get-DatastoreCluster $DatastoreCluster 39 | 40 | if ($DatastoreClusters) { 41 | 42 | foreach ($DSCluster in $DatastoreClusters) { 43 | 44 | $TagData = @{} 45 | ($DSCluster | Select-Object $Tags).PSObject.Properties | ForEach-Object { 46 | if ($_.Value) { 47 | $TagData.Add($_.Name, $_.Value) 48 | } 49 | } 50 | 51 | [pscustomobject]@{ 52 | PSTypeName = 'Metric' 53 | Measure = $Measure 54 | Tags = $TagData 55 | Metrics = @{ 56 | CapacityGB = $DSCluster.CapacityGB 57 | FreeSpaceGB = $DSCluster.FreeSpaceGB 58 | UsedSpaceGB = ($DSCluster.CapacityGB - $DSCluster.FreeSpaceGB) 59 | UsedSpacePercent = (($DSCluster.CapacityGB - $DSCluster.FreeSpaceGB) / $DSCluster.CapacityGB * 100) 60 | } 61 | } 62 | } 63 | } 64 | else { 65 | Write-Verbose 'No DatastoreCluster data returned' 66 | } 67 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-DatastoreMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-DatastoreMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns Datastore metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all Datastores returned by Get-Datastore. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of datastore tags to be included. Default: 'Name','ParentFolder','Type' 14 | 15 | .PARAMETER Datastore 16 | One or more datastores to be queried. 17 | 18 | .PARAMETER Server 19 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 20 | 21 | .PARAMETER Database 22 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 23 | 24 | .EXAMPLE 25 | Send-DatastoreMetric -Measure 'TestDatastores' -Tags Name,Type -Datastore Test* 26 | 27 | Description 28 | ----------- 29 | This command will submit the specified tags and datastore metrics to a measure called 'TestDatastores' for all datastores starting with 'Test' 30 | #> 31 | [cmdletbinding()] 32 | param( 33 | [String] 34 | $Measure = 'Datastore', 35 | 36 | [String[]] 37 | $Tags = ('Name', 'ParentFolder', 'Type'), 38 | 39 | [String[]] 40 | $Datastore = '*', 41 | 42 | [string] 43 | $Database = 'vmware', 44 | 45 | [string] 46 | $Server = 'http://localhost:8086' 47 | ) 48 | 49 | Write-Verbose 'Getting datastores..' 50 | $Datastores = Get-Datastore $Datastore 51 | 52 | if ($Datastores) { 53 | 54 | foreach ($DS in $Datastores) { 55 | 56 | $TagData = @{} 57 | ($DS | Select-Object $Tags).PSObject.Properties | ForEach-Object { 58 | if ($_.Value) { 59 | $TagData.Add($_.Name, $_.Value) 60 | } 61 | } 62 | 63 | [pscustomobject]@{ 64 | PSTypeName = 'Metric' 65 | Measure = $Measure 66 | Tags = $TagData 67 | Metrics = @{ 68 | CapacityGB = $DS.CapacityGB 69 | FreeSpaceGB = $DS.FreeSpaceGB 70 | UsedSpaceGB = ($DS.CapacityGB - $DS.FreeSpaceGB) 71 | } 72 | } 73 | } 74 | } 75 | else { 76 | Write-Verbose 'No datastore data returned' 77 | } 78 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-HostMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-HostMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns common ESX Host metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all ESX hosts returned by Get-VMHost. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of host tags to be included. Default: 'Name','Parent','State','PowerState','Version' 14 | 15 | .PARAMETER Hosts 16 | One or more hosts to be queried. 17 | 18 | .PARAMETER Stats 19 | Use this switch if you want to collect common host stats using Get-Stat. 20 | 21 | .EXAMPLE 22 | Get-HostMetric -Measure 'TestESXHosts' -Tags Name,Parent -Hosts TestHost* 23 | 24 | Description 25 | ----------- 26 | This command will return the specified tag and common ESX host data for a measure called 'TestESXHosts' for all hosts starting with 'TestHost' 27 | #> 28 | [cmdletbinding()] 29 | param( 30 | [String] 31 | $Measure = 'ESXHost', 32 | 33 | [String[]] 34 | $Tags = ('Name', 'Parent', 'State', 'PowerState', 'Version'), 35 | 36 | [String[]] 37 | $Hosts = '*', 38 | 39 | [Switch] 40 | $Stats 41 | ) 42 | 43 | Write-Verbose 'Getting hosts..' 44 | $VMHosts = Get-VMHost $Hosts 45 | 46 | if ($VMHosts) { 47 | 48 | if ($Stats) { 49 | Write-Verbose 'Getting host statistics..' 50 | $HostStats = $VMHosts | Get-Stat -MaxSamples 1 -Common | Where-Object {-not $_.Instance} 51 | } 52 | 53 | foreach ($VMHost in $VMHosts) { 54 | 55 | $TagData = @{} 56 | ($VMHost | Select-Object $Tags).PSObject.Properties | ForEach-Object { 57 | if ($_.Value) { 58 | $TagData.Add($_.Name, $_.Value) 59 | } 60 | } 61 | 62 | $Metrics = @{ 63 | CpuTotalMhz = $VMHost.CpuTotalMhz 64 | CpuUsageMhz = $VMHost.CpuUsageMhz 65 | CpuUsagePercent = (($VMHost.CpuUsageMhz / $VMHost.CpuTotalMhz) * 100) 66 | MemoryTotalGB = $VMHost.MemoryTotalGB 67 | MemoryUsageGB = $VMHost.MemoryUsageGB 68 | MemoryUsagePercent = (($VMHost.MemoryUsageGB / $VMHost.MemoryTotalGB) * 100) 69 | } 70 | 71 | if ($HostStats) { 72 | $HostStats | Where-Object { $_.Entity.Name -eq $VMHost.Name } | ForEach-Object { $Metrics.Add($_.MetricId, $_.Value) } 73 | } 74 | 75 | [pscustomobject]@{ 76 | PSTypeName = 'Metric' 77 | Measure = $Measure 78 | Tags = $TagData 79 | Metrics = $Metrics 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-ResourcePoolMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-ResourcePoolMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns Resource Pool metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all Resource Pools returned by Get-ResourcePool. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of Resource Pool tags to be included. Default: 'Name','Parent' 14 | 15 | .PARAMETER ResourcePool 16 | One or more Resource Pools to be queried. 17 | 18 | .EXAMPLE 19 | Get-ResourcePoolMetric -Measure 'TestResources' -Tags Name,NumCpuShares -ResourcePool Test* 20 | 21 | Description 22 | ----------- 23 | This command will return the specified tags and resource pool metrics for a measure called 'TestResources' for all resource pools starting with 'Test' 24 | #> 25 | [cmdletbinding()] 26 | param( 27 | [String] 28 | $Measure = 'ResourcePool', 29 | 30 | [String[]] 31 | $Tags = ('Name', 'Parent'), 32 | 33 | [String[]] 34 | $ResourcePool = '*' 35 | ) 36 | 37 | Write-Verbose 'Getting resource pools..' 38 | $ResourcePools = Get-ResourcePool $ResourcePool 39 | 40 | if ($ResourcePools) { 41 | 42 | foreach ($RP in $ResourcePools) { 43 | 44 | $TagData = @{} 45 | ($RP | Select-Object $Tags).PSObject.Properties | ForEach-Object { 46 | if ($_.Value) { 47 | $TagData.Add($_.Name, $_.Value) 48 | } 49 | } 50 | 51 | $VMs = $RP | Get-VM 52 | 53 | $Metrics = @{ VMs_Count = $VMs.count } 54 | 55 | If ($VMs.count -gt 0) { 56 | $Metrics.Add('VMs_MemoryGB_Total', ($VMs | Measure-Object MemoryGB -Sum).Sum) 57 | $Metrics.Add('VMs_NumCPU_Total', ($VMs | Measure-Object NumCPU -Sum).Sum) 58 | } 59 | 60 | $VMS | Group-Object PowerState | ForEach-Object { 61 | $Metrics.Add("$($_.Name)_VMs_Count", $_.Count) 62 | If ($_.count -gt 0) { 63 | $Metrics.Add("$($_.Name)_VMs_MemoryGB_Total", ($_.Group | Measure-Object MemoryGB -Sum).Sum) 64 | $Metrics.Add("$($_.Name)_VMs_NumCPU_Total", ($_.Group | Measure-Object NumCPU -Sum).Sum) 65 | } 66 | } 67 | 68 | [pscustomobject]@{ 69 | PSTypeName = 'Metric' 70 | Measure = $Measure 71 | Tags = $TagData 72 | Metrics = $Metrics 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Get-VMMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Get-VMMetric { 2 | <# 3 | .SYNOPSIS 4 | Returns Virtual Machine metrics as a metric object which can then be transmitted to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet returns metrics for all Virtual Machines returned by Get-VM. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be (ultimately) updated or created when this metric object is transmitted to Influx. 11 | 12 | .PARAMETER Tags 13 | An array of virtual machine tags to be included. Default: 'Name','Folder','ResourcePool','PowerState','Guest','VMHost' 14 | 15 | .PARAMETER VMs 16 | One or more Virtual Machines to be queried. 17 | 18 | .PARAMETER Stats 19 | Use to enable the collection of VM statistics via Get-Stat for each VM. 20 | 21 | .EXAMPLE 22 | Get-VMMetric -Measure 'TestVirtualMachines' -Tags Name,ResourcePool -Hosts TestVM* 23 | 24 | Description 25 | ----------- 26 | This command will return the specified tag and common VM host data for a measure called 'TestVirtualMachines' for all VMs starting with 'TestVM' 27 | #> 28 | [cmdletbinding()] 29 | param( 30 | [string] 31 | $Measure = 'VirtualMachine', 32 | 33 | [string[]] 34 | $Tags = ('Name', 'Folder', 'ResourcePool', 'PowerState', 'Guest', 'VMHost'), 35 | 36 | [string[]] 37 | $VMs = '*', 38 | 39 | [switch] 40 | $Stats 41 | ) 42 | 43 | Write-Verbose 'Getting VMs..' 44 | $VMServers = Get-VM $VMs 45 | 46 | if ($VMServers) { 47 | 48 | if ($Stats) { 49 | Write-Verbose 'Getting VM statistics..' 50 | $VMStats = $VMServers | Get-Stat -MaxSamples 1 -Common | Where-Object {-not $_.Instance} 51 | } 52 | 53 | foreach ($VM in $VMServers) { 54 | 55 | $TagData = @{} 56 | ($VM | Select-Object $Tags).PSObject.Properties | ForEach-Object { 57 | if ($_.Value) { 58 | $TagData.Add($_.Name, $_.Value) 59 | } 60 | } 61 | 62 | $Metrics = @{ 63 | PowerState = [int]$VM.PowerState 64 | GuestHeartbeatStatus = [int]$VM.ExtensionData.Summary.QuickStats.GuestHeartbeatStatus 65 | } 66 | 67 | $QuickStats = $VM.ExtensionData.Summary.QuickStats | Select-Object OverallCpuUsage, GuestMemoryUsage, HostMemoryUsage, UptimeSeconds 68 | 69 | $QuickStats.PSObject.Properties | ForEach-Object { 70 | if ($_.Value) { 71 | $Metrics.Add($_.Name, $_.Value) 72 | } 73 | } 74 | 75 | if ($VMStats) { 76 | $VMStats | Where-Object { $_.Entity.Name -eq $VM.Name } | ForEach-Object { $Metrics.Add($_.MetricId, $_.Value) } 77 | } 78 | 79 | [pscustomobject]@{ 80 | PSTypeName = 'Metric' 81 | Measure = $Measure 82 | Tags = $TagData 83 | Metrics = $Metrics 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-DatacenterMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-DatacenterMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Datacenter metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all Datacenter returned by Get-Datacenter. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of Datacenter tags to be included. Default: 'Name','ParentFolder' 14 | 15 | .PARAMETER Datacenter 16 | One or more Datacenters to be queried. 17 | 18 | .PARAMETER Server 19 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 20 | 21 | .PARAMETER Database 22 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 23 | 24 | .EXAMPLE 25 | Send-DatacenterMetric -Measure 'TestDatacenter' -Tags Name,NumCpuShares -Datacenter Test* 26 | 27 | Description 28 | ----------- 29 | This command will submit the specified tags and Datacenter metrics to a measure called 'TestDatacenter' for all Datacenters starting with 'Test' 30 | #> 31 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 32 | param( 33 | [String] 34 | $Measure = 'Datacenter', 35 | 36 | [String[]] 37 | $Tags = ('Name', 'ParentFolder'), 38 | 39 | [String[]] 40 | $Datacenter = '*', 41 | 42 | [string] 43 | $Database = 'vmware', 44 | 45 | [string] 46 | $Server = 'http://localhost:8086' 47 | ) 48 | 49 | $MetricParams = @{ 50 | Measure = $Measure 51 | Tags = $Tags 52 | Datacenter = $Datacenter 53 | } 54 | 55 | $Metric = Get-DatacenterMetric @MetricParams 56 | 57 | if ($Metric.Measure) { 58 | 59 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 60 | $Metric | Write-Influx -Database $Database -Server $Server 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-DatastoreClusterMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-DatastoreClusterMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Datastore Cluster metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all Datastore Clusters returned by Get-DatastoreCluster. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of Datastore Cluster tags to be included. Default: 'Name' 14 | 15 | .PARAMETER DatastoreCluster 16 | One or more Datastore Clusters to be queried. 17 | 18 | .PARAMETER Server 19 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 20 | 21 | .PARAMETER Database 22 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 23 | 24 | .EXAMPLE 25 | Send-DatastoreClusterMetric -Measure 'TestDatastoreClusters' -Tags Name,Type -DatastoreCluster Test* 26 | 27 | Description 28 | ----------- 29 | This command will submit the specified tags and DatastoreCluster metrics to a measure called 'TestDatastoreClusters' for all DatastoreClusters starting with 'Test' 30 | #> 31 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 32 | param( 33 | [String] 34 | $Measure = 'DatastoreCluster', 35 | 36 | [String[]] 37 | $Tags = 'Name', 38 | 39 | [String[]] 40 | $DatastoreCluster = '*', 41 | 42 | [string] 43 | $Database = 'vmware', 44 | 45 | [string] 46 | $Server = 'http://localhost:8086' 47 | ) 48 | 49 | $MetricParams = @{ 50 | Measure = $Measure 51 | Tags = $Tags 52 | DatastoreCluster = $DatastoreCluster 53 | } 54 | 55 | $Metric = Get-DatastoreClusterMetric @MetricParams 56 | 57 | if ($Metric.Measure) { 58 | 59 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 60 | $Metric | Write-Influx -Database $Database -Server $Server 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-DatastoreMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-DatastoreMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Datastore metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all Datastores returned by Get-Datastore. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of datastore tags to be included. Default: 'Name','ParentFolder','Type' 14 | 15 | .PARAMETER Datastore 16 | One or more datastores to be queried. 17 | 18 | .PARAMETER Server 19 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 20 | 21 | .PARAMETER Database 22 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 23 | 24 | .EXAMPLE 25 | Send-DatastoreMetric -Measure 'TestDatastores' -Tags Name,Type -Datastore Test* 26 | 27 | Description 28 | ----------- 29 | This command will submit the specified tags and datastore metrics to a measure called 'TestDatastores' for all datastores starting with 'Test' 30 | #> 31 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 32 | param( 33 | [String] 34 | $Measure = 'Datastore', 35 | 36 | [String[]] 37 | $Tags = ('Name', 'ParentFolder', 'Type'), 38 | 39 | [String[]] 40 | $Datastore = '*', 41 | 42 | [string] 43 | $Database = 'vmware', 44 | 45 | [string] 46 | $Server = 'http://localhost:8086' 47 | ) 48 | 49 | $MetricParams = @{ 50 | Measure = $Measure 51 | Tags = $Tags 52 | Datastore = $Datastore 53 | } 54 | 55 | $Metric = Get-DatastoreMetric @MetricParams 56 | 57 | if ($Metric.Measure) { 58 | 59 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 60 | $Metric | Write-Influx -Database $Database -Server $Server 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-HostMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-HostMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends common ESX Host metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all ESX hosts returned by Get-VMHost. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of host tags to be included. Default: 'Name','Parent','State','PowerState','Version' 14 | 15 | .PARAMETER Hosts 16 | One or more hosts to be queried. 17 | 18 | .PARAMETER Stats 19 | Use this switch if you want to collect common host stats using Get-Stat. 20 | 21 | .PARAMETER Server 22 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 23 | 24 | .PARAMETER Database 25 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 26 | 27 | .EXAMPLE 28 | Send-HostMetric -Measure 'TestESXHosts' -Tags Name,Parent -Hosts TestHost* 29 | 30 | Description 31 | ----------- 32 | This command will submit the specified tag and common ESX host data to a measure called 'TestESXHosts' for all hosts starting with 'TestHost' 33 | #> 34 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 35 | param( 36 | [String] 37 | $Measure = 'ESXHost', 38 | 39 | [String[]] 40 | $Tags = ('Name', 'Parent', 'State', 'PowerState', 'Version'), 41 | 42 | [String[]] 43 | $Hosts = '*', 44 | 45 | [Switch] 46 | $Stats, 47 | 48 | [string] 49 | $Database = 'vmware', 50 | 51 | [string] 52 | $Server = 'http://localhost:8086' 53 | ) 54 | 55 | $MetricParams = @{ 56 | Measure = $Measure 57 | Tags = $Tags 58 | Hosts = $Hosts 59 | Stats = $Stats 60 | } 61 | 62 | $Metric = Get-HostMetric @MetricParams 63 | 64 | if ($Metric.Measure) { 65 | 66 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 67 | $Metric | Write-Influx -Database $Database -Server $Server 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-ResourcePoolMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-ResourcePoolMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Resource Pool metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all Resource Pool returned by Get-ResourcePool. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of Resource Pool tags to be included. Default: 'Name','Parent' 14 | 15 | .PARAMETER ResourcePool 16 | One or more Resource Pools to be queried. 17 | 18 | .PARAMETER Server 19 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 20 | 21 | .PARAMETER Database 22 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 23 | 24 | .EXAMPLE 25 | Send-ResourcePoolMetric -Measure 'TestResources' -Tags Name,NumCpuShares -ResourcePool Test* 26 | 27 | Description 28 | ----------- 29 | This command will submit the specified tags and resource pool metrics to a measure called 'TestResources' for all resource pools starting with 'Test' 30 | #> 31 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 32 | param( 33 | [String] 34 | $Measure = 'ResourcePool', 35 | 36 | [String[]] 37 | $Tags = ('Name', 'Parent'), 38 | 39 | [String[]] 40 | $ResourcePool = '*', 41 | 42 | [string] 43 | $Database = 'vmware', 44 | 45 | [string] 46 | $Server = 'http://localhost:8086' 47 | ) 48 | 49 | $MetricParams = @{ 50 | Measure = $Measure 51 | Tags = $Tags 52 | ResourcePool = $ResourcePool 53 | } 54 | 55 | $Metric = Get-ResourcePoolMetric @MetricParams 56 | 57 | if ($Metric.Measure) { 58 | 59 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 60 | $Metric | Write-Influx -Database $Database -Server $Server 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Influx/Public/VMWare/Send-VMMetric.ps1: -------------------------------------------------------------------------------- 1 | Function Send-VMMetric { 2 | <# 3 | .SYNOPSIS 4 | Sends Virtual Machine metrics to Influx. 5 | 6 | .DESCRIPTION 7 | By default this cmdlet sends metrics for all Virtual Machines returned by Get-VM. 8 | 9 | .PARAMETER Measure 10 | The name of the measure to be updated or created. 11 | 12 | .PARAMETER Tags 13 | An array of virtual machine tags to be included. Default: 'Name','Folder','ResourcePool','PowerState','Guest','VMHost' 14 | 15 | .PARAMETER VMs 16 | One or more Virtual Machines to be queried. 17 | 18 | .PARAMETER Stats 19 | Use to enable the collection of VM statistics via Get-Stat for each VM. 20 | 21 | .PARAMETER Server 22 | The URL and port for the Influx REST API. Default: 'http://localhost:8086' 23 | 24 | .PARAMETER Database 25 | The name of the Influx database to write to. Default: 'vmware'. This must exist in Influx! 26 | 27 | .EXAMPLE 28 | Send-VMMetric -Measure 'TestVirtualMachines' -Tags Name,ResourcePool -Hosts TestVM* 29 | 30 | Description 31 | ----------- 32 | This command will submit the specified tag and common VM host data to a measure called 'TestVirtualMachines' for all VMs starting with 'TestVM' 33 | #> 34 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] 35 | param( 36 | [string] 37 | $Measure = 'VirtualMachine', 38 | 39 | [string[]] 40 | $Tags = ('Name', 'Folder', 'ResourcePool', 'PowerState', 'Guest', 'VMHost'), 41 | 42 | [string[]] 43 | $VMs = '*', 44 | 45 | [switch] 46 | $Stats, 47 | 48 | [string] 49 | $Database = 'vmware', 50 | 51 | [string] 52 | $Server = 'http://localhost:8086' 53 | ) 54 | 55 | $MetricParams = @{ 56 | Measure = $Measure 57 | Tags = $Tags 58 | VMs = $VMs 59 | Stats = $Stats 60 | } 61 | 62 | $Metric = Get-VMMetric @MetricParams 63 | 64 | if ($Metric.Measure) { 65 | 66 | if ($PSCmdlet.ShouldProcess($Metric.Measure)) { 67 | $Metric | Write-Influx -Database $Database -Server $Server 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Influx/Public/Write-Statsd.ps1: -------------------------------------------------------------------------------- 1 | Function Write-StatsD { 2 | <# 3 | .SYNOPSIS 4 | Send metrics to a statsd server via UDP for writing to Influx. 5 | 6 | .DESCRIPTION 7 | PowerShell cmdlet to send metric data to a statsd server. Unless server or port is passed, uses the default 127.0.0.1 and port of 8125. 8 | 9 | .PARAMETER InputObject 10 | A metric object (generated by one of the Get-*Metric cmdlets from this module) which can be provided as pipeline input 11 | and will be automatically converted to StatsD strings. 12 | 13 | .PARAMETER Data 14 | Metric data to send to statsd. If string is not enclosed in quotes (single or double), the pipe character needs to be escaped. 15 | 16 | .PARAMETER IP 17 | IP address for statsd server 18 | 19 | .PARAMETER Port 20 | Port that statsd server is listening to 21 | 22 | .EXAMPLE 23 | Write-StatsD 'my_metric:123|g' 24 | 25 | This will write a value to a gauge metric named my_metric. 26 | 27 | .EXAMPLE 28 | Write-StatsD 'my_metric:321|g' -ip 10.0.0.10 -port 8180 29 | 30 | This will write a value to a gauge metric named my_metric via the specified IP and port. 31 | 32 | .EXAMPLE 33 | 'my_metric:1|c' | Write-StatsD 34 | 35 | This will write a value to a counter metric, using the piepline as input for the cmdlet. 36 | #> 37 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] 38 | param( 39 | [Parameter(ParameterSetName = 'MetricObject', Mandatory = $True, ValueFromPipeline = $True, Position = 0)] 40 | [PSTypeName('Metric')] 41 | [PSObject[]] 42 | $InputObject, 43 | 44 | [parameter(ParameterSetName = 'StatsDString', Mandatory = $True, ValueFromPipeline = $True, Position = 0)] 45 | [string[]] 46 | $Data, 47 | 48 | [ipaddress] 49 | $IP = '127.0.0.1', 50 | 51 | [int] 52 | $Port = 8125 53 | ) 54 | Process { 55 | if ($InputObject) { 56 | $Data = $InputObject | ConvertTo-StatsDString 57 | } 58 | 59 | foreach ($Item in $Data) { 60 | 61 | if ($PSCmdlet.ShouldProcess("$($IP):$Port", "$($MyInvocation.MyCommand) -Data $Item")) { 62 | $Item | Invoke-UDPSendMethod -IP $IP -Port $Port 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /PSScriptAnalyzerSettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ExcludeRules = @( 3 | 'PSAvoidTrailingWhitespace', 4 | 'PSAvoidGlobalVars', 5 | 'PSAvoidUsingCmdletAliases', 6 | 'PSUseDeclaredVarsMoreThanAssignments' 7 | ) 8 | 9 | Severity = @( 10 | "Warning", 11 | "Error" 12 | ) 13 | 14 | Rules = @{} 15 | } 16 | -------------------------------------------------------------------------------- /Tests/Common/Help.Tests.ps1: -------------------------------------------------------------------------------- 1 | # Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1) 2 | # Import module 3 | if (-not (Get-Module -Name $env:BHProjectName -ListAvailable)) { 4 | Import-Module -Name $env:BHPSModuleManifest -ErrorAction 'Stop' -Force 5 | } 6 | $commands = Get-Command -Module $env:BHProjectName -CommandType Cmdlet, Function -ErrorAction 'Stop' # Not alias 7 | 8 | ## When testing help, remember that help is cached at the beginning of each session. 9 | ## To test, restart session. 10 | foreach ($command in $commands) { 11 | $commandName = $command.Name 12 | 13 | # The module-qualified command fails on Microsoft.PowerShell.Archive cmdlets 14 | $help = Get-Help $commandName -ErrorAction SilentlyContinue 15 | 16 | Describe "Test help for $commandName" { 17 | 18 | # If help is not found, synopsis in auto-generated help is the syntax diagram 19 | It 'Should not be auto-generated' { 20 | $help.Synopsis | Should Not BeLike '*`[``]*' 21 | } 22 | 23 | # Should be a description for every function 24 | It "Gets description for $commandName" { 25 | $help.Description | Should Not BeNullOrEmpty 26 | } 27 | 28 | # Should be at least one example 29 | It "Gets example code from $commandName" { 30 | ($help.Examples.Example | Select-Object -First 1).Code | Should Not BeNullOrEmpty 31 | } 32 | 33 | # Should be at least one example description 34 | It "Gets example help from $commandName" { 35 | ($help.Examples.Example.Remarks | Select-Object -First 1).Text | Should Not BeNullOrEmpty 36 | } 37 | 38 | Context "Test parameter help for $commandName" { 39 | 40 | $common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 41 | 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable', 'Confirm', 'Whatif' 42 | 43 | $parameters = $command.ParameterSets.Parameters | 44 | Sort-Object -Property Name -Unique | 45 | Where-Object { $_.Name -notin $common } 46 | $parameterNames = $parameters.Name 47 | 48 | ## Without the filter, WhatIf and Confirm parameters are still flagged in "finds help parameter in code" test 49 | $helpParameters = $help.Parameters.Parameter | 50 | Where-Object { $_.Name -notin $common } | 51 | Sort-Object -Property Name -Unique 52 | $helpParameterNames = $helpParameters.Name 53 | 54 | foreach ($parameter in $parameters) { 55 | $parameterName = $parameter.Name 56 | $parameterHelp = $help.parameters.parameter | Where-Object Name -EQ $parameterName 57 | 58 | # Should be a description for every parameter 59 | It "Gets help for parameter: $parameterName : in $commandName" { 60 | $parameterHelp.Description.Text | Should Not BeNullOrEmpty 61 | } 62 | 63 | # Required value in Help should match IsMandatory property of parameter 64 | It "Help for $parameterName parameter in $commandName has correct Mandatory value" { 65 | $codeMandatory = $parameter.IsMandatory.toString() 66 | $parameterHelp.Required | Should Be $codeMandatory 67 | } 68 | 69 | # Parameter type in Help should match code 70 | # It "help for $commandName has correct parameter type for $parameterName" { 71 | # $codeType = $parameter.ParameterType.Name 72 | # # To avoid calling Trim method on a null object. 73 | # $helpType = if ($parameterHelp.parameterValue) { $parameterHelp.parameterValue.Trim() } 74 | # $helpType | Should be $codeType 75 | # } 76 | } 77 | 78 | foreach ($helpParm in $HelpParameterNames) { 79 | # Shouldn't find extra parameters in help. 80 | It "Finds help parameter in code: $helpParm" { 81 | $helpParm -in $parameterNames | Should Be $true 82 | } 83 | } 84 | } 85 | 86 | Context "Help Links should be Valid for $commandName" { 87 | $link = $help.relatedLinks.navigationLink.uri 88 | 89 | foreach ($link in $links) { 90 | if ($link) { 91 | # Should have a valid uri if one is provided. 92 | It "[$link] should have 200 Status Code for $commandName" { 93 | $Results = Invoke-WebRequest -Uri $link -UseBasicParsing 94 | $Results.StatusCode | Should Be '200' 95 | } 96 | } 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Tests/Common/Manifest.Tests.ps1: -------------------------------------------------------------------------------- 1 | # Vars 2 | $changelogPath = Join-Path -Path $env:BHProjectPath -Child 'CHANGELOG.md' 3 | 4 | Describe 'Module manifest' { 5 | Context 'Validation' { 6 | 7 | $script:manifest = $null 8 | 9 | It 'Has a valid manifest' { 10 | { 11 | $script:manifest = Test-ModuleManifest -Path $env:BHPSModuleManifest -Verbose:$false -ErrorAction 'Stop' -WarningAction 'SilentlyContinue' 12 | } | Should Not Throw 13 | } 14 | 15 | It 'Has a valid name in the manifest' { 16 | $script:manifest.Name | Should Be $env:BHProjectName 17 | } 18 | 19 | It 'Has a valid root module' { 20 | $script:manifest.RootModule | Should Be "$($env:BHProjectName).psm1" 21 | } 22 | 23 | It 'Has a valid version in the manifest' { 24 | $script:manifest.Version -as [Version] | Should Not BeNullOrEmpty 25 | } 26 | 27 | It 'Has a valid description' { 28 | $script:manifest.Description | Should Not BeNullOrEmpty 29 | } 30 | 31 | It 'Has a valid author' { 32 | $script:manifest.Author | Should Not BeNullOrEmpty 33 | } 34 | 35 | It 'Has a valid guid' { 36 | { 37 | [guid]::Parse($script:manifest.Guid) 38 | } | Should Not throw 39 | } 40 | 41 | It 'Has a valid copyright' { 42 | $script:manifest.CopyRight | Should Not BeNullOrEmpty 43 | } 44 | 45 | # Only for DSC modules 46 | # It 'exports DSC resources' { 47 | # $dscResources = ($Manifest.psobject.Properties | Where Name -eq 'ExportedDscResources').Value 48 | # @($dscResources).Count | Should Not Be 0 49 | # } 50 | 51 | $script:changelogVersion = $null 52 | It 'Has a valid version in the changelog' -Skip { 53 | foreach ($line in (Get-Content $changelogPath)) { 54 | if ($line -match "^##\s\[(?(\d+\.){1,3}\d+)\]") { 55 | $script:changelogVersion = $matches.Version 56 | break 57 | } 58 | } 59 | $script:changelogVersion | Should Not BeNullOrEmpty 60 | $script:changelogVersion -as [Version] | Should Not BeNullOrEmpty 61 | } 62 | 63 | It 'Has matching changelog and manifest versions' -Skip { 64 | $script:changelogVersion -as [Version] | Should be ( $script:manifest.Version -as [Version] ) 65 | } 66 | 67 | if (Get-Command -Name 'git.exe' -ErrorAction 'SilentlyContinue') { 68 | $script:tagVersion = $null 69 | 70 | # Skipped as we tag as part of CI build 71 | It 'Is tagged with a valid version' -skip { 72 | $thisCommit = git.exe log --decorate --oneline HEAD~1..HEAD 73 | 74 | if ($thisCommit -match 'tag:\s*(\d+(?:\.\d+)*)') { 75 | $script:tagVersion = $matches[1] 76 | } 77 | 78 | $script:tagVersion | Should Not BeNullOrEmpty 79 | $script:tagVersion -as [Version] | Should Not BeNullOrEmpty 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Tests/Common/PSSA.Tests.ps1: -------------------------------------------------------------------------------- 1 | # This runs all PSScriptAnalyzer rules as Pester tests to enable visibility when publishing test results 2 | # Vars 3 | $ScriptAnalyzerSettingsPath = Join-Path -Path $env:BHProjectPath -ChildPath 'PSScriptAnalyzerSettings.psd1' 4 | 5 | Describe 'Testing against PSSA rules' { 6 | Context 'PSSA Standard Rules' { 7 | $analysis = Invoke-ScriptAnalyzer -Path $env:BHModulePath -Recurse -Settings $ScriptAnalyzerSettingsPath 8 | $scriptAnalyzerRules = Get-ScriptAnalyzerRule 9 | 10 | forEach ($rule in $scriptAnalyzerRules) { 11 | It "Should pass $rule" { 12 | If ($analysis.RuleName -contains $rule) { 13 | $analysis | Where-Object RuleName -EQ $rule -OutVariable 'failures' | Out-Default 14 | $failures.Count | Should Be 0 15 | } 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/ConvertTo-Metric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 6 | 7 | Get-ChildItem $Root -Filter $Sut -Recurse | ForEach-Object { . $_.FullName } 8 | 9 | Describe "ConvertTo-Metric PS$PSVersion" { 10 | 11 | $SomeObject = @( 12 | [pscustomobject]@{ 13 | Name = 'Test' 14 | SomeValue = 1 15 | }, 16 | [pscustomobject]@{ 17 | Name = 'Other' 18 | SomeValue = 20 19 | } 20 | ) 21 | 22 | $MetricObject = $SomeObject | ConvertTo-Metric -Measure Test -MetricProperty Name,SomeValue 23 | 24 | It 'Should return Metric objects' { 25 | $MetricObject | ForEach-Object { 26 | $_.PSObject.TypeNames | Should -Contain 'Metric' 27 | } 28 | } 29 | It 'Should return two objects' { 30 | $MetricObject.count | Should -Be 2 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Tests/ConvertTo-StatsDString.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 6 | 7 | Get-ChildItem $Root -Filter $Sut -Recurse | ForEach-Object { . $_.FullName } 8 | 9 | Describe "ConvertTo-StatsDString PS$PSVersion" { 10 | 11 | $MeasureObject = [pscustomobject]@{ 12 | PSTypeName = 'Metric' 13 | Measure = 'SomeMeasure' 14 | Metrics = @{One = 'One'; Two = 2} 15 | Tags = @{TagOne = 'One'; TagTwo = 2} 16 | TimeStamp = (Get-Date) 17 | } 18 | 19 | Context 'Metric object input' { 20 | 21 | $StatsD = $MeasureObject | ConvertTo-StatsDString 22 | 23 | It 'Should return a string' { 24 | $StatsD | Should -BeOfType [String] 25 | } 26 | It 'Should return two StatsD formmated strings' { 27 | $StatsD[0] | Should -Be 'SomeMeasure.One,TagOne=One,TagTwo=2:One|g' 28 | $StatsD[1] | Should -Be 'SomeMeasure.Two,TagOne=One,TagTwo=2:2|g' 29 | } 30 | } 31 | 32 | Context '-Type specified as c' { 33 | 34 | $StatsD = $MeasureObject | ConvertTo-StatsDString -Type 'c' 35 | 36 | It 'Should return a string' { 37 | $StatsD | Should -BeOfType [String] 38 | } 39 | It 'Should return two StatsD formmated strings with the type set to c' { 40 | $StatsD[0] | Should -Be 'SomeMeasure.One,TagOne=One,TagTwo=2:One|c' 41 | $StatsD[1] | Should -Be 'SomeMeasure.Two,TagOne=One,TagTwo=2:2|c' 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Tests/ConvertTo-UnixTimeMillisecond.Tests.ps1: -------------------------------------------------------------------------------- 1 | if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 6 | 7 | Get-ChildItem $Root -Filter $Sut -Recurse | ForEach-Object { . $_.FullName } 8 | 9 | Describe "ConvertTo-UnixTimeMillisecond PS$PSVersion" { 10 | 11 | $NewTimeSpan = Get-Command New-TimeSpan 12 | 13 | Mock New-TimeSpan { & $NewTimeSpan -Start $Start -End $End } -Verifiable 14 | 15 | Context 'Date object input' { 16 | 17 | $UnixTime = Get-Date '01/01/2017' | ConvertTo-UnixTimeMillisecond 18 | 19 | It 'Should convert 01/01/2017 to 1483228800000' { 20 | $UnixTime | Should Be 1483228800000 21 | } 22 | It "Should return a [double] type value" { 23 | $UnixTime | Should BeOfType [double] 24 | } 25 | It 'Should execute all verifiable mocks' { 26 | Assert-VerifiableMock 27 | } 28 | It 'Should call New-TimeSpan exactly 1 time' { 29 | Assert-MockCalled New-TimeSpan -Exactly 1 30 | } 31 | } 32 | 33 | Context 'String object input' { 34 | 35 | $UnixTime = '01-01-2017 12:34:22.12' | ConvertTo-UnixTimeMillisecond 36 | 37 | It "Should convert '01-01-2017 12:34:22.12' to 1483274062120" { 38 | $UnixTime | Should Be 1483274062120 39 | } 40 | It "Should return a [double] type value" { 41 | $UnixTime | Should BeOfType [double] 42 | } 43 | It 'Should execute all verifiable mocks' { 44 | Assert-VerifiableMock 45 | } 46 | It 'Should call New-TimeSpan exactly 1 time' { 47 | Assert-MockCalled New-TimeSpan -Exactly 1 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Tests/ConvertTo-UnixTimeNanosecond.Tests.ps1: -------------------------------------------------------------------------------- 1 | if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 6 | 7 | Get-ChildItem $Root -Filter $Sut -Recurse | ForEach-Object { . $_.FullName } 8 | 9 | Describe "ConvertTo-UnixTimeNanosecond PS$PSVersion" { 10 | 11 | $NewTimeSpan = Get-Command New-TimeSpan 12 | 13 | Mock New-TimeSpan { & $NewTimeSpan -Start $Start -End $End } -Verifiable 14 | 15 | Context 'Date object input' { 16 | 17 | $UnixTime = Get-Date '01/01/2017' | ConvertTo-UnixTimeNanosecond 18 | 19 | It 'Should convert 01/01/2017 to 1483228800000000000' { 20 | $UnixTime | Should Be 1483228800000000000 21 | } 22 | It "Should return a [long] type value" { 23 | $UnixTime | Should BeOfType [long] 24 | } 25 | It 'Should execute all verifiable mocks' { 26 | Assert-VerifiableMock 27 | } 28 | It 'Should call New-TimeSpan exactly 1 time' { 29 | Assert-MockCalled New-TimeSpan -Exactly 1 30 | } 31 | } 32 | 33 | Context 'String object input' { 34 | 35 | $UnixTime = '01-01-2017 12:34:22.12' | ConvertTo-UnixTimeNanosecond 36 | 37 | It "Should convert '01-01-2017 12:34:22.12' to 1483274062120" { 38 | $UnixTime | Should Be 1483274062120000000 39 | } 40 | It "Should return a [long] type value" { 41 | $UnixTime | Should BeOfType [long] 42 | } 43 | It 'Should execute all verifiable mocks' { 44 | Assert-VerifiableMock 45 | } 46 | It 'Should call New-TimeSpan exactly 1 time' { 47 | Assert-MockCalled New-TimeSpan -Exactly 1 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Tests/Get-3ParSystemMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\..\" 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Get-3ParSystemMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Set-3parPoshSshConnectionUsingPasswordFile { } 16 | Function Get-3parSystem { } 17 | Function Get-3parSpace { } 18 | 19 | Mock Set-3parPoshSshConnectionUsingPasswordFile { } -Verbose 20 | 21 | Mock Get-3parSpace { Import-Clixml .\Tests\Mock-Get3parSpace.xml } -Verifiable 22 | 23 | Mock Write-Influx { } 24 | 25 | Context 'Simulating successful get' { 26 | 27 | Mock Import-Module { } -ParameterFilter {$Name -eq 'HPE3PARPSToolkit'} -Verifiable 28 | 29 | Mock Get-3parSystem { Import-Clixml .\Tests\Mock-Get3parSystem.xml } -Verifiable 30 | 31 | $Get3ParSys = Get-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 32 | 33 | it 'Should return a 3PARSystem measure' { 34 | $Get3ParSys.measure | Should -Be '3PARSystem' 35 | } 36 | It 'Should execute all verifiable mocks' { 37 | Assert-VerifiableMock 38 | } 39 | It 'Should call Import-Module exactly 1 time' { 40 | Assert-MockCalled Import-Module -Exactly 1 41 | } 42 | It 'Should call Set-3parPoshSshConnectionUsingPasswordFile exactly 1 time' { 43 | Assert-MockCalled Set-3parPoshSshConnectionUsingPasswordFile -Exactly 1 44 | } 45 | It 'Should call Get-3parSystem exactly 1 time' { 46 | Assert-MockCalled Get-3parSystem -Exactly 1 47 | } 48 | It 'Should call Get-3parSpace exactly 1 time' { 49 | Assert-MockCalled Get-3parSpace -Exactly 1 50 | } 51 | } 52 | 53 | Context 'Simulating no system data returned' { 54 | 55 | Mock Import-Module { } -ParameterFilter {$Name -eq 'HPE3PARPSToolkit'} -Verifiable 56 | 57 | Mock Get-3parSystem { } -Verifiable 58 | 59 | It 'Should return null' { 60 | Get-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd | Should -Be $null 61 | } 62 | It 'Should execute all verifiable mocks' { 63 | Assert-VerifiableMock 64 | } 65 | It 'Should call Import-Module exactly 1 time' { 66 | Assert-MockCalled Import-Module -Exactly 1 67 | } 68 | It 'Should call Set-3parPoshSshConnectionUsingPasswordFile exactly 1 time' { 69 | Assert-MockCalled Set-3parPoshSshConnectionUsingPasswordFile -Exactly 1 70 | } 71 | It 'Should call Get-3parSystem exactly 1 time' { 72 | Assert-MockCalled Get-3parSystem -Exactly 1 73 | } 74 | It 'Should call Get-3parSpace exactly 0 times' { 75 | Assert-MockCalled Get-3parSpace -Exactly 0 76 | } 77 | } 78 | 79 | Context 'Simulating module not found' { 80 | 81 | Mock Import-Module { Throw "The specified module 'HPE3PARPSToolkit' was not loaded because no valid module file was found in any module directory." } 82 | 83 | it 'Should throw when the module is not present' { 84 | { Get-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd } | Should Throw "The specified module 'HPE3PARPSToolkit' was not loaded because no valid module file was found in any module directory." 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /Tests/Influx.Tests.ps1: -------------------------------------------------------------------------------- 1 | if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Describe "Influx Module Tests PS$PSVersion" { 8 | 9 | It "Should import without errors" { 10 | {Import-Module "$Root\$Module" -Force -ErrorAction Stop} | Should -Not -Throw 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/Invoke-UDPSendMethod.Tests.ps1: -------------------------------------------------------------------------------- 1 | if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\..\" 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Invoke-UDPSendMethod PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | $NewObject = Get-Command New-Object 16 | 17 | Mock New-Object { & $NewObject -TypeName $TypeName -ArgumentList $ArgumentList -Property $Property } -Verifiable 18 | 19 | Context 'Simulating successful write' { 20 | 21 | Mock Write-Verbose { $null } 22 | 23 | $InvokeUDPSend = 'my_metric:1|c' | Invoke-UDPSendMethod -IP 1.2.3.4 -Port 1234 24 | 25 | It 'Invoke-UDPSendMethod should return null' { 26 | $InvokeUDPSend | Should -Be $null 27 | } 28 | It 'Should execute all verifiable mocks' { 29 | Assert-VerifiableMock 30 | } 31 | It 'Should call New-Object exactly 2 times' { 32 | Assert-MockCalled New-Object -Exactly 2 33 | } 34 | It 'Should call Write-Verbose exactly 1 times' { 35 | Assert-MockCalled Write-Verbose -Exactly 1 36 | } 37 | } 38 | 39 | Context 'Simulating -WhatIf' { 40 | 41 | Mock Write-Verbose { $null } -ParameterFilter {$WhatIf -eq $true} 42 | 43 | $InvokeUDPSend = 'my_metric:1|c' | Invoke-UDPSendMethod -IP 1.2.3.4 -Port 1234 -WhatIf 44 | 45 | It 'Invoke-UDPSendMethod should return null' { 46 | $InvokeUDPSend | Should -Be $null 47 | } 48 | It 'Should execute all verifiable mocks' { 49 | Assert-VerifiableMock 50 | } 51 | It 'Should call New-Object exactly 2 times' { 52 | Assert-MockCalled New-Object -Exactly 2 53 | } 54 | It 'Should call Write-Verbose exactly 0 times' { 55 | Assert-MockCalled Write-Verbose -Exactly 0 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Tests/Mock-Get-3parStatVV.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markwragg/PowerShell-Influx/0493b36816a4cb4beeaa2418e9663f519e86e9ba/Tests/Mock-Get-3parStatVV.xml -------------------------------------------------------------------------------- /Tests/Mock-Get3parSpace.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markwragg/PowerShell-Influx/0493b36816a4cb4beeaa2418e9663f519e86e9ba/Tests/Mock-Get3parSpace.xml -------------------------------------------------------------------------------- /Tests/Mock-Get3parSystem.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markwragg/PowerShell-Influx/0493b36816a4cb4beeaa2418e9663f519e86e9ba/Tests/Mock-Get3parSystem.xml -------------------------------------------------------------------------------- /Tests/Mock-GetisiStoragePools.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markwragg/PowerShell-Influx/0493b36816a4cb4beeaa2418e9663f519e86e9ba/Tests/Mock-GetisiStoragePools.xml -------------------------------------------------------------------------------- /Tests/Out-InfluxEscapeString.Tests.ps1: -------------------------------------------------------------------------------- 1 | if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\..\" 5 | $Sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 6 | 7 | Get-ChildItem $Root -Filter $Sut -Recurse | ForEach-Object { . $_.FullName } 8 | 9 | Describe "Out-InfluxEscapeString PS$PSVersion" { 10 | 11 | Context 'Simulating default escape (-StringType not used)' { 12 | 13 | $SomeString = 'I am a value = "hei, \you\"' | Out-InfluxEscapeString 14 | 15 | It "Should convert 'I am a value = ""hei,\ \you\""'" { 16 | $SomeString | Should -Be 'I\ am\ a\ value\ \=\ \"hei\,\ \\you\\\"' 17 | } 18 | It "Should return a [string] type value" { 19 | $SomeString | Should -BeOfType [string] 20 | } 21 | } 22 | 23 | Context 'Simulating escape of Measurement (-StringType Measurement)' { 24 | $SomeString = 'AwfulName= \Table,\' | Out-InfluxEscapeString -StringType Measurement 25 | 26 | It "Should return a [string] type value" { 27 | $SomeString | Should -BeOfType [string] 28 | } 29 | It "Should convert 'AwfulName= \Table,\' to 'AwfulName=\ \\Table\,\\'" { 30 | $SomeString | Should -Be 'AwfulName=\ \\Table\,\\' 31 | } 32 | } 33 | 34 | Context 'Simulating escape of Field Text Value (-StringType FieldTextValue)' { 35 | $SomeString = 'This is a "String" field value' | Out-InfluxEscapeString -StringType FieldTextValue 36 | 37 | It "Should return a [string] type value" { 38 | $SomeString | Should -BeOfType [string] 39 | } 40 | It "Should convert 'This is a ""String"" field value' to 'This is a \""String\"" field value'" { 41 | $SomeString | Should -Be 'This is a \"String\" field value' 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Tests/Send-3ParSystemMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\..\" 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-3ParSystemMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Set-3parPoshSshConnectionUsingPasswordFile { } 16 | Function Get-3parSystem { } 17 | Function Get-3parSpace { } 18 | 19 | Mock Set-3parPoshSshConnectionUsingPasswordFile { } -Verbose 20 | 21 | Mock Get-3parSpace { Import-Clixml .\Tests\Mock-Get3parSpace.xml } -Verifiable 22 | 23 | Mock Write-Influx { } 24 | 25 | Context 'Simulating successful send' { 26 | 27 | Mock Import-Module { } -ParameterFilter {$Name -eq 'HPE3PARPSToolkit'} -Verifiable 28 | 29 | Mock Get-3parSystem { Import-Clixml .\Tests\Mock-Get3parSystem.xml } -Verifiable 30 | 31 | $Send3ParSys = Send-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd 32 | 33 | it 'Should return null' { 34 | $Send3ParSys | Should be $null 35 | } 36 | It 'Should execute all verifiable mocks' { 37 | Assert-VerifiableMock 38 | } 39 | It 'Should call Import-Module exactly 1 time' { 40 | Assert-MockCalled Import-Module -Exactly 1 41 | } 42 | It 'Should call Set-3parPoshSshConnectionUsingPasswordFile exactly 1 time' { 43 | Assert-MockCalled Set-3parPoshSshConnectionUsingPasswordFile -Exactly 1 44 | } 45 | It 'Should call Get-3parSystem exactly 1 time' { 46 | Assert-MockCalled Get-3parSystem -Exactly 1 47 | } 48 | It 'Should call Get-3parSpace exactly 1 time' { 49 | Assert-MockCalled Get-3parSpace -Exactly 1 50 | } 51 | It 'Should call Write-Influx exactly 1 time' { 52 | Assert-MockCalled Write-Influx -Exactly 1 53 | } 54 | } 55 | 56 | Context 'Simulating no system data returned' { 57 | 58 | Mock Import-Module { } -ParameterFilter {$Name -eq 'HPE3PARPSToolkit'} -Verifiable 59 | 60 | Mock Get-3parSystem { } -Verifiable 61 | 62 | It 'Should return null' { 63 | Send-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd | Should -Be $null 64 | } 65 | It 'Should execute all verifiable mocks' { 66 | Assert-VerifiableMock 67 | } 68 | It 'Should call Import-Module exactly 1 time' { 69 | Assert-MockCalled Import-Module -Exactly 1 70 | } 71 | It 'Should call Set-3parPoshSshConnectionUsingPasswordFile exactly 1 time' { 72 | Assert-MockCalled Set-3parPoshSshConnectionUsingPasswordFile -Exactly 1 73 | } 74 | It 'Should call Get-3parSystem exactly 1 time' { 75 | Assert-MockCalled Get-3parSystem -Exactly 1 76 | } 77 | It 'Should call Get-3parSpace exactly 0 times' { 78 | Assert-MockCalled Get-3parSpace -Exactly 0 79 | } 80 | It 'Should call Write-Influx exactly 0 times' { 81 | Assert-MockCalled Write-Influx -Exactly 0 82 | } 83 | } 84 | 85 | Context 'Simulating module not found' { 86 | 87 | Mock Import-Module { Throw "The specified module 'HPE3PARPSToolkit' was not loaded because no valid module file was found in any module directory." } 88 | 89 | it 'Should throw when the module is not present' { 90 | { Send-3ParSystemMetric -SANIPAddress 1.2.3.4 -SANUsername admin -SANPwdFile C:\scripts\3par.pwd } | Should Throw "The specified module 'HPE3PARPSToolkit' was not loaded because no valid module file was found in any module directory." 91 | } 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /Tests/Send-DatacenterMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-DatacenterMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-Datacenter { } 16 | Function Get-VM { } 17 | 18 | Mock Write-Influx { } 19 | 20 | Context 'Simulating successful send' { 21 | 22 | Mock Get-Datacenter { 23 | [PSCustomObject]@{ 24 | Name = 'Test Datacenter' 25 | ParentFolder = 'Some Folder' 26 | } 27 | } -Verifiable 28 | 29 | Mock Get-VM { 30 | [PSCustomObject]@{ 31 | Name = 'TestVM001' 32 | ParentFolder = 'Some Folder' 33 | MemoryGB = 4 34 | NumCPU = 2 35 | PowerState = 'PoweredOn' 36 | } 37 | [PSCustomObject]@{ 38 | Name = 'TestVM002' 39 | ParentFolder = 'Some Other Folder' 40 | MemoryGB = 8 41 | NumCPU = 4 42 | PowerState = 'PoweredOff' 43 | } 44 | } -Verifiable 45 | 46 | $SendDC = Send-DatacenterMetric 47 | 48 | it 'Should return null' { 49 | $SendDC | Should be $null 50 | } 51 | It 'Should execute all verifiable mocks' { 52 | Assert-VerifiableMock 53 | } 54 | It 'Should call Get-Datacenter exactly 1 time' { 55 | Assert-MockCalled Get-Datacenter -Exactly 1 56 | } 57 | It 'Should call Get-VM exactly 1 time' { 58 | Assert-MockCalled Get-VM -Exactly 1 59 | } 60 | It 'Should call Write-Influx exactly 1 time' { 61 | Assert-MockCalled Write-Influx -Exactly 1 62 | } 63 | } 64 | 65 | Context 'Simulating no Datacenter data returned' { 66 | 67 | Mock Get-Datacenter { } -Verifiable 68 | 69 | Mock Get-VM { } 70 | 71 | It 'Should return null' { 72 | Send-DatacenterMetric | Should -Be $null 73 | } 74 | It 'Should execute all verifiable mocks' { 75 | Assert-VerifiableMock 76 | } 77 | It 'Should call Get-Datacenter exactly 1 time' { 78 | Assert-MockCalled Get-Datacenter -Exactly 1 79 | } 80 | It 'Should call Get-VM exactly 0 times' { 81 | Assert-MockCalled Get-VM -Exactly 0 82 | } 83 | It 'Should call Write-Influx exactly 0 times' { 84 | Assert-MockCalled Write-Influx -Exactly 0 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /Tests/Send-DatastoreClusterMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-DatastoreClusterMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-DatastoreCluster { } 16 | 17 | Mock Write-Influx { } 18 | 19 | Context 'Simulating successful send' { 20 | 21 | Mock Get-DatastoreCluster { 22 | [PSCustomObject]@{ 23 | Name = 'Test Datastore Cluster' 24 | CapacityGB = 12345.987 25 | FreespaceGB = 654.123 26 | } 27 | } -Verifiable 28 | 29 | $SendDatastore = Send-DatastoreClusterMetric 30 | 31 | it 'Should return null' { 32 | $SendDatastore | Should be $null 33 | } 34 | It 'Should execute all verifiable mocks' { 35 | Assert-VerifiableMock 36 | } 37 | It 'Should call Get-DatastoreCluster exactly 1 time' { 38 | Assert-MockCalled Get-DatastoreCluster -Exactly 1 39 | } 40 | It 'Should call Write-Influx exactly 1 time' { 41 | Assert-MockCalled Write-Influx -Exactly 1 42 | } 43 | } 44 | 45 | Context 'Simulating no DatastoreCluster data returned' { 46 | 47 | Mock Get-DatastoreCluster { } -Verifiable 48 | 49 | It 'Should return null' { 50 | Send-DatastoreClusterMetric | Should -Be $null 51 | } 52 | It 'Should execute all verifiable mocks' { 53 | Assert-VerifiableMock 54 | } 55 | It 'Should call Get-DatastoreCluster exactly 1 time' { 56 | Assert-MockCalled Get-DatastoreCluster -Exactly 1 57 | } 58 | It 'Should call Write-Influx exactly 0 times' { 59 | Assert-MockCalled Write-Influx -Exactly 0 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Tests/Send-DatastoreMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-DatastoreMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-Datastore { } 16 | 17 | Mock Write-Influx { } 18 | 19 | Context 'Simulating successful send' { 20 | 21 | Mock Get-Datastore { 22 | [PSCustomObject]@{ 23 | Name = 'Test Datastore' 24 | CapacityGB = 12345.987 25 | FreespaceGB = 654.123 26 | } 27 | } -Verifiable 28 | 29 | $SendDatastore = Send-DatastoreMetric 30 | 31 | it 'Should return null' { 32 | $SendDatastore | Should be $null 33 | } 34 | It 'Should execute all verifiable mocks' { 35 | Assert-VerifiableMock 36 | } 37 | It 'Should call Get-Datastore exactly 1 time' { 38 | Assert-MockCalled Get-Datastore -Exactly 1 39 | } 40 | It 'Should call Write-Influx exactly 1 time' { 41 | Assert-MockCalled Write-Influx -Exactly 1 42 | } 43 | } 44 | 45 | Context 'Simulating no Datastore data returned' { 46 | 47 | Mock Get-Datastore { } -Verifiable 48 | 49 | it 'Should return null' { 50 | Send-DatastoreMetric | Should be $null 51 | } 52 | It 'Should execute all verifiable mocks' { 53 | Assert-VerifiableMock 54 | } 55 | It 'Should call Get-Datastore exactly 1 time' { 56 | Assert-MockCalled Get-Datastore -Exactly 1 57 | } 58 | It 'Should call Write-Influx exactly 0 times' { 59 | Assert-MockCalled Write-Influx -Exactly 0 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Tests/Send-HostMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-HostMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-VMHost { } 16 | Function Get-Stat { } 17 | 18 | Mock Write-Influx { } 19 | 20 | Context 'Simulating successful send' { 21 | 22 | Mock Get-VMHost { 23 | [PSCustomObject]@{ 24 | Name = 'Test VMHost' 25 | CpuTotalMhz = 30396 26 | CpuUsageMhz = 7651 27 | MemoryTotalGB = 255.906 28 | MemoryUsageGB = 123.456 29 | 30 | } 31 | } -Verifiable 32 | 33 | Mock Get-Stat { } 34 | 35 | $SendVMHost = Send-HostMetric 36 | 37 | it 'Should return null' { 38 | $SendVMHost | Should be $null 39 | } 40 | It 'Should execute all verifiable mocks' { 41 | Assert-VerifiableMock 42 | } 43 | It 'Should call Get-VMHost exactly 1 time' { 44 | Assert-MockCalled Get-VMHost -Exactly 1 45 | } 46 | It 'Should call Get-Stat exactly 0 times' { 47 | Assert-MockCalled Get-Stat -Exactly 0 48 | } 49 | It 'Should call Write-Influx exactly 1 time' { 50 | Assert-MockCalled Write-Influx -Exactly 1 51 | } 52 | } 53 | 54 | Context 'Simulating successful send with -Stats switch' { 55 | 56 | Mock Get-VMHost { 57 | [PSCustomObject]@{ 58 | Name = 'Test VMHost' 59 | CpuTotalMhz = 30396 60 | CpuUsageMhz = 7651 61 | MemoryTotalGB = 255.906 62 | MemoryUsageGB = 123.456 63 | 64 | } 65 | } -Verifiable 66 | 67 | Mock Get-Stat { 68 | [PSCustomObject]@{ 69 | Entity = @{Name = 'Test VMHost'} 70 | MetricID = 'cpu.usage.average' 71 | Timestamp = '12/31/2017 12:00:00 AM' 72 | Value = '0.11' 73 | Unit = '%' 74 | } 75 | } -Verifiable 76 | 77 | $SendVMHost = Send-HostMetric -Stats 78 | 79 | it 'Should return null' { 80 | $SendVMHost | Should be $null 81 | } 82 | It 'Should execute all verifiable mocks' { 83 | Assert-VerifiableMock 84 | } 85 | It 'Should call Get-VMHost exactly 1 time' { 86 | Assert-MockCalled Get-VMHost -Exactly 1 87 | } 88 | It 'Should call Get-Stat exactly 1 time' { 89 | Assert-MockCalled Get-Stat -Exactly 1 90 | } 91 | It 'Should call Write-Influx exactly 1 time' { 92 | Assert-MockCalled Write-Influx -Exactly 1 93 | } 94 | } 95 | 96 | Context 'Simulating no VMHost data returned' { 97 | 98 | Mock Get-VMHost { } -Verifiable 99 | 100 | Mock Get-Stat { } 101 | 102 | it 'Should return null' { 103 | Send-HostMetric | Should be $null 104 | } 105 | It 'Should execute all verifiable mocks' { 106 | Assert-VerifiableMock 107 | } 108 | It 'Should call Get-VMHost exactly 1 time' { 109 | Assert-MockCalled Get-VMHost -Exactly 1 110 | } 111 | It 'Should call Get-Stat exactly 0 times' { 112 | Assert-MockCalled Get-Stat -Exactly 0 113 | } 114 | It 'Should call Write-Influx exactly 0 times' { 115 | Assert-MockCalled Write-Influx -Exactly 0 116 | } 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /Tests/Send-IsilonStoragePoolMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-IsilonStoragePoolMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function New-isiSession { } 16 | Function Get-isiStoragepools { } 17 | Function Remove-isiSession { } 18 | 19 | Mock New-isiSession { } -Verifiable 20 | 21 | $ImportClixml = Get-Command Import-Clixml 22 | 23 | Mock Import-Clixml { } -Verifiable 24 | 25 | Mock Remove-isiSession { } -Verifiable 26 | 27 | Mock Write-Influx { } 28 | 29 | Context 'Simulating successful send' { 30 | 31 | Mock Import-Module { } -ParameterFilter {$Name -eq 'IsilonPlatform'} -Verifiable 32 | 33 | Mock Get-isiStoragepools { & $ImportClixml -Path .\Tests\Mock-GetisiStoragePools.xml } -Verifiable 34 | 35 | $SendIsilonSP = Send-IsilonStoragePoolMetric -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 36 | 37 | it 'Should return null' { 38 | $SendIsilonSP | Should be $null 39 | } 40 | It 'Should execute all verifiable mocks' { 41 | Assert-VerifiableMock 42 | } 43 | It 'Should call Import-Module exactly 1 time' { 44 | Assert-MockCalled Import-Module -Exactly 1 45 | } 46 | It 'Should call New-isiSession exactly 1 time' { 47 | Assert-MockCalled New-isiSession -Exactly 1 48 | } 49 | It 'Should call Get-isiStoragepools exactly 1 time' { 50 | Assert-MockCalled Get-isiStoragepools -Exactly 1 51 | } 52 | It 'Should call Write-Influx exactly 1 time' { 53 | Assert-MockCalled Write-Influx -Exactly 1 54 | } 55 | It 'Should call Remove-isiSession exactly 1 time' { 56 | Assert-MockCalled Remove-isiSession -Exactly 1 57 | } 58 | 59 | } 60 | 61 | Context 'Simulating no storage pool data returned' { 62 | 63 | Mock Import-Module { } -ParameterFilter {$Name -eq 'IsilonPlatform'} -Verifiable 64 | 65 | Mock Get-isiStoragepools { } -Verifiable 66 | 67 | $SendIsilonSP = Send-IsilonStoragePoolMetric -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab 68 | 69 | it 'Should return null' { 70 | $SendIsilonSP | Should be $null 71 | } 72 | It 'Should execute all verifiable mocks' { 73 | Assert-VerifiableMock 74 | } 75 | It 'Should call Import-Module exactly 1 time' { 76 | Assert-MockCalled Import-Module -Exactly 1 77 | } 78 | It 'Should call New-isiSession exactly 1 time' { 79 | Assert-MockCalled New-isiSession -Exactly 1 80 | } 81 | It 'Should call Get-isiStoragepools exactly 1 time' { 82 | Assert-MockCalled Get-isiStoragepools -Exactly 1 83 | } 84 | It 'Should call Write-Influx exactly 1 time' { 85 | Assert-MockCalled Write-Influx -Exactly 0 86 | } 87 | It 'Should call Remove-isiSession exactly 1 time' { 88 | Assert-MockCalled Remove-isiSession -Exactly 1 89 | } 90 | } 91 | 92 | Context 'Simulating module not found' { 93 | 94 | Mock Import-Module { Throw "The specified module 'IsilonPlatform' was not loaded because no valid module file was found in any module directory." } 95 | 96 | it 'Should throw when the module is not present' { 97 | { Send-IsilonStoragePoolMetric -IsilonName 1.2.3.4 -IsilonPwdFile C:\scripts\Isilon.pwd -ClusterName TestLab } | Should Throw "The specified module 'IsilonPlatform' was not loaded because no valid module file was found in any module directory." 98 | } 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /Tests/Send-ResourcePoolMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-ResourcePoolMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-ResourcePool { } 16 | Function Get-VM { } 17 | 18 | Mock Write-Influx { } 19 | 20 | Context 'Simulating successful send' { 21 | 22 | Mock Get-ResourcePool { 23 | [PSCustomObject]@{ 24 | Name = 'Test ResourcePool' 25 | Parent = 'Parent Folder' 26 | } 27 | } -Verifiable 28 | 29 | Mock Get-VM { 30 | [PSCustomObject]@{ 31 | Name = 'TestVM001' 32 | ParentFolder = 'Some Folder' 33 | MemoryGB = 4 34 | NumCPU = 2 35 | PowerState = 'PoweredOn' 36 | } 37 | [PSCustomObject]@{ 38 | Name = 'TestVM002' 39 | ParentFolder = 'Some Other Folder' 40 | MemoryGB = 8 41 | NumCPU = 4 42 | PowerState = 'PoweredOff' 43 | } 44 | } -Verifiable 45 | 46 | $SendResourcePool = Send-ResourcePoolMetric 47 | 48 | it 'Should return null' { 49 | $SendResourcePool | Should be $null 50 | } 51 | It 'Should execute all verifiable mocks' { 52 | Assert-VerifiableMock 53 | } 54 | It 'Should call Get-ResourcePool exactly 1 time' { 55 | Assert-MockCalled Get-ResourcePool -Exactly 1 56 | } 57 | It 'Should call Get-VM exactly 1 time' { 58 | Assert-MockCalled Get-VM -Exactly 1 59 | } 60 | It 'Should call Write-Influx exactly 1 time' { 61 | Assert-MockCalled Write-Influx -Exactly 1 62 | } 63 | } 64 | 65 | Context 'Simulating no ResourcePool data returned' { 66 | 67 | Mock Get-ResourcePool { } -Verifiable 68 | 69 | Mock Get-VM { } 70 | 71 | $SendResourcePool = Send-ResourcePoolMetric 72 | 73 | it 'Should return null' { 74 | $SendResourcePool | Should be $null 75 | } 76 | It 'Should execute all verifiable mocks' { 77 | Assert-VerifiableMock 78 | } 79 | It 'Should call Get-ResourcePool exactly 1 time' { 80 | Assert-MockCalled Get-ResourcePool -Exactly 1 81 | } 82 | It 'Should call Get-VM exactly 0 times' { 83 | Assert-MockCalled Get-VM -Exactly 0 84 | } 85 | It 'Should call Write-Influx exactly 0 times' { 86 | Assert-MockCalled Write-Influx -Exactly 0 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Tests/Send-VMMetric.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\.." 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Send-VMMetric PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Function Get-VM { } 16 | Function Get-Stat { } 17 | 18 | Mock Write-Influx { } 19 | 20 | Context 'Simulating successful send' { 21 | 22 | Mock Get-VM { 23 | [PSCustomObject]@{ 24 | Name = 'TestVM001' 25 | ParentFolder = 'Some Folder' 26 | MemoryGB = 4 27 | NumCPU = 2 28 | PowerState = 1 29 | } 30 | [PSCustomObject]@{ 31 | Name = 'TestVM002' 32 | ParentFolder = 'Some Other Folder' 33 | MemoryGB = 8 34 | NumCPU = 4 35 | PowerState = 0 36 | } 37 | } -Verifiable 38 | 39 | Mock Get-Stat { } 40 | 41 | $SendVM = Send-VMMetric 42 | 43 | it 'Should return null' { 44 | $SendVM | Should be $null 45 | } 46 | It 'Should execute all verifiable mocks' { 47 | Assert-VerifiableMock 48 | } 49 | It 'Should call Get-VM exactly 1 time' { 50 | Assert-MockCalled Get-VM -Exactly 1 51 | } 52 | It 'Should call Get-Stat exactly 0 times' { 53 | Assert-MockCalled Get-Stat -Exactly 0 54 | } 55 | It 'Should call Write-Influx exactly 2 time' { 56 | Assert-MockCalled Write-Influx -Exactly 2 57 | } 58 | } 59 | 60 | Context 'Simulating successful send with -Stats switch' { 61 | 62 | Mock Get-VM { 63 | [PSCustomObject]@{ 64 | Name = 'TestVM001' 65 | ParentFolder = 'Some Folder' 66 | MemoryGB = 4 67 | NumCPU = 2 68 | PowerState = 1 69 | ExtensionData = @{ 70 | Summary = @{ 71 | QuickStats = [PSCustomObject]@{ 72 | OverallCpuUsage = 10 73 | GuestMemoryUsage = 50 74 | HostMemoryUsage = 150 75 | UptimeSeconds = 1234567890 76 | } 77 | } 78 | } 79 | } 80 | } -Verifiable 81 | 82 | Mock Get-Stat { 83 | [PSCustomObject]@{ 84 | Entity = @{Name = 'TestVM001'} 85 | MetricID = 'cpu.usage.average' 86 | Timestamp = '12/31/2017 12:00:00 AM' 87 | Value = '0.11' 88 | Unit = '%' 89 | } 90 | } -Verifiable 91 | 92 | $SendVM = Send-VMMetric -Stats 93 | 94 | It 'Should return null' { 95 | $SendVM | Should be $null 96 | } 97 | It 'Should execute all verifiable mocks' { 98 | Assert-VerifiableMock 99 | } 100 | It 'Should call Get-VM exactly 1 time' { 101 | Assert-MockCalled Get-VM -Exactly 1 102 | } 103 | It 'Should call Get-Stat exactly 2 times' { 104 | Assert-MockCalled Get-Stat -Exactly 1 105 | } 106 | It 'Should call Write-Influx exactly 2 times' { 107 | Assert-MockCalled Write-Influx -Exactly 1 108 | } 109 | } 110 | 111 | Context 'Simulating no VM data returned' { 112 | 113 | Mock Get-VM { } -Verifiable 114 | 115 | Mock Get-Stat { } 116 | 117 | $SendVM = Send-VMMetric 118 | 119 | It 'Should return null' { 120 | $SendVM | Should be $null 121 | } 122 | It 'Should execute all verifiable mocks' { 123 | Assert-VerifiableMock 124 | } 125 | It 'Should call Get-VM exactly 1 time' { 126 | Assert-MockCalled Get-VM -Exactly 1 127 | } 128 | It 'Should call Get-Stat exactly 0 times' { 129 | Assert-MockCalled Get-Stat -Exactly 0 130 | } 131 | It 'Should call Write-Influx exactly 0 times' { 132 | Assert-MockCalled Write-Influx -Exactly 0 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /Tests/Write-Statsd.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } 2 | 3 | $PSVersion = $PSVersionTable.PSVersion.Major 4 | $Root = "$PSScriptRoot\..\" 5 | $Module = 'Influx' 6 | 7 | Get-Module $Module | Remove-Module -Force 8 | 9 | Import-Module "$Root\$Module" -Force 10 | 11 | Describe "Write-StatsD PS$PSVersion" { 12 | 13 | InModuleScope Influx { 14 | 15 | Context 'Simulating successful write' { 16 | 17 | Mock Invoke-UDPSendMethod { $null } -Verifiable 18 | 19 | $WriteStatsD = 'my_metric:1|c' | Write-StatsD -IP 1.2.3.4 -Port 1234 20 | 21 | It 'Write-StatsD should return null' { 22 | $WriteStatsD | Should -Be $null 23 | } 24 | It 'Should execute all verifiable mocks' { 25 | Assert-VerifiableMock 26 | } 27 | It 'Should call Invoke-UDPSendMethod exactly 1 time' { 28 | Assert-MockCalled Invoke-UDPSendMethod -Exactly 1 29 | } 30 | } 31 | 32 | Context 'Simulating successful write with object input' { 33 | 34 | Mock Invoke-UDPSendMethod { $null } -Verifiable 35 | 36 | $MeasureObject = [pscustomobject]@{ 37 | PSTypeName = 'Metric' 38 | Measure = 'SomeMeasure' 39 | Metrics = @{One = 'One'; Two = 2} 40 | Tags = @{TagOne = 'One'; TagTwo = 2} 41 | TimeStamp = (Get-Date) 42 | } 43 | 44 | $WriteStatsD = $MeasureObject | Write-StatsD -IP 1.2.3.4 -Port 1234 45 | 46 | It 'Write-StatsD should not return an error' { 47 | { $WriteStatsD } | Should -Not -Throw 48 | } 49 | It 'Should execute all verifiable mocks' { 50 | Assert-VerifiableMock 51 | } 52 | It 'Should call Invoke-UDPSendMethod exactly 1 time' { 53 | Assert-MockCalled Invoke-UDPSendMethod -Exactly 2 54 | } 55 | } 56 | 57 | Context 'Simulating -WhatIf' { 58 | 59 | Mock Invoke-UDPSendMethod { $null } -ParameterFilter {$WhatIf -eq $true} 60 | 61 | $WriteStatsD = 'my_metric:1|c' | Write-StatsD -IP 1.2.3.4 -Port 1234 -WhatIf 62 | 63 | It 'Write-StatsD should return null' { 64 | $WriteStatsD | Should -Be $null 65 | } 66 | It 'Should execute all verifiable mocks' { 67 | Assert-VerifiableMock 68 | } 69 | It 'Should call Invoke-UDPSendMethod exactly 0 times' { 70 | Assert-MockCalled Invoke-UDPSendMethod -Exactly 0 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - group: powershell-gallery 3 | 4 | # Build Pipeline 5 | pool: 6 | # What environment will the build agent run on? (Windows / Linux / macOS) 7 | vmImage: "windows-latest" 8 | 9 | trigger: 10 | batch: true 11 | 12 | # What branches will trigger a build? 13 | branches: 14 | include: 15 | # Any Pull Request merging into the master branch 16 | - master 17 | 18 | steps: 19 | - checkout: self 20 | persistCredentials: true 21 | clean: true 22 | 23 | - powershell: | 24 | .\Build\build.ps1 -ResolveDependency -TaskList 'Init' 25 | displayName: "Install Dependencies" 26 | 27 | - powershell: | 28 | .\Build\build.ps1 -TaskList 'CombineFunctionsAndStage' 29 | displayName: "Combine PowerShell functions into single module file" 30 | 31 | - powershell: | 32 | .\Build\build.ps1 -TaskList 'Analyze' 33 | displayName: "Analyze" 34 | 35 | - powershell: | 36 | .\Build\build.ps1 -TaskList 'Test' 37 | displayName: "Test" 38 | 39 | - powershell: | 40 | .\Build\build.ps1 -TaskList 'UpdateDocumentation' 41 | displayName: "Update Documentation" 42 | 43 | - powershell: | 44 | .\Build\build.ps1 -TaskList 'Deploy' 45 | displayName: "Deploy" 46 | 47 | - powershell: | 48 | .\Build\build.ps1 -TaskList 'Commit' 49 | displayName: "Commit Changes" 50 | 51 | - powershell: | 52 | .\Build\build.ps1 -TaskList 'CreateBuildArtifact' 53 | displayName: "Create Build Artifact" 54 | 55 | - task: PublishTestResults@2 56 | displayName: "Publish Pester Tests" 57 | inputs: 58 | testRunner: "NUnit" 59 | searchFolder: "Artifacts" 60 | testRunTitle: "PesterTests" 61 | condition: always() 62 | 63 | - task: PublishBuildArtifacts@1 64 | displayName: "Publish Artifact: PowerShell Module Zipped for offline use" 65 | inputs: 66 | PathtoPublish: Artifacts 67 | ArtifactName: Artifacts 68 | condition: always() 69 | 70 | - task: PublishBuildArtifacts@1 71 | displayName: "Publish Artifact: PowerShell Module" 72 | inputs: 73 | PathtoPublish: Staging 74 | ArtifactName: PSModule 75 | condition: always() 76 | --------------------------------------------------------------------------------