Newer
Older
#!/usr/bin/python
import sys, os, pwd
import getopt
import commands
import subprocess
STATE_OK=0
STATE_WARNING=1
dist = platform.dist()
if dist[0] == "debian":
command = "/usr/sbin/service apache2 status"
elif dist[0] == "centos":
command = "/sbin/service httpd status"
else:
command = "service apache2 status"
check_apache=subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
apache_status=check_apache.communicate()[0]
if "run" in apache_status:
print "Apache is Running"
sys.exit(STATE_OK)
else:
print "Apache is NOT Running !!"
sys.exit(STATE_WARNING)
sys.exit(STATE_OK)