Initial import

This commit is contained in:
Christoph 2017-02-21 02:20:36 +01:00
commit 9472a46bea
7 changed files with 3653 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/BAK/*

52
add_custom_log_to_vhost.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
vhost_config_dir=/usr/local/apache2/conf/vhosts
_temp_dir=`mktemp -d`
cp -a $vhost_config_dir ${vhost_config_dir}-`date +%Y%m%d-%H%M`
files=`find $vhost_config_dir -maxdepth 1 -mindepth 1 -type f -print`
_tmp_file=`mktemp`
echo false > $_tmp_file
find "$vhost_config_dir" -maxdepth 1 -mindepth 1 -type f -print | while read _file ; do
echo "$_file"
[[ "`basename $_file`" = "0000-logformat.conf" ]] && continue;
[[ "`basename $_file`" = "000-default.conf" ]] && continue;
new_file="$_temp_dir/`basename $_file`"
while IFS='' read -r line || [[ -n $line ]]; do
if [[ "$line" =~ "<VirtualHost" ]] ;then
if [[ "$line" =~ "]:" ]]; then
log_entry="CustomLog /var/log/apache2/ipv6_requests.log base_requests"
else
log_entry="CustomLog /var/log/apache2/ipv4_requests.log base_requests"
fi
echo "true" > $_tmp_file
fi
if [[ "$line" =~ "$log_entry" ]]; then
echo "false" > $_tmp_file
fi
if [[ "$line" =~ "</VirtualHost" ]]; then
if `cat $_tmp_file | head -n 1` ; then
#echo "" >> $new_file
## - with tabstop
#echo -e " $log_entry" >> $new_file
## - with blank signs
echo -e " $log_entry" >> $new_file
echo "" >> $new_file
fi
echo false > $_tmp_file
fi
echo "$line" >> $new_file
done < $_file
done
find $_temp_dir -maxdepth 1 -mindepth 1 -type f -print -exec cp -f {} $vhost_config_dir/ \; > /dev/null 2>&1
rm -f $_tmp_file
rm -rf $_temp_dir
exit

355
add_https_to_vhosts.sh Executable file
View File

@ -0,0 +1,355 @@
#!/usr/bin/env bash
_date=`date +%Y-%m-%d-%H%M`
vhost_dir=/usr/local/apache2/conf/vhosts
target_dir=$vhost_dir
#target_dir=/root/tmp
ipv4=83.223.86.82
ipv6="2a01:30:0:13:26f:6dff:feb9:9d11"
_cert_default=/usr/local/apache2/conf/server-bundle.crt
_key_default=/usr/local/apache2/conf/server.key
file_suffixes="conf mod_php php-fpm mod_fcgid mod_php redirect"
## --- Some functions
## ---
## - Check if a given array (parameter 2) contains a given string (parameter 1)
## -
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo -e -n "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
fatal(){
echo ""
echo -e "fataler Fehler: $*"
echo ""
echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m"
echo ""
exit 1
}
error(){
echo ""
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
echo ""
}
warn (){
echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
}
info (){
echo ""
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
}
echo_done() {
echo -e "\033[75G[ \033[32mdone\033[m ]"
}
echo_ok() {
echo -e "\033[75G[ \033[32mok\033[m ]"
}
echo_warning() {
echo -e "\033[75G[ \033[33m\033[1mwarn\033[m ]"
}
echo_failed(){
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
}
echo_skipped() {
echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]"
}
echo ""
if [[ "$vhost_dir" = "$target_dir" ]]; then
cp -a $vhost_dir ${vhost_dir}.$_date
vhost_dir=${vhost_dir}.$_date
fi
declare -a vhost_arr_tmp
while IFS='' read -r -d '' _file ; do
[[ -h "$_file" ]] && continue
vhost_arr_tmp+=("$_file")
done < <(find $vhost_dir -mindepth 1 -maxdepth 1 -type f -print0)
# - Sort array
# -
IFS=$'\n' vhost_arr=($(sort <<<"${vhost_arr_tmp[*]}"))
unset IFS
declare -a file_suffixe_arr
for _suffix in $file_suffixes ; do
file_suffixe_arr+=("$_suffix")
done
declare -i number=0
declare -a file_already_ok_arr
declare -a file_not_converted_arr
declare -a file_ipv4_ok_arr
declare -a file_ipv6_ok_arr
for _file in ${vhost_arr[@]} ; do
# - For testing
# -
#if [[ $number -gt 3 ]]; then
# break
#fi
echononl " Working on $(basename $_file) .."
if [[ "$(basename $_file)" =~ ^00 ]] ; then
echo_skipped
info "File $(basename $_file) left unchanged"
file_not_converted_arr+=("$_file")
continue
fi
_found=false
for _suffix in ${file_suffixe_arr[@]} ; do
if [[ "$_suffix" = "${_file##*.}" ]]; then
_found=true
break
fi
done
if ! $_found ; then
echo_failed
error "File $(basename $_file) was not edited. Wrong suffix \"${_file##*.}\""
file_not_converted_arr+=("$_file")
continue
fi
_basename_file=$(basename $_file)
https_ipv4=false
https_ipv6=false
if grep -i -E "^\s*<VirtualHost\s+[0-9.]+:443" $_file> /dev/null 2>&1 ; then
https_ipv4=true
fi
if grep -i -E "^\s*<VirtualHost\s+\[[a-f0-9:]+\]:443>" $_file> /dev/null 2>&1 ; then
https_ipv6=true
fi
if $https_ipv4 && $https_ipv6 ; then
file_already_ok_arr+=("$_file")
echo_skipped
info "File $(basename $_file) already converted.."
continue
fi
if $https_ipv4 ; then
file_ipv4_ok_arr+=("$_file")
fi
if $https_ipv6 ; then
file_ipv6_ok_arr+=("$_file")
fi
> $target_dir/${_basename_file}.80
> $target_dir/${_basename_file}.443
> $target_dir/${_basename_file}
server_name_found=false
server_name=
vhost_ipv4_80=false
found_custom_log=false
ssl_cert_found=false
ssl_key_found=false
ssl_cert=$_cert_default
ssl_key=$_key_default
server_aliases_arr=()
while IFS='' read -r _line || [[ -n $_line ]] ; do
if echo "$_line" | grep -i -E "^\s*</VirtualHost>" > /dev/null 2>&1 ; then
vhost_ipv4_80=false
fi
if ! $ssl_cert_found && echo "$_line" | grep -E "^\s*SSLCertificateFile\s+" > /dev/null 2>&1 ; then
ssl_cert_found=true
ssl_cert=$(echo $_line | awk '{print$2}')
fi
if ! $ssl_key_found && echo "$_line" | grep -E "^\s*SSLCertificateKeyFile\s+" > /dev/null 2>&1 ; then
ssl_key_found=true
ssl_key=$(echo $_line | awk '{print$2}')
fi
if echo $_line | grep -e "^\s*ServerAlias" > /dev/null 2>&1 ; then
server_alias_tmp=$(echo $_line | sed -e "s/ServerAlias//" | sed "s/^\s*//" | sed "s/\s*$//")
if [[ ${#server_aliases_arr[@]} -eq 0 ]] ; then
for _alias in $server_alias_tmp ; do
server_aliases_arr+=("$_alias")
done
else
for _alias in $server_alias_tmp ; do
containsElement "$_alias" "${server_aliases_arr[@]}" && continue
server_aliases_arr+=("$_alias")
done
fi
fi
if $vhost_ipv4_80 ; then
if echo "$_line" | grep -i -E "^\s*CustomLog\s+" > /dev/null 2>&1 && ! $found_custom_log ; then
echo " SSLEngine on" >> $target_dir/${_basename_file}.443
echo "" >> $target_dir/${_basename_file}.443
echo " SSLCertificateFile $ssl_cert" >> $target_dir/${_basename_file}.443
echo " SSLCertificateKeyFile $ssl_key" >> $target_dir/${_basename_file}.443
echo "" >> $target_dir/${_basename_file}.443
found_custom_log=true
fi
echo "$_line" >> $target_dir/${_basename_file}.80
echo "$_line" >> $target_dir/${_basename_file}.443
fi
if echo "$_line" | grep -i -E "^\s*<VirtualHost\s+$ipv4:80" > /dev/null 2>&1 ; then
vhost_ipv4_80=true
fi
if ! $server_name_found && echo "$_line" | grep -E "^\s*ServerName\s+" > /dev/null 2>&1 ; then
server_name_found=true
server_name=$(echo $_line | awk '{print$2}')
fi
done < "$_file"
if [[ -z "$(cat $target_dir/${_basename_file}.80)" ]] ; then
echo_failed
error "File $(basename $_file) was not edited. Maybe no Configuration (for IPv4) found!"
file_not_converted_arr+=("$_file")
continue
fi
let number++
if [[ "$ssl_cert" != "$_cert_default" ]]; then
perl -i -n -p -e "s#^(\s*)SSLCertificateFile\s+.*#\1SSLCertificateFile $ssl_cert#" \
$target_dir/${_basename_file}.443
fi
if [[ "$ssl_key" != "$_key_default" ]]; then
perl -i -n -p -e "s#^(\s*)SSLCertificateKeyFile\s+.*#\1SSLCertificateKeyFile $ssl_key#" \
$target_dir/${_basename_file}.443
fi
# - Delete empty lines at the beginning
# -
while [[ "$(head -n 1 $target_dir/${_basename_file}.80)" =~ ^\s*$ ]] ; do
sed -i '1d' $target_dir/${_basename_file}.80
done
while [[ "$(head -n 1 $target_dir/${_basename_file}.443)" =~ ^\s*$ ]] ; do
sed -i '1d' $target_dir/${_basename_file}.443
done
# - Delete empty lines at the end
# -
while [[ "$(tail -n 1 $target_dir/${_basename_file}.80)" =~ ^\s*$ ]] ; do
sed -i '$ d' $target_dir/${_basename_file}.80
done
while [[ "$(tail -n 1 $target_dir/${_basename_file}.443)" =~ ^\s*$ ]] ; do
sed -i '$ d' $target_dir/${_basename_file}.443
done
echo "# --- $server_name" > $target_dir/${_basename_file}
for _alias in "${server_aliases_arr[@]}" ; do
echo "# --- $_alias" >> $target_dir/${_basename_file}
done
echo "" >> $target_dir/$(basename $_file)
echo "<VirtualHost $ipv4:80>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
cat $target_dir/${_basename_file}.80 >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "</VirtualHost>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "<VirtualHost $ipv4:443>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
cat $target_dir/${_basename_file}.443 >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "</VirtualHost>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
perl -i -n -p -e "s#^(\s*)CustomLog\s+/var/log/apache2/ipv4_requests.log\s+.*#\1CustomLog /var/log/apache2/ipv6_requests.log base_requests#" $target_dir/${_basename_file}.443
perl -i -n -p -e "s#^(\s*)CustomLog\s+/var/log/apache2/ipv4_requests.log\s+.*#\1CustomLog /var/log/apache2/ipv6_requests.log base_requests#" $target_dir/${_basename_file}.80
echo "# ---" >> $target_dir/${_basename_file}
echo "# --- IPv6" >> $target_dir/${_basename_file}
echo "# ---" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "<VirtualHost [$ipv6]:80>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
cat $target_dir/${_basename_file}.80 >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "</VirtualHost>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "<VirtualHost [$ipv6]:443>" >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
cat $target_dir/${_basename_file}.443 >> $target_dir/${_basename_file}
echo "" >> $target_dir/${_basename_file}
echo "</VirtualHost>" >> $target_dir/${_basename_file}
rm $target_dir/${_basename_file}.80
rm $target_dir/${_basename_file}.443
echo_done
done
echo
if [[ ${#file_already_ok_arr[@]} -gt 0 ]] ; then
echo ""
echo -e "\033[32m\033[1mFiles left unchanged\033[m:"
for _file in ${file_already_ok_arr[@]} ; do
echo " $(basename $_file)"
done
fi
echo ""
if [[ ${#file_ipv4_ok_arr[@]} -gt 0 ]]; then
echo ""
echo -e "\033[33m\033[1mIPv6 support was added on files\033[m:"
for _file in ${file_ipv4_ok_arr[@]} ; do
echo " $(basename $_file)"
done
fi
#if [[ ${#file_ipv6_ok_arr[@]} -gt 0 ]]; then
# echo ""
# echo -e "\033[37m\033[1mOriginally, no IPv4 support.\n\033[31m\033[1mFiles not converted:\033[m"
# for _file in ${file_ipv6_ok_arr[@]} ; do
# echo " $(basename $_file)"
# done
#fi
if [[ ${#file_not_converted_arr[@]} -gt 0 ]]; then
echo ""
echo -e "\033[31m\033[1mFiles ot converted\033[m:"
for _file in ${file_not_converted_arr[@]}; do
echo " $(basename $_file)"
done
fi
echo ""
exit 0

8
apache_memory_usage.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
echo ""
ps -ylC httpd
echo ""
ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'
echo ""

49
convert_vhosts_2.4.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
#APACHE_CONF_DIR=/usr/local/httpd-2.4.2/conf
APACHE_CONF_DIR="/usr/local/httpd-2.4.9_php-5.3.28/conf"
VHOST_DIR=${APACHE_CONF_DIR}/vhosts
#_conf_files=`find $VHOST_DIR -type f -name *.conf`
_conf_files=`find $VHOST_DIR -type f`
for file in $_conf_files ; do
[ -d "$file" ] && continue
[ -h "$file" ] && continue
echo "convert \"`basename $file`\".."
## -
## - Order deny,allow
## - Deny from all --> Require all denied
## -
## - Order allow,deny
## - Allow from all --> Require all granted
## -
## -
sed -i.bak -r -e "s/^(\s*NameVirtualHost.*)$/#\1/g" $file
sed -i -r -e "s/^(\s*)(Order\s+[aA]llow\s*,\s*[dD]eny)$/\1#\2/g" $file
sed -i -r -e "s/^(\s*)([aA]llow\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all granted/g" $file
sed -i -r -e "s/^(\s*)([dD]eny\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all denied/g" $file
sed -i -r -e "s/^(\s*)([dD]eny\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all denied/g" $file
## - Order Deny,Allow
## - Deny from all
## - Allow from 127.0.0.1 192.168.63.40 --> Require ip 127.0.0.1 192.168.63.40
## -
sed -i -r -e "s/^(\s*)([aA]llow\s+from)\s+([0-2][0-9]{0,2}\..*)$/\1#\2 \3\n\1Require ip \3/g" $file
## - Order Deny,Allow
## - Deny from all
## - Allow from example.org --> Require host example.org
## -
sed -i -r -e "s/^(\s*)([aA]llow\s+from)\s+(.*)$/\1#\2 \3\n\1Require host \3/g" $file
done
exit 0

2887
create_vhost_php.sh Executable file

File diff suppressed because it is too large Load Diff

301
max_memory_limit_apache.sh Executable file
View File

@ -0,0 +1,301 @@
#!/usr/bin/env bash
ps_output_tmp_file=/tmp/ps.out.$$
declare -i http_client_rss_usage_kb=0
declare -i http_parent_rss_usage_kb=0
declare -i http_process_max_usage_kb=0
declare -i http_server_prozesses=0
## ---
apache_version=`httpd -v | grep "version" | awk '{print$3}' | cut -d'/' -f2`
apache_major_version=`echo $apache_version | awk -F \. '{ printf "%d", $1; printf "." ; printf "%d", $2 }'`
## ---
#uptime=`wget -q -O - http://127.0.0.1/server-status?auto | grep -i Uptime | awk '{print$2}'`
uptime=`lynx -dump http://127.0.0.1/server-status?auto | awk ' /Uptime/ {print$2}'`
_now=`date +%s`
_timestamp_start=`expr $_now - $uptime`
starttime=`date -d \@$_timestamp_start +%c`
days=`echo "scale=0 ; $uptime / 86400" | bc -l`
days_rest=`echo "scale=0 ; $uptime % 86400" | bc -l`
hours=`echo "scale=0 ; $days_rest / 3600" | bc -l`
hours_rest=`echo "scale=0 ; $days_rest % 3600" | bc -l`
minutes=`echo "scale=0 ; $hours_rest / 60" | bc -l`
seconds=`echo "scale=0 ; $hours_rest % 60" | bc -l`
uptime_string="$days days $hours hrs $minutes min $seconds sec"
## ---
scoreborad=`wget -q -O - http://127.0.0.1/server-status?auto | grep -i Scoreboard | awk '{print$2}'`
_scoreborad_in_use=`echo -n "$scoreborad" | sed -e 's/[\.]//g'`
_scoreboard_busy=`echo -n "$_scoreborad_in_use" | sed -e 's/[_]//g'`
_scoreboard_idle=`echo -n "$_scoreborad_in_use" | sed -e 's/[^_]//g'`
workers_in_use=`echo -n "$_scoreborad_in_use" | wc -m`
idle_workers=`echo -n "$_scoreboard_idle" | wc -m`
busy_workers=`echo -n "$_scoreboard_busy" | wc -m`
#max_simultanous_connections=`echo -n "$scoreborad" | wc -m`
## ---
mpm=`lynx -dump http://127.0.0.1/server-info?server | awk ' /MPM Name:/ {print tolower($3)}'`
server_root=`lynx -dump http://127.0.0.1/server-info?server | awk ' /Server Root:/ {print$3}'`
config_file=`lynx -dump http://127.0.0.1/server-info?server | awk ' /Config File:/ {print$3}'`
config_file_found=false
_default_2_2_prefork_server_limit=256
_default_2_2_prefork_max_clients=150
_default_2_2_prefork_max_requests_per_child=0
_default_2_2_worker_server_limit=16
_default_2_2_worker_max_clients=150
_default_2_2_worker_threads_per_child=25
_default_2_2_worker_max_requests_per_child=0
_default_2_4_prefork_server_limit=250
_default_2_4_prefork_max_request_workers=25
_default_2_4_prefork_max_connections_per_child=0
_default_2_4_event_server_limit=16
_default_2_4_event_threads_per_child=25
_default_2_4_event_max_request_workers=400
_default_2_4_event_max_connections_per_child=0
if grep -i -E "^\s*Include\s+conf/extra/httpd-mpm.conf" $config_file > /dev/null 2>&1 ; then
config_file_found=true
found=false
while read line ; do
if echo $line | grep -i "IfModule mpm_${mpm}_module" > /dev/null 2>&1 ; then
found=true
continue
fi
if $found ; then
if echo $line | grep -i "ServerLimit" > /dev/null 2>&1 ; then
server_limit=`echo $line | grep -i "ServerLimit" | awk '{print$2}'`
fi
if echo $line | grep -i "MaxClients" > /dev/null 2>&1 ; then
max_clients=`echo $line | grep -i "MaxClients" | awk '{print$2}'`
fi
if echo $line | grep -i "ThreadsPerChild" > /dev/null 2>&1 ; then
threads_per_child=`echo $line | grep -i "ThreadsPerChild" | awk '{print$2}'`
fi
if echo $line | grep -i "MaxRequestWorkers" > /dev/null 2>&1 ; then
max_request_workers=`echo $line | grep -i "MaxRequestWorkers" | awk '{print$2}'`
fi
if echo $line | grep -i "MaxConnectionsPerChild" > /dev/null 2>&1 ; then
max_connections_per_child=`echo $line | grep -i "MaxConnectionsPerChild" | awk '{print$2}'`
fi
if echo $line | grep -i "MaxRequestsPerChild" > /dev/null 2>&1 ; then
max_requests_per_child=`echo $line | grep -i "MaxRequestsPerChild" | awk '{print$2}'`
fi
if echo $line | grep -i "</IfModule" > /dev/null 2>&1 ; then
break;
fi
fi
done < ${server_root}/conf/extra/httpd-mpm.conf
fi
if [ "$apache_major_version" = "2.4" ]; then
if [ "$mpm" = "event" ];then
if [ -z "$server_limit" ]; then
server_limit=$_default_2_4_event_server_limit
fi
if [ -z "$threads_per_child" ]; then
threads_per_child=$_default_2_4_event_threads_per_child
fi
if [ -z "$max_request_workers" ]; then
max_request_workers=$_default_2_4_event_max_request_workers
fi
if [ -z "$max_connections_per_child" ]; then
max_connections_per_child=$_default_2_4_event_max_connections_per_child
fi
max_processes=$server_limit
max_simultanous_connections=`expr $server_limit \* $threads_per_child`
elif [ "$mpm" = "prefork" ];then
if [ -z "$server_limit" ]; then
server_limit=$_default_2_4_prefork_server_limit
fi
if [ -z "$max_request_workers" ]; then
max_request_workers=$_default_2_4_prefork_max_request_workers
fi
if [ -z "$max_connections_per_child" ]; then
max_connections_per_child=$_default_2_4_prefork_max_connections_per_child
fi
max_processes=$max_request_workers
max_simultanous_connections=$max_request_workers
max_simultanous_connections_msg="Based on \"Max Request Workers\" NOT \"Server Limit"
fi
elif [ "$apache_major_version" = "2.2" ]; then
if [ "$mpm" = "worker" ];then
if [ -z "$server_limit" ]; then
server_limit=$_default_2_2_worker_server_limit
fi
if [ -z "$threads_per_child" ]; then
threads_per_child=$_default_2_2_worker_threads_per_child
fi
if [ -z "$max_clients" ]; then
max_clients=$_default_2_2_worker_max_clients
fi
if [ -z "$max_requests_per_child" ]; then
max_requests_per_child=$_default_2_2_worker_max_requests_per_child
fi
max_processes=$max_clients
max_simultanous_connections=$max_clients
max_simultanous_connections_msg="Based on \"Max Clients\" NOT \"Server Limit"
elif [ "$mpm" = "prefork" ];then
if [ -z "$server_limit" ]; then
server_limit=$_default_2_2_prefork_server_limit
fi
if [ -z "$max_clients" ]; then
max_clients=$_default_2_2_prefork_max_clients
fi
if [ -z "$max_requests_per_child" ]; then
max_requests_per_child=$_default_2_2_prefork_max_requests_per_child
fi
max_processes=$max_clients
max_simultanous_connections=$max_clients
max_simultanous_connections_msg="Based on \"Max Clients\" NOT \"Server Limit"
fi
fi
## ---
ps --no-headers -ylC httpd | awk '{print$2" "$8}' > $ps_output_tmp_file
while read _UID _RSS ; do
if [ "$_UID" = "0" ]; then
http_parent_rss_usage_kb=$_RSS
else
http_client_rss_usage_kb=`expr $http_client_rss_usage_kb + $_RSS`
let http_server_prozesses++
if [ $_RSS -gt $http_process_max_usage_kb ]; then
http_process_max_usage_kb=$http_client_rss_usage_kb
fi
fi
done < $ps_output_tmp_file
cur_memory_usage_kb=`echo "scale=0; $http_parent_rss_usage_kb + $http_client_rss_usage_kb" | bc -l`
cur_memory_usage_mb=`echo "scale=3; $cur_memory_usage_kb/1024" | bc -l`
each_process_usage_kb=`echo "scale=3; $http_client_rss_usage_kb/$http_server_prozesses" | bc -l`
each_process_usage_mb=`echo "scale=3; $each_process_usage_kb/1024" | bc -l`
http_process_max_usage_mb=`echo "scale=3; $http_process_max_usage_kb/1024" | bc -l`
declare -i _tmp_val=0
max_memory_limit_avarage_mb=0
max_memory_limit_avarage_mb=`echo "scale=3; $each_process_usage_mb * $max_processes" | bc -l`
max_memory_limit_avarage_gb_str=""
_tmp_val=`echo "scale=0; $max_memory_limit_avarage_mb / 1" | bc -l`
if [ $_tmp_val -gt 1023 ]; then
max_memory_limit_avarage_gb=`echo "scale=3; $max_memory_limit_avarage_mb/1024" | bc -l`
max_memory_limit_avarage_gb_str=" ($max_memory_limit_avarage_gb GB)"
fi
max_memory_limit_max_mb=0
max_memory_limit_max_mb=`echo "scale=3; $http_process_max_usage_mb * $max_processes" | bc -l`
max_memory_limit_max_gb_str=""
_tmp_val=`echo "scale=0; $max_memory_limit_max_mb / 1" | bc -l`
if [ $_tmp_val -gt 1023 ]; then
max_memory_limit_max_gb=`echo "scale=3; $max_memory_limit_max_mb/1024" | bc -l`
max_memory_limit_max_gb_str=" ($max_memory_limit_max_gb GB)"
fi
## ---
echo ""
echo "----- Current Status"
echo ""
echo -e "\tApache Server Version.............: $apache_version"
#echo -e "\tApache Major Version..............: $apache_major_version"
echo ""
echo -e "\tStart Time........................: $starttime"
echo -e "\tUptime............................: $uptime_string"
echo
echo -e "\tMulti-Processing Module (MPM).....: $mpm "
if [ -n "$server_root" ];then
echo ""
echo -e "\tServer Rooot Directory............: $server_root"
fi
if [ -n "config_file" ]; then
echo -e "\tConfig File.......................: $config_file"
fi
echo ""
echo -e "\tNumber Apache (Client) Prozesses..: $http_server_prozesses"
echo ""
echo -e "\tCurrent Memory Usage..............: $cur_memory_usage_mb MB"
echo -e "\tEach Process Usage (Avarage)......: $each_process_usage_mb MB"
echo ""
echo -e "\tWorkers in Use....................: $workers_in_use"
echo -e "\tBusy Workers......................: $busy_workers"
echo -e "\tIdle Workers......................: $idle_workers"
echo ""
echo ""
if $config_file_found ; then
echo "----- MPM Configuration (read from included config file httpd-mpm.conf)"
else
echo "----- MPM Configuration (config file httpd-mpm.conf NOT included - assuming defaults)"
fi
echo ""
echo -e "\tMulti-Processing Module (MPM).....: $mpm "
echo ""
echo ""
echo -e "\tServer Limit (Processes)..........: $server_limit"
if [ -n "$max_clients" ]; then
echo -e "\tMax Clients.......................: $max_clients"
fi
if [ -n "$threads_per_child" ]; then
echo -e "\tThreads Per Child.................: $threads_per_child"
fi
if [ -n "$max_request_workers" ]; then
echo -e "\tMax Request Workers...............: $max_request_workers"
fi
if [ -n "$max_connections_per_child" ]; then
echo -e "\tMax Connections Per Child.........: $max_connections_per_child"
elif [ -n "$max_requests_per_child" ]; then
echo -e "\tMax Requests Per Child............: $max_requests_per_child"
fi
echo ""
echo -e "\tMax Simultanous Connectons........: $max_simultanous_connections"
if [ -n "$max_simultanous_connections_msg" ];then
echo -e "\t $max_simultanous_connections_msg"
fi
echo ""
echo ""
echo "----- Memory Limit (estimated values!!)"
echo ""
echo -e "\tMax Memory (based on avarage usage)..: $max_memory_limit_avarage_mb MB$max_memory_limit_avarage_gb_str"
echo ""
echo -e "\tMax Memory (bades on max usage)......: $max_memory_limit_max_mb MB$max_memory_limit_max_gb_str"
echo ""
echo ""
rm -f $ps_output_tmp_file
exit 0