universal way to query service status

This commit is contained in:
Serghey Rodin 2014-05-17 11:58:54 +03:00
commit f0c5a60849

View file

@ -23,12 +23,11 @@ get_srv_state() {
proc_name=${2-$1} proc_name=${2-$1}
# Check service status # Check service status
status=1 status=$(service $srv status 2>/dev/null)
if [ ! -z "$(service $srv status| grep running)" ]; then rc=$?
status=0 stopped=$(echo $status| grep stop)
fi
if [ $status -eq 0 ]; then if [ "$rc" -eq 0 ] && [ -z "$stopped" ]; then
state='running' state='running'
# Calculate cpu and memory usage # Calculate cpu and memory usage