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!

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState