#!/bin/bash -x
# Exit values:
# ------------
# 0 OK
# 1 Warning
# 2 Cirital
# 3 Unknown
# Others Unknown
##-------
dfs_process=`ps -ef | grep './dfs client' | grep -v grep`
if [ -z "$dfs_process" ];then
echo "Critical the program of gather is down !!!"
exit 2
fi
process_ppid=`echo $dfs_process|awk '{print $3}'`
process_pid=`echo $dfs_process|awk '{print $2}'`
if [ $process_ppid = 1 ];then
echo 'The process of dfs put back'
exit 1
else
while [ $process_ppid != 1 ]
do
old_process_ppid=$process_ppid
process_ppid=`ps -ef | grep $process_ppid | grep -v $process_pid | grep -v grep | awk '{print $3}'`
process_pid=`ps -ef | grep $old_process_ppid| grep -v $process_pid | grep -v grep|awk '{print $2}'`
done
dfs_pprocess=`ps -ef | grep "$process_pid 1" | grep -v grep`
echo "process of './dfs client' OK ! - Parent process is `echo $dfs_pprocess | awk '{print $8,$9,$10}'`"
exit 0
fi