Skip to content
Snippets Groups Projects
check_ldap 619 B
Newer Older
#!/usr/bin/python
import sys, os, pwd
import getopt
import commands
import subprocess
Jupiter Hu's avatar
Jupiter Hu committed
import platform
Jupiter Hu's avatar
Jupiter Hu committed
dist = platform.dist()
if dist[0] == "debian":
    command = "/usr/sbin/service slapd status"
elif dist[0] == "centos":
    command = "/sbin/service slapd status"
else:
    command = "service slapd status"

check_ldap=subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
ldap_status=check_ldap.communicate()[0]

if "run" in ldap_status:
   print "Ldap is Running"
   sys.exit(STATE_OK)
else:
   print "Ldap is NOT Running !!"   
   sys.exit(STATE_WARNING)

sys.exit(STATE_OK)