#!/usr/bin/python

#Script can perform server health check....
#Modified Date 21/Aug/2015
######

import os
import subprocess
import time

print "\t################################################################"
print "\t#             LINUX SERVER HEALTH CHECK PROGRAM                #"
print "\t#                          EMAIL :                             #"
print "\t#                phyominhtun1990@gmail.com                     #"
print "\t#                                                              #"
print "\t#                                       Written by PhyoMinHtun #"
print "\t################################################################"
pass
time.sleep(1)
os.system("date")
print "\t#########################################################################"
print "\t# Help:                                                                 #"
print "\t# 0: Type input [0 or exit] for exit program:                           #"
print "\t# 1: Type input [1] for checking TCP ports:                             #"  
print "\t# 2: Type input [2] for last logins:                                    #" 
print "\t# 3: Type input [3] for check Disk,System Info: and memory usage:       #"
print "\t# 4: Type input [4] for utilization and most expensive processes:       #"  
print "\t# 5: Type input [5] for current socket connections:                     #" 
print "\t# 6: Type input [6] for check public IP address:                        #"
print "\t# 7: Type input [7] for Show who is logged on and what they are doing:  #"
print "\t#########################################################################"

def exit():
   exit

def nmap():
   print "checking TCP ports:"
   a=os.popen('nmap -p- -T4 127.0.0.1')
   scan=a.read()
   print scan
   print "======================================="

def lastlogin():
   print "Last logins:"
   b=os.popen('last -a |head -3')
   last=b.read()
   print last
   print "======================================="

def chk_info():
   print "Check Disk,System Info: and memory usage:"
   subprocess.call(["df","-h"])
   subprocess.call(["free","-m"])
   print ""
   print "System Information is: \n",subprocess.call(["uname","-a"])
   print "======================================="

def utilize_expensive_process():
   print "Utilization and most expensive processes:"
   c=os.popen('top -b |head -3')
   process=c.read()
   print process
   print "======================================="

def current_socket_con():
   print "Current connections:"
   d=os.popen('ss -s')
   socket=d.read()
   print socket
   os.system("netstat -nlpt")
   print "======================================="

def chk_pubip():
   print "Check Server Public IP:"
   e=os.popen('wget -qO- ifconfig.me/ip')
   ip=e.read()
   print ip
   print "======================================="

def chk_login():
   print "Show who is logged on and what they are doing:"
   os.system("w -s")

login=raw_input("Do you want to run this script?yes or no? ")
if(login=="yes") or (login=="YES"):
   input=raw_input("Enter your input: ")
   if(input=="0") or (input=="exit"):
      exit()
   if(input=="1"):
      nmap()
   if(input=="2"):
      lastlogin()
   if(input=="3"):
      chk_info()
   if(input=="4"):
      utilize_expensive_process()
   if(input=="5"):
      current_socket_con()
   if(input=="6"):
      chk_pubip()
   if(input=="7"):
      chk_login()
elif (login=="no") or (login=="NO"):
   print "Thank you for your using server health check script..."
else:
   print "Invalid Input Key!"

#DONE



@@ -1696,20 +1696,18 @@
 %0A   
-a=os.popen('
+chk_port=%22
 nmap
@@ -1728,41 +1728,32 @@
 .0.1
-')
+%22
 %0A   
-scan=a.read()%0A   print scan
+os.system(chk_port)
 %0A   
@@ -2903,16 +2903,32 @@
 w -s%22)%0A%0A
+%0Adef main():%0A   
 login=ra
@@ -2981,16 +2981,19 @@
  no? %22)%0A
+   
 if(login
@@ -3020,16 +3020,19 @@
 %22YES%22):%0A
+   
    input
@@ -3063,24 +3063,27 @@
 nput: %22)%0A   
+ 
+  
 if(input==%220
@@ -3115,15 +3115,21 @@
     
+   
 exit()%0A
+   
    i
@@ -3139,24 +3139,27 @@
 nput==%221%22):%0A
+   
       nmap()
@@ -3155,24 +3155,27 @@
      nmap()%0A
+   
    if(input=
@@ -3177,24 +3177,27 @@
 nput==%222%22):%0A
+   
       lastlo
@@ -3198,24 +3198,27 @@
 lastlogin()%0A
+   
    if(input=
@@ -3226,24 +3226,27 @@
 %223%22):%0A      
+  
+ 
 chk_info()%0A 
@@ -3244,16 +3244,19 @@
 _info()%0A
+   
    if(in
@@ -3272,16 +3272,19 @@
 :%0A      
+  
+ 
 utilize_
@@ -3303,16 +3303,19 @@
 ocess()%0A
+   
    if(in
@@ -3331,16 +3331,19 @@
 :%0A      
+  
+ 
 current_
@@ -3355,16 +3355,19 @@
 t_con()%0A
+   
    if(in
@@ -3379,24 +3379,27 @@
 %226%22):%0A      
+  
+ 
 chk_pubip()%0A
@@ -3398,16 +3398,19 @@
 pubip()%0A
+   
    if(in
@@ -3422,24 +3422,27 @@
 %227%22):%0A      
+ 
+  
 chk_login()%0A
@@ -3441,16 +3441,19 @@
 login()%0A
+   
 elif (lo
@@ -3481,16 +3481,19 @@
 =%22NO%22):%0A
+   
    print
@@ -3554,14 +3554,20 @@
 ..%22%0A
+   
 else:%0A
+   
    p
@@ -3593,16 +3593,24 @@
  Key!%22%0A%0A
+main()%0A%0A
 #DONE%0A%0A%0A

Add Main Method