This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathicinga2-perfcounter-lib.psm1
65 lines (60 loc) · 2.64 KB
/
icinga2-perfcounter-lib.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<#
.Synopsis
Icinga 2 Performance Counter Library - Easy fetching of Performance Counter data
.DESCRIPTION
More Information on https://github.com/LordHepipud/icinga2-perfcounter-lib
.EXAMPLE
Get-Icinga2Counter -ListCounter 'Processor'
.EXAMPLE
Get-Icinga2Counter -Counter '\Processor(*)\% Processor Time'
.EXAMPLE
Get-Icinga2Counter -CounterArray @( '\Processor(*)\% Processor Time', '\Processor(*)\% c1 time')
.NOTES
#>
function Get-Icinga2Counter
{
[CmdletBinding()]
param(
# Allows to specify the full path of a counter to fetch data. Example '\Processor(*)\% Processor Time'
[string]$Counter = '',
# Allows to fetch all counters of a specific category, like 'Processor'
[string]$ListCounter = '',
# Provide an array of counters we check in a bulk '\Processor(*)\% Processor Time', '\Processor(*)\% c1 time'"
[array]$CounterArray = @(),
# List all available Performance Counter Categories on a system
[switch]$ListCategories = $FALSE,
# By default counters will wait globally for 500 milliseconds. With this we can skip it. Use with caution!
[switch]$SkipWait = $FALSE,
# These arguments apply to CreateStructuredPerformanceCounterTable
# This is the category name we want to create a structured output
# Example: 'Network Interface'
[string]$CreateStructuredOutputForCategory = '',
# This is the hashtable of Performance Counters, created by
# PerformanceCounterArray
[hashtable]$StructuredCounterInput = @{},
# This argument is just a helper to replace certain strings within
# a instance name with simply nothing.
# Example: 'HarddiskVolume1' => '1'
[array]$StructuredCounterInstanceCleanup = @(),
# Enable PowerShell Tracing (0 / 1 / 2)
[int16]$Trace = 0
);
Set-PSDebug -Trace $Trace;
$CounterScript = Join-Path $PSScriptRoot -ChildPath 'perfcounter.ps1';
return (&$CounterScript `
-Counter $Counter `
-ListCounter $ListCounter `
-CounterArray $CounterArray `
-ListCategories $ListCategories `
-SkipWait $SkipWait `
-CreateStructuredOutputForCategory $CreateStructuredOutputForCategory `
-StructuredCounterInput $StructuredCounterInput `
-StructuredCounterInstanceCleanup $StructuredCounterInstanceCleanup
);
}
$exportModuleData = @{
Function = @(
'Get-Icinga2Counter'
)
}
Export-ModuleMember @exportModuleData;