Tuesday 23 December 2014

Shell script that will allow live monitoring of Apache Server

This the script that will enable live monitoring of Apache Server Ex. Who is currently logged on to it.

It will be look like the following screen shot .



Note: This script will work for Ubuntu (All  versions) and Debian(All Version ) only. There is another script for Redhat , Centos and Fedora.


Writer: Anuj Borah
Email: anujborah1@gmail.com



#!/bin/bash
clear
Writer: Anuj Borah
Email: anujborah1@gmail.com
sleep 3
echo "This the script for apache server monitoring.(Press F5 to refress)"
sleep 3
if [ $UID -eq 0 ]
then
dpkg -l apache2 && echo "Congrats ,Apache is installed" || echo "Apache is not installed type (apt-get install apache2) to linstall apache"
sleep 3
a2enmod status > /dev/null
clear
echo "Give the ip address to which u want to associate for apache server monitoring " ; read p

echo "<IfModule mod_status.c>
    # Allow server status reports generated by mod_status,
    # with the URL of http://servername/server-status
    # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.

    <Location /server-status>
        SetHandler server-status
        Require local
        Allow from 127.0.0.1 ::1 $p
        #Require ip 192.0.2.0/24
    </Location>

    # Keep track of extended status information for each request
    ExtendedStatus On

    # Determine if mod_status displays the first 63 characters of a request or
    # the last 63, assuming the request itself is greater than 63 chars.
    # Default: Off
    #SeeRequestTail On


    <IfModule mod_proxy.c>
        # Show Proxy LoadBalancer status in mod_status
        ProxyStatus On
    </IfModule>


</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet" > /etc/apache2/mods-enabled/status.conf

service apache2 restart > /dev/null

clear
echo "All Done. Now i will enable the system.(Press F5 to refress) "
sleep 3
firefox http://127.0.0.1:server-status

else
echo "&&&&&&This Script will run as root only ,  login as root and try $0  again. &&&&&&"
fi

No comments:

Post a Comment

Popular Posts