Linux script to monitor CPU or Mem % for an individual process
Here's a simple bash script I conjured up that will find a pid, and print out either the CPU or Memory % utilization from the ps command. Keep in mind that I am in the very early stages of learning bash scripting and there probably are better ways to accomplish what I'm looking for. I'm hoping that by posting this script here, people will be able to improve it and give it back to the APM community here as a resource they can use in their own installations.
Please please please, help us all out on this! This is a "functional" first step, but it can be improved! If you know of a better way, please note it here, or upload a better script.
To use this in a template you need to do the following:
1. Upload the script to the target server.
2. Configure a new template using a Linux/Unix Script Monitor.
3. Configure credentials that will have access and execute permissions to the location where you uploaded the script.
4. For the command line, enter the name of the script. i.e -- ./processcpu.sh
5. For the Script Working Directory, enter the location of the script. i.e. -- /home/user
6. For the Script body you can put anything -- you can't leave it blank, but it doesn't matter what you enter there.
7. Configure your response time thresholds according to your environment, and configure statistics thresholds according to %'s.