#Alex Simpson
#Script to check the status of the Postgres DB
#function to check service status and restart
function FuncCheckService
{
$ServiceName = 'pgsql-9.2'
$arrService = Get-Service -Name $ServiceName
if ($arrService.Status -eq 'Running')
{
Write-Output "$ServiceName service is running"
}
else
{
Write-Output "$ServiceName service is not running"
}
}
#start transscript to log details
Start-Transcript -Path "C:\Documents\CheckPostgresService.log" -Append -IncludeInvocationHeader
#Call function with EM service as a parameter
FuncCheckService pgsql-9.2
#stop logging
Stop-Transcript
This works fine and does what I need it to do.
I want to be able to in a shell script call the PowerShell script to execute or rewrite this script within a shell script to check whether the windows service is running but not 100% sure if this is possible.
We have a internal monitoring tool which is UNIX/LINUX based and to retrieve metrics results it needs to be used within the UNIX/LINUX system.
As the service is a windows service I have wrote a powershell script to check whether the service is running. However I am not sure how to get this working on the UNIX/LINUX system