Today, another small one.
At times, you will have a certain process, service or software package that during faulty periods takes take up a lot of memory.
To counter this, we can have a script take automatic remedial actions.
The script below will retrieve memory usage of a process and depending on that, we can set actions to respond to these results.
In this example, I have a process called XXXXXX.
It retrieves the memory usage and compares it to a set limit, in this case 300 Mb (300000000 bytes).
It then allows for the setting/scripting of actions depending on whether it is below or above the limit.
Here I have set it to restart a service when it is above the limit.
This script can be used in combination with monitoring software or the task scheduler to be set to run with intervals. This can avoid servers from getting stuck on 100% memory for days.
Hopefully this will end up making monitoring processes a bit less demanding.
Categories: Powershell, Script, Performance, Processes
Patrick Berger AKA Powershellder.
[ i ] Parallax section below. Click on the section below to upload image. Don't worry if it looks weird in the Weebly editor. It'll look normal on your published site.
To edit or delete your image, press the "toggle" button below. Then, hover over your image until a popup appears with the "edit" and "delete" options. If you don't want a white content section, leave it blank. It will disappear on your live website.