Application Perf Mgmt (BAC / BSM) Practitioners Forum
cancel

How to invoke restartSiteScope() method API

Respected Contributor.. Charles L.
Respected Contributor..

How to invoke restartSiteScope() method API

In our effort to maintain Sitescope, we want to perform Sitescope restart automatically when certain error conditions are met, using Sitescope own's alerting function.

Currently, I have the following batch file which would in turn running powershell scripts.

powershell.exe -noprofile -executionpolicy bypass -InputFormat None -file E:\SiteScope\scripts\RestartSiSServiceStop.ps1

ping 127.0.0.1 -n 60 >NUL 2>&1 || ping ::1 -n 60 >NUL 2>&1

powershell.exe -noprofile -executionpolicy bypass -InputFormat None -file E:\SiteScope\scripts\RestartSiSServiceStart.ps1

RestartSiSServiceStop.ps1

try{
$ServiceName = "HP SiteScope"
Write-Host "Stopping $ServiceName Service ..."
Stop-Service $ServiceName -Verbose -Force
}
catch {
Write-Error $_.Exception.ToString()
Read-Host -Prompt "The above error occurred. Press Enter to exit."
}

RestartSiSServiceStart.ps1

try{
$ServiceName = "HP SiteScope"
$ServiceDetails = Get-Service $ServiceName
Write-Host "Starting $ServiceName service ..."
Start-Service $ServiceName
}
catch {
Write-Error $_.Exception.ToString()
Read-Host -Prompt "The above error occurred. Press Enter to exit."
}

It works most of the time. However, it would fail when Sitescope  takes too long to restart., because Sitescope would kill application, resulting in stopping child processes as well, and hence killed the script alert required to restart the Sitescope.

service: Thu Sep 28 18:34:06 2017 In ServiceStop
service: Thu Sep 28 18:34:06 2017 Stopping service, requested by user
service: Thu Sep 28 18:34:06 2017 cleaning up service
service: Thu Sep 28 18:34:06 2017 Shutdown request process successful
Thu Sep 28 18:34:25 2017 stopping 40632
Thu Sep 28 18:35:14 2017 stopping 26724
service: Thu Sep 28 18:36:06 2017 Service failed to wait for application shutdown, killing application
service: Thu Sep 28 18:36:06 2017 Stopping monitoring process: 26720, result: 1
service: Thu Sep 28 18:36:06 2017 Stopping child processes: 26720
Thu Sep 28 18:36:07 2017 stopping perfex 39828
Thu Sep 28 18:36:07 2017 stopping perfex 33524
Thu Sep 28 18:36:07 2017 stopping perfex 12724
Thu Sep 28 18:36:07 2017 stopping perfex 40756
Thu Sep 28 18:36:07 2017 stopping perfex 30088
Thu Sep 28 18:36:07 2017 stopping perfex 28900
Thu Sep 28 18:36:07 2017 stopping perfex 54020
Thu Sep 28 18:36:07 2017 stopping perfex_dispatcher 40772
Thu Sep 28 18:36:07 2017 stopping perfex 21356
Thu Sep 28 18:36:07 2017 stopping perfex 40848
Thu Sep 28 18:36:07 2017 stopping perfex 69392
Thu Sep 28 18:36:07 2017 stopping perfex 28020
Thu Sep 28 18:36:07 2017 stopping perfex 65068
Thu Sep 28 18:36:07 2017 stopping perfex 37216
Thu Sep 28 18:36:07 2017 stopping perfex 15564
Thu Sep 28 18:36:07 2017 stopping cmd 38280
Thu Sep 28 18:36:07 2017 stopping cmd 50156
Thu Sep 28 18:36:07 2017 stopping powershell 6920

Is there any way for us to invoke the restartSiteScope() method API as a way to restart Sitescope service properly?

Best Regards,

Charles L.

 

7 REPLIES
Siggi Gladitsch
Micro Focus Expert

Re: How to invoke restartSiteScope() method API

Hi Charles L.,

there is in fact an API call "restartSiteScope()", but this is part of an internal API and cannot be called from an external program,
as you could do it with the calls from the published APIs (<SiteScope>\examples\integration\api\*)

If my understanding of your issue is correct, then sometimes the powershell script you use to restart SiteScope is stopped / killed,
this can also be seen in the log file snippet:
..
Thu Sep 28 18:36:07 2017 stopping powershell 6920
..

If this is the issue, then check out:

KM01217709 - SiteScope 11.24 - Running stop-service cmdlet on HP SiteScope service kills powershell

1. Stop the SiteScope service.
2. Go to the following location C:\SiteScope\groups.
3. Add the following line on the master.config file: _doNotkillProcesses=powershell.exe.
4. Save the change on the master.config file.
5. Restart the SiteScope service.

Greetings
Siggi

Customer Support
Micro Focus

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
Respected Contributor.. Charles L.
Respected Contributor..

Re: How to invoke restartSiteScope() method API

Hi Siggi,

Thank you for the suggestion. Unfortunately, the powershell script was still killed despite the additional parameter in master.config.

service: Sun Oct 08 18:59:42 2017 Service failed to wait for application  shutdown, killing application
service: Sun Oct 08 18:59:42 2017 Stopping monitoring process: 5556, result: 1
service: Sun Oct 08 18:59:42 2017 Stopping child processes: 5556
Sun Oct 08 18:59:42 2017 stopping perfex 5872

Sun Oct 08 18:59:42 2017 stopping perfex 7752

Sun Oct 08 18:59:43 2017 stopping perfex 8608

Sun Oct 08 18:59:43 2017 stopping perfex 4228

Sun Oct 08 18:59:43 2017 stopping perfex 6604

Sun Oct 08 18:59:43 2017 stopping perfex 5812

Sun Oct 08 18:59:43 2017 stopping perfex 8580

Sun Oct 08 18:59:43 2017 stopping perfex 4376

Sun Oct 08 18:59:43 2017 stopping perfex 9032

Sun Oct 08 18:59:43 2017 stopping perfex_dispatcher 8992

Sun Oct 08 18:59:43 2017 stopping perfex 7516

Sun Oct 08 18:59:43 2017 stopping perfex 7376

Sun Oct 08 18:59:43 2017 stopping cmd 8120

Sun Oct 08 18:59:43 2017 stopping cmd 7256

Sun Oct 08 18:59:43 2017 stopping powershell 7672

Sun Oct 08 18:59:43 2017 stopping sslget 5780

Sun Oct 08 18:59:43 2017 stopping sslget 3268

Sun Oct 08 18:59:43 2017 stopping sslget 5584

Sun Oct 08 18:59:43 2017 stopping sslget 5896

Sun Oct 08 18:59:43 2017 stopping sslget 8356

Sun Oct 08 18:59:43 2017 stopping sslget 8216

The _doNotkillProcesses=powershell.exe is added into the <SiteScope>\groups\master.config.doNotkillProcesses.jpg

Best Regards,

Charles L 

 

 

Siggi Gladitsch
Micro Focus Expert

Re: How to invoke restartSiteScope() method API

Hi Charles,

thanks for the update.

I tried to locate the code where we output the message
 service: date/time Service failed to wait for application shutdown, killing application
to find out how long SiteScope would wait (looks like 2 minutes), and whether or not this time can be modified,
but it's part of the SiteScope service code, and for whatever reason I was unable to find anything useful.

I guess your only chance is to trigger a script or a program which detaches itself from SiteScope,
so that SiteScope cannot stop it.

BTW, what SiteScope version do you use?
The behaviour to kill powershell.exe when the SiteScope service stops has only been introdcued with 11.24.

Greetings
Siggi

 

Customer Support
Micro Focus

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
Respected Contributor.. Charles L.
Respected Contributor..

Re: How to invoke restartSiteScope() method API

Thanks Siggi for the insight. It is 11.32.

Currently, I am using this mechanism to self-reboot, whenever Sitescope seems to encounter any resource related issue, as it would send massive false alerts to users. An effort to make Sitescope look more reliable to my clients.

Cheers,

Charles Laudia

Siggi Gladitsch
Micro Focus Expert

Re: How to invoke restartSiteScope() method API

Hi Charles,

thanks for the update.

This
..
Currently, I am using this mechanism to self-reboot, whenever Sitescope seems to encounter any resource related issue, as it would send massive false alerts to users. An effort to make Sitescope look more reliable to my clients.
..
is a good idea, I know various customers doing the same, and in the past SiteScope restarted itself every night, but why doing this if not required.

As mentioned, the only other idea I have is instead of using scripts which run within SiteScope, trigger something outside of SiteScope,
which would require some further programming or scripting, so it's the question swhether it's worth.

Another option would be to have an external program running under a service,
which checks whether the SiteScope service is running, and if not, start it after a certain period of time.
You would need to signal it when you trigger the SiS restart via your current implementation, so that it doesn't kick in too early, or you can also only stop the service with your mechanism, and leave it the otehr program to start it again.

You also might wanna check out Service Hawk (http://www.servicehawk.com/) and/or Service Keeper (https://www.activeplus.com/products/servicekeeper)

Greetings
SIggi

Customer Support
Micro Focus

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
Respected Contributor.. Charles L.
Respected Contributor..

Re: How to invoke restartSiteScope() method API

Just to share, that I changed the powershell script to restart, instead of stop-start. With this, even though Sitescope killed the cmd.exe and powershell.exe, the service restart could go on.

RestartSiteScopeService.ps1

try{
    $ServiceName = "HP SiteScope"
    $ServiceDetails = Get-Service $ServiceName
    Write-Host "Restarting $ServiceName service ..."
    Restart-Service -displayname $ServiceName
}
catch {
    Write-Error $_.Exception.ToString()
    Read-Host -Prompt "The above error occurred. Press Enter to exit."
}

Here is the result, from error.log.

Mon Nov 20 20:02:37 2017    stopping perfex 16308
Mon Nov 20 20:02:37 2017    stopping perfex 24068
Mon Nov 20 20:02:37 2017    stopping perfex_dispatcher 11884
Mon Nov 20 20:02:37 2017    stopping cmd 5048
Mon Nov 20 20:02:37 2017    stopping cmd 17572
Mon Nov 20 20:02:37 2017    stopping powershell 21444
service: Mon Nov 20 20:02:39 2017    Starting monitoring process: 8284, result: 1
2017-11-20 20:03:17,454 [SiteScope Main Thread] (SiteScopeHeartbeatManager.java:53) INFO  - The Heartbeat Scheduler was started.
2017-11-20 20:03:17,532 [SiteScope Main Thread] (ServiceController.java:82) INFO  - Registering service: Host DNS Resolution Service
2017-11-20 20:03:17,610 [SiteScope Main Thread] (ServiceController.java:82) INFO  - Registering service: Monitor History Event Sink Service
2017-11-20 20:03:17,626 [SiteScope Main Thread] (ServiceController.java:82) INFO  - Registering service: Alert Action Execution Counter Registry Service
2017-11-20 20:03:17,626 [SiteScope Main Thread] (ServiceController.java:82) INFO  - Registering service: Alert Open Status Registry Service
2017-11-20 20:03:17,719 [SiteScope Main Thread] (SiteScopeSupport.java:693) INFO  - ---------------------------------------------
2017-11-20 20:03:17,719 [SiteScope Main Thread] (SiteScopeSupport.java:694) INFO  - Starting SiteScope...

...

2017-11-20 20:07:14,160 [SiteScope Main] (SiteScopeGroup.java:527) INFO  - SiteScope Start monitors completed
2017-11-20 20:07:14,191 [SiteScope Main] (SiteScopeGroup.java:541) INFO  - SiteScope Startup Completed
2017-11-20 20:07:14,222 [SiteScope Main] (SiteScopeSupport.java:729) INFO  - SiteScope 11.32.371  build 233 process started at Mon Nov 20 20:07:14 PST 2017
2017-11-20 20:07:14,222 [SiteScope Main] (SiteScopeSupport.java:730) INFO  - SiteScope Start took 236 sec

As seen above, despite the alert script was killed (highlighted in red above), but Sitescope service could be restarted successfully.

Highlighted
Siggi Gladitsch
Micro Focus Expert

Re: How to invoke restartSiteScope() method API

Hi Charles,

thanks for the update and the good news.
Great that you got it working!

Greetings
Siggi

Customer Support
Micro Focus

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.