New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Restart service automatically if service is using >%90 cpu

Votes:

0

Your Vote:

Up

Down

We have PRTG Probe Server and most of time CPU usage hits to more than %90 thanks to that service. Is there any way restart to service automatically when CPU usage hit to %90?

automatically prtg restart

Created on Jun 17, 2019 1:10:31 PM by  Erol Ulug (0) 2



3 Replies

Votes:

0

Your Vote:

Up

Down

Hello Erol,

  1. Use the probe's existing Probe Health sensor
  2. Set a limit in channel that monitor's probe service's cpu load so that the sensor goes to error when surpassing 90%.
  3. For restarting the service you can use "ServiceRestart" executable from here with an Execute Program Notification.

(Of course you could as well use a script of your own as well for restarting the service.)

Kind regards,

Erhard

Created on Jun 18, 2019 8:48:44 AM by  Erhard Mikulik [Paessler Support]

Last change on Jun 18, 2019 12:19:29 PM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hello Erhard,

Thank you for your suggestion. I want to use script if it is possible. I wrote simple PowerShell script but it is not working. I am using JobTrigger not sure is it true or not. Just want to restart automatically. Do you have advice? Also, how can I use "ServiceRestart" Should I just start to exe, can you give little bit more information? Thank you, Here is my source code :

   $peridiocallyChecks = {

   # Check if logging source is available, if not add it

   if (!(Get-EventLog -Source "CPU supervision" -LogNameApplication)){

       New-EventLog -LogName Application -Source "CPU supervision"
   }

   $cpuUsage = [double] (Get-Counter '\Processor(_Total)\% Processor Time' -ErrorAction SilentlyContinue | Select-Object 

   -ExpandProperty CounterSamples | Select-Object -ExpandProperty CookedValue)

   if ($cpuUsage -gt 80) {

       Write-EventLog -LogName "Application" -Source "CPU supervision" -EntryType Information -EventId 1 -Message 
       
       "CPU usage is $cpuUsage. Going to stop service"
       
       Stop-Service "PRTG Probe Service"
       
       # Some cooldown time for the service to shutdown
       
       Start-Sleep -Seconds 10
       
       Start-Service "PRTG Probe Service"
       
       Write-EventLog -LogName "Application" -Source "CPU supervision" -EntryType Information -EventId 1 -Message 
   
      "Restarted service"
      
       }
   
      Get-EventLog -Source "CPU supervision" -LogName Application
   
      }

    # Trigger every hour
   
    $trigger = New-JobTrigger -Once -At "17/05/2019 0am" -RepetitionInterval (New-TimeSpan -Hour 12) - 
   
    RepetitionDuration ([TimeSpan]::MaxValue)

   Register-ScheduledJob -Name "CPUCheck" -Trigger $trigger -Scriptblock $peridiocallyCheck

Created on Jun 18, 2019 12:11:09 PM by  Erol Ulug (0) 2

Last change on Jun 18, 2019 1:28:13 PM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Erol,

Ok, so the script actually does everything, checking the load and then trying to do the restart. I would recommend to simply use the existing "Probe Health" sensor as it already checks for the probe service's cpu consumption and reduce the script only to the portion that restarts the service. Does the code portion for restarting the service work by itself when running it manually? If not, maybe some coding forum is better suited for helping you out or you use the aforementioned executable alternatively.

Kind regards,

Erhard

Created on Jun 19, 2019 11:36:55 AM by  Erhard Mikulik [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.