Skip to content

Commit f21c116

Browse files
committed
Removes plugin documentation creation function
1 parent 7d4b58c commit f21c116

File tree

2 files changed

+1
-164
lines changed

2 files changed

+1
-164
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2424
* [#211](https://github.com/Icinga/icinga-powershell-plugins/issues/211) Adds feature to `Invoke-IcingaCheckService`, allowing to filter for specific service startup types in case the plugin is used to check for specific services with `-Service`
2525
* [#237](https://github.com/Icinga/icinga-powershell-plugins/issues/237) Adds support for `Invoke-IcingaCheckHTTPStatus` to add the content of the website output by using the flag `-AddOutputContent`
2626
* [#241](https://github.com/Icinga/icinga-powershell-plugins/pull/241) Adds possibility to switch between free and used monitoring for `Invoke-IcingaCheckUNCPath` and consolidates monitoring like other plugins, with dynamic % monitoring.
27+
* [#243](https://github.com/Icinga/icinga-powershell-plugins/pull/243) Removes function `Publish-IcingaPluginDocumentation`, as this function will move directly into the Icinga PowerShell Framework
2728

2829
## 1.6.0 (2021-09-07)
2930

icinga-powershell-plugins.psm1

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -33,167 +33,3 @@ function Import-IcingaPlugins()
3333
Import-Module ([string]::Format('{0}.psm1', $module)) -Global;
3434
}
3535
}
36-
37-
function Publish-IcingaPluginDocumentation()
38-
{
39-
param (
40-
[string]$ModulePath = $PSScriptRoot
41-
);
42-
43-
[string]$PluginDir = Join-Path -Path $ModulePath -ChildPath 'plugins';
44-
[string]$DocDir = Join-Path -Path $ModulePath -ChildPath 'doc';
45-
[string]$PluginDocFile = Join-Path -Path $ModulePath -ChildPath 'doc/10-Icinga-Plugins.md';
46-
[string]$PluginDocDir = Join-Path -Path $ModulePath -ChildPath 'doc/plugins';
47-
48-
if ((Test-Path $PluginDocDir) -eq $FALSE) {
49-
New-Item -Path $PluginDocDir -ItemType Directory -Force | Out-Null;
50-
}
51-
52-
$MDFiles = Get-ChildItem -Path $PluginDocDir;
53-
[int]$FileCount = $MDFiles.Count;
54-
[string]$FileCountStr = '';
55-
56-
Set-Content -Path $PluginDocFile -Value '# Icinga Plugins';
57-
Add-Content -Path $PluginDocFile -Value '';
58-
Add-Content -Path $PluginDocFile -Value 'Below you will find a documentation for every single available plugin provided by this repository. Most of the plugins allow the usage of default Icinga threshold range handling, which is defined as follows:';
59-
Add-Content -Path $PluginDocFile -Value '';
60-
Add-Content -Path $PluginDocFile -Value '| Argument | Throws error on | Ok range |';
61-
Add-Content -Path $PluginDocFile -Value '| --- | --- | --- |';
62-
Add-Content -Path $PluginDocFile -Value '| 20 | < 0 or > 20 | 0 .. 20 |';
63-
Add-Content -Path $PluginDocFile -Value '| 20: | < 20 | between 20 .. ∞ |';
64-
Add-Content -Path $PluginDocFile -Value '| ~:20 | > 20 | between -∞ .. 20 |';
65-
Add-Content -Path $PluginDocFile -Value '| 30:40 | < 30 or > 40 | between {30 .. 40} |';
66-
Add-Content -Path $PluginDocFile -Value '| `@30:40 | ≥ 30 and ≤ 40 | outside -∞ .. 29 and 41 .. ∞ |';
67-
Add-Content -Path $PluginDocFile -Value '';
68-
Add-Content -Path $PluginDocFile -Value 'Please ensure that you will escape the `@` if you are configuring it on the Icinga side. To do so, you will simply have to write an *\`* before the `@` symbol: \``@`';
69-
Add-Content -Path $PluginDocFile -Value '';
70-
Add-Content -Path $PluginDocFile -Value 'To test thresholds with different input values, you can use the Framework Cmdlet `Get-IcingaHelpThresholds`.';
71-
Add-Content -Path $PluginDocFile -Value '';
72-
Add-Content -Path $PluginDocFile -Value 'Each plugin ships with a constant Framework argument `-ThresholdInterval`. This can be used to modify the value your thresholds are compared against from the current, fetched value to one collected over time by the Icinga for Windows daemon. In case you [registered service checks](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/) for specific time intervals, you can for example set the argument to `15m` to get the average value of 15m as base for your monitoring values. Please note that in this example, you will require to have collected the `15m` average for `Invoke-IcingaCheckCPU`.';
73-
Add-Content -Path $PluginDocFile -Value '';
74-
Add-Content -Path $PluginDocFile -Value '```powershell';
75-
Add-Content -Path $PluginDocFile -Value 'icinga> icinga { Invoke-IcingaCheckCPU -Warning 20 -Critical 40 -Core _Total -ThresholdInterval 15m }'
76-
Add-Content -Path $PluginDocFile -Value ''
77-
Add-Content -Path $PluginDocFile -Value '[WARNING] CPU Load: [WARNING] Core Total (29,14817700%)'
78-
Add-Content -Path $PluginDocFile -Value '\_ [WARNING] Core Total: 29,14817700% is greater than threshold 20% (15m avg.)';
79-
Add-Content -Path $PluginDocFile -Value "| 'core_total_1'=31.545677%;;;0;100 'core_total_15'=29.148177%;20;40;0;100 'core_total_5'=28.827410%;;;0;100 'core_total_20'=30.032942%;;;0;100 'core_total_3'=27.731669%;;;0;100 'core_total'=33.87817%;;;0;100";
80-
Add-Content -Path $PluginDocFile -Value '```';
81-
82-
$AvailablePlugins = Get-ChildItem -Path $PluginDir -Recurse -Filter *.psm1;
83-
foreach ($plugin in $AvailablePlugins) {
84-
[string]$PluginName = $plugin.Name.Replace('.psm1', '');
85-
[string]$PluginDocName = '';
86-
foreach ($DocFile in $MDFiles) {
87-
$DocFileName = $DocFile.Name;
88-
if ($DocFileName -Like "*$PluginName*") {
89-
$PluginDocName = $DocFile.Name;
90-
break;
91-
}
92-
}
93-
94-
if ([string]::IsNullOrEmpty($PluginDocName)) {
95-
$FileCount += 1;
96-
if ($FileCount -lt 10) {
97-
$FileCountStr = [string]::Format('0{0}', $FileCount);
98-
} else {
99-
$FileCountStr = $FileCount;
100-
}
101-
102-
$PluginDocName = [string]::Format('{0}-{1}.md', $FileCountStr, $PluginName);
103-
}
104-
[string]$PluginDescriptionFile = Join-Path -Path $PluginDocDir -ChildPath $PluginDocName;
105-
106-
Add-Content -Path $PluginDocFile -Value ([string]::Format(
107-
'* [{0}](plugins/{1})',
108-
$PluginName,
109-
$PluginDocName
110-
));
111-
112-
$PluginHelp = Get-Help $PluginName -Full;
113-
114-
Set-Content -Path $PluginDescriptionFile -Value ([string]::Format('# {0}', $PluginHelp.Name));
115-
Add-Content -Path $PluginDescriptionFile -Value '';
116-
Add-Content -Path $PluginDescriptionFile -Value '## Description';
117-
Add-Content -Path $PluginDescriptionFile -Value '';
118-
Add-Content -Path $PluginDescriptionFile -Value $PluginHelp.details.description.Text;
119-
Add-Content -Path $PluginDescriptionFile -Value '';
120-
Add-Content -Path $PluginDescriptionFile -Value $PluginHelp.description.Text;
121-
Add-Content -Path $PluginDescriptionFile -Value '';
122-
Add-Content -Path $PluginDescriptionFile -Value '## Permissions';
123-
Add-Content -Path $PluginDescriptionFile -Value '';
124-
125-
if ([string]::IsNullOrEmpty($PluginHelp.Role)) {
126-
Add-Content -Path $PluginDescriptionFile -Value 'No special permissions required.';
127-
} else {
128-
Add-Content -Path $PluginDescriptionFile -Value 'To execute this plugin you will require to grant the following user permissions.';
129-
Add-Content -Path $PluginDescriptionFile -Value '';
130-
Add-Content -Path $PluginDescriptionFile -Value $PluginHelp.Role;
131-
}
132-
133-
if ($null -ne $PluginHelp.parameters.parameter) {
134-
Add-Content -Path $PluginDescriptionFile -Value '';
135-
Add-Content -Path $PluginDescriptionFile -Value '## Arguments';
136-
Add-Content -Path $PluginDescriptionFile -Value '';
137-
Add-Content -Path $PluginDescriptionFile -Value '| Argument | Type | Required | Default | Description |';
138-
Add-Content -Path $PluginDescriptionFile -Value '| --- | --- | --- | --- | --- |';
139-
140-
foreach ($parameter in $PluginHelp.parameters.parameter) {
141-
[string]$ParamDescription = $parameter.description.Text;
142-
if ([string]::IsNullOrEmpty($ParamDescription) -eq $FALSE) {
143-
$ParamDescription = $ParamDescription.Replace("`r`n", ' ');
144-
$ParamDescription = $ParamDescription.Replace("`r", ' ');
145-
$ParamDescription = $ParamDescription.Replace("`n", ' ');
146-
}
147-
[string]$TableContent = [string]::Format(
148-
'| {0} | {1} | {2} | {3} | {4} |',
149-
$parameter.name,
150-
$parameter.type.name,
151-
$parameter.required,
152-
$parameter.defaultValue,
153-
$ParamDescription
154-
);
155-
Add-Content -Path $PluginDescriptionFile -Value $TableContent;
156-
}
157-
158-
Add-Content -Path $PluginDescriptionFile -Value '| ThresholdInterval | Object | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. |';
159-
}
160-
161-
if ($null -ne $PluginHelp.examples) {
162-
[int]$ExampleIndex = 1;
163-
Add-Content -Path $PluginDescriptionFile -Value '';
164-
Add-Content -Path $PluginDescriptionFile -Value '## Examples';
165-
Add-Content -Path $PluginDescriptionFile -Value '';
166-
167-
foreach ($example in $PluginHelp.examples.example) {
168-
[string]$ExampleDescription = $example.remarks.Text;
169-
if ([string]::IsNullOrEmpty($ExampleDescription) -eq $FALSE) {
170-
$ExampleDescription = $ExampleDescription.Replace("`r`n", '');
171-
$ExampleDescription = $ExampleDescription.Replace("`r", '');
172-
$ExampleDescription = $ExampleDescription.Replace("`n", '');
173-
$ExampleDescription = $ExampleDescription.Replace(' ', '');
174-
}
175-
176-
Add-Content -Path $PluginDescriptionFile -Value ([string]::Format('### Example Command {0}', $ExampleIndex));
177-
Add-Content -Path $PluginDescriptionFile -Value '';
178-
Add-Content -Path $PluginDescriptionFile -Value '```powershell';
179-
Add-Content -Path $PluginDescriptionFile -Value $example.code;
180-
Add-Content -Path $PluginDescriptionFile -Value '```';
181-
Add-Content -Path $PluginDescriptionFile -Value '';
182-
Add-Content -Path $PluginDescriptionFile -Value ([string]::Format('### Example Output {0}', $ExampleIndex));
183-
Add-Content -Path $PluginDescriptionFile -Value '';
184-
Add-Content -Path $PluginDescriptionFile -Value '```powershell';
185-
Add-Content -Path $PluginDescriptionFile -Value $ExampleDescription;
186-
Add-Content -Path $PluginDescriptionFile -Value '```';
187-
Add-Content -Path $PluginDescriptionFile -Value '';
188-
189-
$ExampleIndex += 1;
190-
}
191-
192-
$Content = Get-Content -Path $PluginDescriptionFile;
193-
Set-Content -Path $PluginDescriptionFile -Value '';
194-
for ($entry = 0; $entry -lt ($Content.Count - 1); $entry++) {
195-
Add-Content -Path $PluginDescriptionFile -Value $Content[$entry];
196-
}
197-
}
198-
}
199-
}

0 commit comments

Comments
 (0)