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!

Webcast
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers

Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions