Checkup Routine for Linux Server

 in

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.

You could use Perl's

Anonymous's picture

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

It removed my <PROC> from

Anonymous's picture

It removed my <PROC> from the while loop.

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

I guess its just a case of

squantrill's picture

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!

Vriendelijke groeten, Simon Quantrill
t. +31630038096
a. Walcherselaan 5, Marknesse 8316NK, The Netherlands.
e. simon.quantrill@q-techservices.com
w. http://www.q-techservices.com
Managed IT Services Provider, registered company in the Netherlands:

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Webcast
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up and watch now

Sponsored by Skybot