Hello.

My manager asked me to create a daily / weekly / monthly checkup routine for a linux server (Centos 4). Some kind of a "to do" list, making sure all of the relevant services are working properly: hardware, software, network services, quota... I'm a linux newbie, and am not aware of all the components that are relevant to this kind of checkup.

Can you help me?

Thank you.
__________________________

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous's picture

You could use Perl's

On November 10th, 2009 Anonymous (not verified) says:

You could use Perl's Proc::ProcessTable module.

Personally I'd create a text file with the services I was checking for, seperated by a colon like:

apache2:sshd:mysqld

Then I'd read that into the script and match it to the running processes using Proc::ProcessTable.

http://search.cpan.org/~durist/Proc-ProcessTable-0.45/Process/Process.pm should be able to get you started. Here's an ugly code that I threw together. It'll get the job done but there's much better ways to do it:

#!/usr/bin/perl
use strict;
use warnings;
use Proc::ProcessTable;
use Data::Dumper;

my $table = new Proc::ProcessTable( 'cache_ttys' => 1);
my @processes;

open(PROC, 'proc.check');
        while () {
                chomp;
                @processes = split(/:/);
        }
close(PROC);

foreach my $process (@{$table->table}) {
        foreach my $monitor ($process->{cmndline}) {
                foreach my $check (@processes) {
                        if ($monitor =~ m/$check/i) {
                                print "$check found running\n";
                        }
                        else {
                                next;
                        }
                }
        }
}

Output will be:

~$ perl check.pl
sshd found running
mysqld found running
mysqld found running
mysqld found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
apache2 found running
sshd found running
sshd found running
apache2 found running
apache2 found running
Anonymous's picture

It removed my <PROC> from

On November 10th, 2009 Anonymous (not verified) says:

It removed my <PROC> from the while loop.

while (<PROC>) {
chomp;
@processes = split(/:/);
}
squantrill's picture

I guess its just a case of

On June 3rd, 2008 squantrill says:

I guess its just a case of checking services are running I wrote a check script for a tru64 system once but seem to have lost it but its really write down all the services you think should be running then check them

i.e
ps -ef | grep http
telnet localhost 80

this is a basic check for a running apache server but there is much more you can do of course.. Really is such a wide requirements question you need to be a bit more specific in your question!

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.


Read this issue