#!/usr/bin/perl -W use strict; use Config::IniFiles; delete @ENV{qw(IFS PATH CDPATH ENV BASH_ENV)}; my $cfg = new Config::IniFiles( -file => "default.ini" ); &processcheck if $cfg->val('PROCESS','ENABLED'); &displayresults; exit; sub processcheck { my @ptable = `/usr/bin/ps -ef`; my @alert = $cfg->val('PROCESS','ALERT'); my @message = $cfg->val('PROCESS','MESSAGE'); my @process = $cfg->val('PROCESS','PROCESS'); for ( my $i = 0; $i <= $#alert; $i++ ) { unless(grep /$process[$i]/ , @ptable) { $alerts{"$alert[$i]"} .= "\n$message[$i]"; } } } sub displayresults { print "REPORT TAKEN AT " . localtime(time) . "\n"; for my $alerttype ( sort keys %alerts ) { print "\n\U$alerttype\E ALERTS"; print "$alerts{$alerttype}\n"; } } #default.ini [PROCESS] ENABLED = 1 PROCESS = ldapd -p 389 PROCESS = sendmail: accepting PROCESS = /xntpd PROCESS = apache/bin/httpd MESSAGE = LDAP is not running MESSAGE = Sendmail daemon is not accepting connections MESSAGE = NTP daemon is not running MESSAGE = Apache web server is not running ALERT = medium ALERT = major ALERT = minor ALERT = minor