Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions check_httpd_limits.pl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'CONFIG' => '',
'MPM' => '',
'VERSION' => '',
'CTL' => '',
);
my $cf_IfModule = '';
my $cf_MaxName = ''; # defined based on httpd version (MaxClients or MaxRequestWorkers)
Expand Down Expand Up @@ -197,6 +198,12 @@
'/usr/lib/apache2/mpm-prefork/apache2',
'/usr/lib/apache2/mpm-worker/apache2',
);
my @apache2ctl_paths = (
'/usr/sbin/apache2ctl',
'/usr/local/sbin/apache2ctl',
'/usr/lib/apache2/mpm-prefork/apache2ctl',
'/usr/lib/apache2/mpm-worker/apache2ctl',
);
my $dbname = '/var/tmp/check_httpd_limits.sqlite';
my $dbuser = '';
my $dbpass = '';
Expand All @@ -216,6 +223,7 @@
'debug',
'verbose',
'exe=s',
'ctl=s',
'config=s',
'swappct=i',
'save',
Expand Down Expand Up @@ -360,6 +368,30 @@
die "ERROR: No executable Apache HTTP binary found!\n"
unless ( defined $httpd{'EXE'} && -x $httpd{'EXE'} );

# ----------------------------
# LOCATE THE APACHE2CTL BINARY
# ----------------------------
#
if ( defined $opt{'ctl'} ) {
$httpd{'CTL'} = $opt{'ctl'};
print "DEBUG: Command-Line Ctl \"$httpd{'CTL'}\".\n"
if ( $opt{'debug'} );
} else {
for ( @apache2ctl_paths ) {
if ( $_ && -x $_ ) {
$httpd{'CTL'} = $_;
print "DEBUG: Found Httpd Ctl \"$httpd{'CTL'}\".\n"
if ( $opt{'debug'} );
last;
}
}
}
if ( not ( defined $httpd{'CTL'} && -x $httpd{'CTL'} ) ) {
print "ERROR: No executable Apache HTTP config binary found! Setting $httpd{'EXE'}\n";
$httpd{'CTL'} = $httpd{'EXE'};
}


# -----------------------------------------
# READ PROCESS INFORMATION FOR HTTPD BINARY
# -----------------------------------------
Expand Down Expand Up @@ -403,8 +435,8 @@
# READ THE HTTPD BINARY COMPILED VALUES
# -------------------------------------
#
print "DEBUG: Open $httpd{'EXE'} -V\n" if ( $opt{'debug'} );
open ( my $set_fh, "-|", "$httpd{'EXE'} -V" ) or die "ERROR: $httpd{'EXE'} - $!\n";
print "DEBUG: Open $httpd{'CTL'} -V\n" if ( $opt{'debug'} );
open ( my $set_fh, "-|", "$httpd{'CTL'} -V" ) or die "ERROR: $httpd{'CTL'} - $!\n";
while ( <$set_fh> ) {
$httpd{'ROOT'} = $1 if (/^.*HTTPD_ROOT="(.*)"$/);
$httpd{'CONFIG'} = $1 if (/^.*SERVER_CONFIG_FILE="(.*)"$/);
Expand Down