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.
This commit is contained in:
Lord Hepipud 2022-02-07 15:30:36 +01:00 committed by GitHub
commit 7b1436dbef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -37,6 +37,8 @@ function Show-Icinga()
$JEAContext = Get-IcingaJEAContext; $JEAContext = Get-IcingaJEAContext;
$JEASessionFile = Get-IcingaJEASessionFile; $JEASessionFile = Get-IcingaJEASessionFile;
$IcingaForWindowsCert = Get-IcingaForWindowsCertificate; $IcingaForWindowsCert = Get-IcingaForWindowsCertificate;
$ServicePid = Get-IcingaForWindowsServicePid;
$JEAServicePid = Get-IcingaJEAServicePid;
if ([string]::IsNullOrEmpty($DefinedServiceUser)) { if ([string]::IsNullOrEmpty($DefinedServiceUser)) {
$DefinedServiceUser = ''; $DefinedServiceUser = '';
@ -47,8 +49,11 @@ function Show-Icinga()
if ([string]::IsNullOrEmpty($JEASessionFile)) { if ([string]::IsNullOrEmpty($JEASessionFile)) {
$JEASessionFile = ''; $JEASessionFile = '';
} }
if ($null -eq $IcingaForWindowsCert -Or [string]::IsNullOrEmpty($IcingaForWindowsCert)) { if ([string]::IsNullOrEmpty($ServicePid)) {
$IcingaForWindowsCert = 'Not installed'; $ServicePid = '';
}
if ([string]::IsNullOrEmpty($JEAServicePid)) {
$JEAServicePid = '';
} }
$Output += ''; $Output += '';
@ -57,6 +62,8 @@ function Show-Icinga()
$Output += ([string]::Format('PowerShell Root => {0}', (Get-IcingaForWindowsRootPath))); $Output += ([string]::Format('PowerShell Root => {0}', (Get-IcingaForWindowsRootPath)));
$Output += ([string]::Format('Icinga for Windows Service Path => {0}', $IcingaForWindowsService.Directory)); $Output += ([string]::Format('Icinga for Windows Service Path => {0}', $IcingaForWindowsService.Directory));
$Output += ([string]::Format('Icinga for Windows Service User => {0}', $IcingaForWindowsService.User)); $Output += ([string]::Format('Icinga for Windows Service User => {0}', $IcingaForWindowsService.User));
$Output += ([string]::Format('Icinga for Windows Service Pid => {0}', $ServicePid));
$Output += ([string]::Format('Icinga for Windows JEA Pid => {0}', $JEAServicePid));
$Output += ([string]::Format('Icinga Agent Path => {0}', $IcingaAgentService.RootDir)); $Output += ([string]::Format('Icinga Agent Path => {0}', $IcingaAgentService.RootDir));
$Output += ([string]::Format('Icinga Agent User => {0}', $IcingaAgentService.User)); $Output += ([string]::Format('Icinga Agent User => {0}', $IcingaAgentService.User));
$Output += ([string]::Format('Defined Default User => {0}', $DefinedServiceUser)); $Output += ([string]::Format('Defined Default User => {0}', $DefinedServiceUser));
@ -69,9 +76,15 @@ function Show-Icinga()
$Output += ([string]::Format('Api Check Forwarder => {0}', (Get-IcingaFrameworkApiChecks))); $Output += ([string]::Format('Api Check Forwarder => {0}', (Get-IcingaFrameworkApiChecks)));
$Output += ([string]::Format('Debug Mode => {0}', (Get-IcingaFrameworkDebugMode))); $Output += ([string]::Format('Debug Mode => {0}', (Get-IcingaFrameworkDebugMode)));
$Output += ''; $Output += '';
$Output += 'Icinga for Windows Certificate'; $Output += 'Icinga for Windows Certificate:';
$Output += ''; $Output += '';
$Output += $IcingaForWindowsCert; if ($null -eq $IcingaForWindowsCert -Or [string]::IsNullOrEmpty($IcingaForWindowsCert)) {
$Output += 'Not installed';
} else {
$Output += ([string]::Format('Issuer => {0}', ($IcingaForWindowsCert.Issuer)));
$Output += ([string]::Format('Subject => {0}', ($IcingaForWindowsCert.Subject)));
}
$Output += ''; $Output += '';
$Output += (Show-IcingaRegisteredBackgroundDaemons); $Output += (Show-IcingaRegisteredBackgroundDaemons);

View file

@ -0,0 +1,11 @@
function Get-IcingaForWindowsServicePid()
{
[string]$PidFile = (Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'service.pid');
[string]$IfWPid = Read-IcingaFileSecure -File $PidFile;
if ([string]::IsNullOrEmpty($IfWPid) -eq $FALSE) {
$IfWPid = $IfWPid.Replace("`r`n", '').Replace("`n", '').Replace(' ', '');
}
return $IfWPid;
}