#!/bin/python
import subprocess
process = subprocess.Popen('./nagios_monitor.sh', stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) try: for line in process.stdout: systemup = "Successfully" #systemup = "NOT-FOUND" if (systemup in line): print("Nagios Process is running: {}".format(systemup)) else: print("Nagios NOT FOUND: PROCESS DOWN") except: error = 1 print(error) process.stdout.close()
#!/bin/bash
echo "*******************************************************************"
echo " Checking Nagios process status"
if [ $(ps -ef |grep -i nagios|grep -v grep|wc-l) -ge 10 ]; then
echo "Nagios process running Successfully"
else
echo "Nagios process is Down"
fi
#####################################################
python new_subprocess.py
######################################
# nagios running successfully
##############################################################