]> git.puffer.fish Git - mirror/frr.git/commitdiff
Quagga: Display useful info when doing service quagga status
authorvivek <vivek@cumulusnetworks.com>
Wed, 21 Oct 2015 05:09:58 +0000 (22:09 -0700)
committervivek <vivek@cumulusnetworks.com>
Wed, 21 Oct 2015 05:09:58 +0000 (22:09 -0700)
Ticket: CM-7132
Reviewed By: CCR-3461
Testing Done: the usual

Today, 'service quagga status' merely sets the return code and nothing
more. Like other services, it'd be good to print some useful output as
well.

Example output:
    cumulus@top1$ sudo service quagga status ospfd
    [ ok ] ospfd-1 is running.
    [ ok ] ospfd-2 is running.
    cumulus@top1$ sudo service quagga status
    [ ok ] zebra is running.
    [ ok ] ospfd-1 is running.
    [ ok ] ospfd-2 is running.
    [ ok ] ospf6d is running.
    cumulus@top1$ sudo service quagga status
    [ ok ] zebra is running.
    [ ok ] ospfd-1 is running.
    [FAIL] ospfd-2 is not running ... failed!
    [ ok ] ospf6d is running.
    cumulus@top1$ echo $?
    1
    cumulus@top1$

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
debian/quagga.init.d

index 3e745dfc81606721f3d0981c998def65cde4dcd7..9e5cae88fd06f1effbff992f329bd4d0644556f6 100755 (executable)
@@ -25,6 +25,8 @@ DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld"
 MAX_INSTANCES=5
 RELOAD_SCRIPT=/usr/lib/quagga/quagga-reload.py
 
+. /lib/lsb/init-functions
+
 # Print the name of the pidfile.
 pidfile()
 {
@@ -41,8 +43,12 @@ vtyfile()
 started()
 {
         [ ! -e `pidfile $1` ] && return 3
-       kill -0 `cat \`pidfile $1\`` 2> /dev/null || return 1
-       return 0
+       if [ -n "$2" ] && [ "$2" == "log" ]; then
+           status_of_proc -p `pidfile $1` $1 $1 && return 0 || return $?
+       else
+          kill -0 `cat \`pidfile $1\`` 2> /dev/null || return 1
+          return 0
+        fi
 }
 
 # Loads the config via vtysh -b if configured to do so.
@@ -410,6 +416,7 @@ check_status()
     local daemon_name
     local daemon_prio
     local daemon_inst
+    local failed_status=0
 
     if [ -n "$1" ] && [[ "$1" =~ (.*)-(.*) ]]; then
        daemon=${BASH_REMATCH[1]}
@@ -428,19 +435,19 @@ check_status()
            if [ -n "$daemon_inst" ]; then
               for i in ${daemon_inst}; do
                  if [ -n "$inst" -a "$inst" = "$i" ]; then
-                      started "$1" || return $?
+                      started "$1" "log" || failed_status=$?
                  elif [ -z "$inst" ]; then
-                      started "$daemon_name-$i" || return $?
+                      started "$daemon_name-$i" "log" || failed_status=$?
                  fi
               done
            else
-               started "$daemon_name" || return $?
+               started "$daemon_name" "log" || failed_status=$?
            fi
         fi
     done
 
     # All daemons that need to have been started are up and running
-    return 0
+    return $failed_status
 }
 
 #########################################################