File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ function Find-IcingaAgentObjects ()
2+ {
3+ param (
4+ $Find = @ (),
5+ $OutFile = $null
6+ );
7+
8+ if ($Find.Length -eq 0 ) {
9+ throw ' Please specify content you want to look for' ;
10+ }
11+
12+ [array ]$ObjectList = (Get-IcingaAgentObjectList ).Split(" `r`n " );
13+ [int ]$lineIndex = 0 ;
14+ [array ]$Result = @ ();
15+
16+ foreach ($line in $ObjectList ) {
17+ if ([string ]::IsNullOrEmpty($line )) {
18+ continue ;
19+ }
20+
21+ foreach ($entry in $Find ) {
22+ if ($line -like $entry ) {
23+ [string ]$ResultLine = [string ]::Format(
24+ ' Line #{0} => "{1}"' ,
25+ $lineIndex ,
26+ $line
27+ );
28+ $Result += $ResultLine ;
29+ }
30+ }
31+
32+ $lineIndex += 1 ;
33+ }
34+
35+ if ([string ]::IsNullOrEmpty($OutFile )) {
36+ Write-Output $Result ;
37+ } else {
38+ Set-Content - Path $OutFile - Value $Result ;
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ function Get-IcingaAgentObjectList ()
2+ {
3+ $Binary = Get-IcingaAgentBinary ;
4+ $ObjectList = Start-IcingaProcess - Executable $Binary - Arguments ' object list' ;
5+
6+ return $ObjectList.Message ;
7+ }
Original file line number Diff line number Diff line change 1+ function Write-IcingaAgentObjectList ()
2+ {
3+ param (
4+ [string ]$Path
5+ );
6+
7+ if ([string ]::IsNullOrEmpty($Path )) {
8+ throw ' Please specify a path to write the Icinga objects to' ;
9+ }
10+
11+ $ObjectList = Get-IcingaAgentObjectList ;
12+
13+ Set-Content - Path $Path - Value $ObjectList ;
14+ }
You can’t perform that action at this time.
0 commit comments