hiltpoll.blogg.se

Linux process monitor
Linux process monitor






linux process monitor

You'll also find that this script doesn't significantly impact performance on your system. It also doesn't require any budget discussions, nor does it require a maintenance window for agent installation. Yes, it's primitive and simple, but it works and it's free. This script is an example of a quick method for setting up a process monitor and alert on a local system. The entry I've made below runs the script every five minutes: */5 * * * * /root/apache.sh Once you've tested your script and satisfied that it operates as desired, place this script into the root user's crontab: $ sudo crontab -e No one wants to receive emails or notices that a service is up every five minutes. If the file exists, then no action is taken. This script checks for the non-existence of the httpd.pid file and then takes action if it's not found. You could just as easily send an SMS message to a team on-call mobile phone. Mail -s 'Apache is down' <<< 'Apache is down on SERVER1 and cannot be restarted' If the Apache service is still down and cannot be restarted after 30 seconds, then the script sends the system administrator team an email: #!/bin/bash

linux process monitor

I repeated this process two more times, waiting for 10 seconds between checks. I decided that rather than have an alert sent if the Apache web server was down, I would have the script attempt a service restart, and then check again. I identified the PID file with the variable, FILE. There are many different ways to create such a script, but this is how I did it, and it works. Note: If you don't have Apache installed, it doesn't matter, because you can replace the httpd.pid file pointed to in the script with any other PID file that works for your system. Be sure to change permissions on the file to 750 ( rwxr -x-) so that no other user can execute or even read this file, regardless of location: $ sudo chmod 750 apache.sh I named this script apache.sh, and placed it into root's home directory.

linux process monitor

In this example, the Apache web server ( httpd) has a PID file: /run/httpd/httpd.pid. Most processes have a process ID (PID) file under the /run directory when they are running, and many of those have their own separate directories that contain their corresponding PID files. This article takes you through the process of creating a script that checks every five minutes for the Apache web server process, attempts to restart it if it's down, and then alerts you via email if it's down for more than 30 seconds and cannot be restarted. How well do you know Linux? Take a quiz and get a badge.Linux system administration skills assessment.A guide to installing applications on Linux.

#LINUX PROCESS MONITOR DOWNLOAD#

Download RHEL 9 at no charge through the Red Hat Developer program.








Linux process monitor