Skip to content

Commit 7b1436d

Browse files
authored
Merge pull request #468 from Icinga:feature/adds_pid_to_show_icinga
Feature: Adds PID to Show-Icinga Adds pid information to Show-Icinga and improves Icinga for Windows certificate output.
2 parents 8e41a2d + 87d4072 commit 7b1436d

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

lib/core/repository/Show-Icinga.psm1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function Show-Icinga()
3737
$JEAContext = Get-IcingaJEAContext;
3838
$JEASessionFile = Get-IcingaJEASessionFile;
3939
$IcingaForWindowsCert = Get-IcingaForWindowsCertificate;
40+
$ServicePid = Get-IcingaForWindowsServicePid;
41+
$JEAServicePid = Get-IcingaJEAServicePid;
4042

4143
if ([string]::IsNullOrEmpty($DefinedServiceUser)) {
4244
$DefinedServiceUser = '';
@@ -47,8 +49,11 @@ function Show-Icinga()
4749
if ([string]::IsNullOrEmpty($JEASessionFile)) {
4850
$JEASessionFile = '';
4951
}
50-
if ($null -eq $IcingaForWindowsCert -Or [string]::IsNullOrEmpty($IcingaForWindowsCert)) {
51-
$IcingaForWindowsCert = 'Not installed';
52+
if ([string]::IsNullOrEmpty($ServicePid)) {
53+
$ServicePid = '';
54+
}
55+
if ([string]::IsNullOrEmpty($JEAServicePid)) {
56+
$JEAServicePid = '';
5257
}
5358

5459
$Output += '';
@@ -57,6 +62,8 @@ function Show-Icinga()
5762
$Output += ([string]::Format('PowerShell Root => {0}', (Get-IcingaForWindowsRootPath)));
5863
$Output += ([string]::Format('Icinga for Windows Service Path => {0}', $IcingaForWindowsService.Directory));
5964
$Output += ([string]::Format('Icinga for Windows Service User => {0}', $IcingaForWindowsService.User));
65+
$Output += ([string]::Format('Icinga for Windows Service Pid => {0}', $ServicePid));
66+
$Output += ([string]::Format('Icinga for Windows JEA Pid => {0}', $JEAServicePid));
6067
$Output += ([string]::Format('Icinga Agent Path => {0}', $IcingaAgentService.RootDir));
6168
$Output += ([string]::Format('Icinga Agent User => {0}', $IcingaAgentService.User));
6269
$Output += ([string]::Format('Defined Default User => {0}', $DefinedServiceUser));
@@ -69,9 +76,15 @@ function Show-Icinga()
6976
$Output += ([string]::Format('Api Check Forwarder => {0}', (Get-IcingaFrameworkApiChecks)));
7077
$Output += ([string]::Format('Debug Mode => {0}', (Get-IcingaFrameworkDebugMode)));
7178
$Output += '';
72-
$Output += 'Icinga for Windows Certificate';
79+
$Output += 'Icinga for Windows Certificate:';
7380
$Output += '';
74-
$Output += $IcingaForWindowsCert;
81+
if ($null -eq $IcingaForWindowsCert -Or [string]::IsNullOrEmpty($IcingaForWindowsCert)) {
82+
$Output += 'Not installed';
83+
} else {
84+
$Output += ([string]::Format('Issuer => {0}', ($IcingaForWindowsCert.Issuer)));
85+
$Output += ([string]::Format('Subject => {0}', ($IcingaForWindowsCert.Subject)));
86+
}
87+
7588
$Output += '';
7689

7790
$Output += (Show-IcingaRegisteredBackgroundDaemons);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function Get-IcingaForWindowsServicePid()
2+
{
3+
[string]$PidFile = (Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'service.pid');
4+
[string]$IfWPid = Read-IcingaFileSecure -File $PidFile;
5+
6+
if ([string]::IsNullOrEmpty($IfWPid) -eq $FALSE) {
7+
$IfWPid = $IfWPid.Replace("`r`n", '').Replace("`n", '').Replace(' ', '');
8+
}
9+
10+
return $IfWPid;
11+
}

0 commit comments

Comments
 (0)