sensu-plugins / sensu-plugins-windows

Sensu Windows Plugins
http://sensu-plugins.io
MIT License
22 stars 46 forks source link

powershell.exe Terminated #42

Closed stevebanik-ndsc closed 7 years ago

stevebanik-ndsc commented 7 years ago

Resource Monitor is showing Terminated powershell.exe processes each time Sensu runs the check. Is there a way to close powershell.exe more gracefully? I'm also curious if CPU usage can be decreased with these checks, as they tend to spike each time powershell.exe is invoked.

majormoses commented 7 years ago

might be related? https://github.com/sensu-plugins/sensu-plugins-windows/pull/39 can you validate if you are using poweshell 2?

simonsteur commented 7 years ago

Also regarding the cpu spikes. how does your command look to initiate the powershell check? It's best to start powershell with the following flags to reduce the cpu usage: Powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -NoLogo

stevebanik-ndsc commented 7 years ago

@majormoses PSVersion = 4.0

stevebanik-ndsc commented 7 years ago

@simonsteur I've included Powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -NoLogo in the .json file.

simonsteur commented 7 years ago

@stevebanik-ndsc Sorry for my confusion but do you mean you already had that included or that you added it now. Incase of the second, do you see any difference?

Also to pick up on that powershell is listed as terminated in resource monitor. That is expected behavior and has nothing to do with a graceful exit of an application. The resource monitor shows terminated processes for a short while, their cpu usage, etc. This is the case for all applications, regardless of how they exit.

Since your sensu checks will run every x amount of time, powershell.exe will probably have a permanent place among the terminated processes. This is nothing to be concerned about and completely normal.

majormoses commented 7 years ago

It sounds like this is intended behavior, is there anything to actually be done here? Maybe something in the readme would help?

stevebanik-ndsc commented 7 years ago

@simonsteur I already had that included. What you've described regarding "terminated" in Resource Monitor makes sense. Thanks for that info.

majormoses commented 7 years ago

closing this out then, please feel free to message back if you feel this should remain open.