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!

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix