Results 1 to 8 of 8
Hello all,
I am wondering if anyone uses a script to test services to be sure they are up after say updating and rebooting a server?
For instance, if I ...
- 05-14-2008 #1
Test script... anyone else do this??
Hello all,
I am wondering if anyone uses a script to test services to be sure they are up after say updating and rebooting a server?
For instance, if I install patches and updates and reboot the system, when I am completed I would like to run one script and have it check if services are up and running (ie: httpd, iptables, sshd, and so on)
Is this something someone does?
- 05-14-2008 #2
I'm sure there are people out there who do something like this. Just to check if they are running would be simple; diagnosing their health could be a little more challenging.
Would something like this be enough?
Code:#!/bin/sh HTTPD=`ps -ef | grep httpd | grep -vc grep` SSHD=`ps -ef | grep sshd | grep -vc grep` IPTABLES=`ps -ef | grep iptables | grep -vc grep` echo "$HTTPD instances of httpd appear to be running." echo "$SSHD instances of sshd appear to be running." echo "$IPTABLES instances of iptables appear to be running."
- 05-14-2008 #3
I think that is exactly what I am looking for, I will name it, ailias it, and run it post reboot, or when ever I want to verify they are up.
Thanks for the quick response.
- 05-17-2008 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Use can use curl to check that the http server is delivering pages.
- 05-17-2008 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
As Thrillhouse already scripted, you need to take a pragmatic approach (which means that you need to check if the processes are running). That's because the OS tools will always report that the service is running if you started it, even if it segfaulted or died because of any problem.
EDITED: You can always use the OR operator || to launch the service if grep doesn't report it as running. For example:
That will run a command if grep doesn't give an output (which means that the process is not running.Code:ps -A | grep whatever || <launch whatever>
- 05-20-2008 #6
That's a nice touch too, thanks.
These tips will be very helpful.
- 05-20-2008 #7Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
- 05-20-2008 #8
Yeah, it's especially helpful for scripting as it prevents a lot of false positives. Humans can easily dismiss the grep.


Reply With Quote
