Sumanth.Artham

Monitoring PI Notification Service

Discussion created by Sumanth.Artham on Nov 8, 2019

Hi Team,

 

As part of support project, we have implemented PI Notification to monitor the critical parameters in PI Server. We have also decided to monitor the Notification service using PowerShell scripts. We have developed a script to trigger the email when the Notification service goes down. We are able to achieve it when we run the script manually but when we try to perform the same using task scheduler we are unable to.

 

Below is the script to monitor the Notification Service:

 

$Computer="10.40.20.125"
$Srv="PINotificationsService"
$from="EMAIL ID"
$smtp= "smtp.office365.com"
$Username = "EMAIL ID"
$password = Get-Content F:\Testing\pwd.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PSCredential $Username, $password
$emailbody = @”
Hi Team,

PI Notification Service is not running in PAPWOSIPI-AFSP Server.

Note:This is an autogenerated email, do not reply to this.

 

“@
$Service= Get-Service -ComputerName $Computer -Name $Srv
if($Service.Status -ne "Running")
{
write-host "PI Notification Service is not running"

$mailparam= @{

To="EMAIL ID"
CC="EMAIL ID"
From="$from"
Subject = "PI Notification Service is not running"
Body = $emailbody
SmtpServer = "$smtp"
Port = 587
Credential = $cred

}
Start-sleep -Seconds 1
Send-MailMessage @mailparam -UseSsl
write-host "Mail sent successful"
exit
}

 

Below are the screen shots from Task Scheduler:

 

We are running the task with Admin account and the task should run once in every  minutes to check the notification service status.

We could see that the task is running once in every minutes but it is not triggering the emails. 

 

 

Kindly help us if any one has any idea to make it work from Task scheduler. Also let us know if there is any way to monitor the Notification service other than powershell script.

 

Thanks & Regards,

Sumanth Artham

Outcomes