Start Blogaria Bored bsgen cconf Cookies Dialwhatever dnspb fch HammerServer jpeginfo kalk Lectures Microproxy msc Nasapics Off The Grid PGPkey Posters SafeEdit Simple listserv syscheck Wallpapers
A little movie
An animation can't be properly rendered. You have probably a too old version of Flash player. |
syscheckHow do I get syscheck?For downloads, use the following links:What's syscheck?I often find myself hopping from server to server, to see whether jobs have crashed, to check that daemons are running, what not. Being lazy as I am, I'm always trying to make such systems "self-healing" in the sense that possible errors should be auto-detected and fixed. Yes, I admit - being called at night for support is something I avoid like the plague. There are many tools to accomplish this task, from tiny to fullblown - e.g., cfengine is a truly great one. But in many situations I'll log onto a server where such tooling isn't available, and I find myself needing something small, portable, quick to set up, and just fit for the job. In such cases I tend to use syscheck:
How to use syscheck?
What's in the configuration?Syscheck mainly does the following for you:
ExamplesThe usage of the commands is best illustrated by examples. Below is a configuration that checks whether httpd is present in the process list. If not, apachectl start is executed. This of course checks that Apache is up and running.# Get the process list (output of ps ax) populate pslist ps ax # Check that httpd is in that list, if not run apachectl start expect pslist httpd correct apachect startOnce a list is available, then the same list can be re-used. Next expect/corect combo's can re-use the list pslist. Also, lists can be constructed from any output; be creative. The following example probes whether Apache is running by (a) examining the process list and searching for httpd, (b) fetching the output of http://localhost/ and searching for the string <html>. # Get the process list populate pslist ps ax # Get http://localhost/ populate httpoutput curl http://localhost/ # Match httpd in the processes and <html> in the http output expect pslist httpd expect httpoutput <html> # If one or both are not found, correct the situation. Kill off # any misbehaving Apache processes first. correct killall -9 httpd; sleep 1; apachectl startBelow is an example of eval. Imagine a hypothetical program mydaemon which won't run unless the environment variable MYHOME is set. Assuming that restarts of mydaemon would not work without that variable, then you'd have basically two options: (a) set MYHOME before calling syscheck, or (b) use eval in the configuration. These options are equivalent. Below is an example of using eval in the configuration file:
# Get the process list
populate pslist ps ax
# Set MYHOME
eval $ENV{MYHOME} = '/opt/mydaemon/etc';
# Scan for 'mydaemon' in the process list, if not found, start it
expect pslist mydaemon
correct /opt/mydaemon/bin/mydaemon
|