#!/usr/bin/python import sys, os, pwd import getopt import commands import subprocess import platform STATE_OK=0 STATE_WARNING=1 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)