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}
# Check service status
status=1
if [ ! -z "$(service $srv status| grep running)" ]; then
status=0
fi
status=$(service $srv status 2>/dev/null)
rc=$?
stopped=$(echo $status| grep stop)
if [ $status -eq 0 ]; then
if [ "$rc" -eq 0 ] && [ -z "$stopped" ]; then
state='running'
# Calculate cpu and memory usage