#!/bin/sh
clear; 
echo -e "SERVER SOFTWARE"; 
cat /etc/redhat-release | awk '{print "\tOS: " $1, $3, $4}'; 
cat /usr/local/cpanel/version | awk '{print "\tcPanel: " $1}';
httpd -v 2> /dev/null | awk 'NR > 1 { exit }; 1  {print "\tApache version: " $3}'; 
rpm -q ea-cpanel-tools > /dev/null && echo -e "\tEasyApache: EA4" || echo -e "\tEasyApache: EA3";
php -v | awk 'NR > 1 { exit }; 1 {print "\tPHP Version: " $2}'; 
mysql -V | awk '{print "\tMYSQL Version: " $5}' | sed 's/,//'; 
handler=`/usr/local/cpanel/bin/rebuild_phpconf --current | awk 'NR==4 {print $3}'`; 
if [ "$handler" = "suphp" ]; 
	then echo -e "\tPHP Handler: $handler\tSafe to run fixperms"; 
else echo -e "\tPHP Handler: $handler\t\033[0;31mDO NOT RUN FIXPERMS\033[0m"; 
fi; echo; 
ls /etc/nginx 2>/dev/null | grep nginx.conf >/dev/null;
if [ $? -eq 0 ];
then echo -e "\033[0;31m\tTHIS SERVER USES NGINX\033[0m";
	echo;
fi;
ls /etc/sysconfig | grep varnish >/dev/null;
if [ $? -eq 0 ];
then echo -e "\033[0;31m\tTHIS SERVER USES VARNISH\033[0m";
	echo;
fi;
ls /usr/bin | grep redis >/dev/null;
if [ $? -eq 0 ];
then echo -e "\033[0;31m\tTHIS SERVER USES REDIS\033[0m";
	echo;
fi;
	echo "Nameservers"; 
	ns=`cat /etc/wwwacct.conf | grep NS2 | awk '{print $2}'`; 
	if [ "$ns" = "ns2.inmotionhosting.com" ]; 
		then echo -e "\tNo custom nameservers"; 
	else echo -e "\t\033[0;31mCustom nameservers are setup\033[0m"; 
		cat /etc/wwwacct.conf | grep -B1 NS2 | 
		awk '{print "\t" $2}';
	fi; 
	echo; echo -e "Memory"; 
	free -mh | awk 'NR==2 {print "\tTotal Memory: " $2, "\n\tMemory Used: " $3, "\n\tMemory Free: " $4 "\n\tMemory Cached: " $7}'; 
		echo; 
		echo -e "Hard Drive"; 
		df -h | awk 'NR==2 {print "\tSize: "$2 "\n\tUsed: " $3 "\n\tAvail: " $4}'; 
		echo; 
		echo -e "Resellers"; 
		grep -o '^[a-z][a-z0-9]\{0,7\}' /var/cpanel/resellers; 
		echo; 
		echo -e "Users"; 
		nmbrofusers=`ls /var/cpanel/users | wc -l`; 
		if [ "$nmbrofusers" -le 50 ]; 
			then sudo cat /etc/trueuserdomains | 
		awk 'BEGIN { print ORS=" "}; {print FNR ") " $2}'; 
		echo; 
	else echo -e "test"; 
	fi; 
	echo; 
	echo -e "Hostname:"; 
		hostname; echo -e "PTR:"; 
		dig -x `hostname -i` +short; 
		echo; 
		echo "Services: ";
		ps cax | grep mysqld > /dev/null; 
		if [ $? -eq 0 ]; 
		then echo -e "\tmysql is running"; 
	else echo -e "\033[0;31m\tmysql is not running\033[0m"; 
	fi; 
			ps cax | grep httpd > /dev/null; 
        if [ $? -eq 0 ]; 
            then echo -e "\thttpd is running"; 
        else echo -e "\033[0;31m\thttpd is not running\033[0m"; 
        fi;
			ps cax | grep exim > /dev/null; 
				if [ $? -eq 0 ]; 
					then echo -e "\texim is running"; 
				else echo -e "\033[0;31m\texim is not running\033[0m"; 
				fi; 
				ps cax | grep named > /dev/null; 
					if [ $? -eq 0 ]; 
						then echo -e "\tnamed is running"; 
					else echo -e "\033[0;31m\tnamed is not running(Are they root?)\033[0m"; 
					fi; 
						ps cax | grep pure-ftpd > /dev/null; 
						if [ $? -eq 0 ]; then echo -e "\tftpd is running"; 
						else echo -e "\033[0;31m\tftpd is not running\033[0m"; 
					fi; 
					ps cax | grep dovecot > /dev/null; 
					if [ $? -eq 0 ]; then echo -e "\tdovecot is running"; 
					else echo -e "\033[0;31m\tdovecot is not running\033[0m"; 
				fi;
ls /etc/nginx 2>/dev/null | grep nginx.conf >/dev/null;
if [ $? -eq 0 ];
then
ps cax | grep nginx > /dev/null
        if  [[ $? -eq 0 ]]
            then echo -e "\tnginx is running"
        else echo -e "\033[0;31m\tnginx is not running\033[0m";
        fi;	
fi;
ls /etc/sysconfig | grep varnish >/dev/null;
if [ $? -eq 0 ];
then
ps cax | grep varnish > /dev/null
        if  [[ $? -eq 0 ]]
            then echo -e "\tvarnish is running"
        else echo -e "\033[0;31m\tvarnish is not running\033[0m";
        fi;	
fi;
ls /usr/bin | grep redis >/dev/null;
if [ $? -eq 0 ];
then
ps cax | grep redis > /dev/null
        if  [[ $? -eq 0 ]]
            then echo -e "\tredis is running"
        else echo -e "\033[0;31m\tredis is not running\033[0m";
        fi;	
fi;
				echo; 
				echo -e "IP USAGE:"; 
				/scripts/ipusage | grep -E --color "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | awk '{ print "\033[31m\t"$1"  \033[0m";}'
				echo;
					if [ -s /etc/mailips ];
					then mailip=$(grep "*:" /etc/mailips |awk '{print $2}');
					else mailip=$(hostname -i);
				fi;
				echo -e "Mail IP:\033[00;33m $mailip\033[0m";
