Code

Added support for the "status" command to the init script.
authorSebastian Harl <sh@tokkee.org>
Sun, 6 Jan 2008 17:12:17 +0000 (18:12 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 6 Jan 2008 17:12:17 +0000 (18:12 +0100)
debian/collectd.init.d

index 42a90cd6047795ed2f2d4f5e2cea2146f621ed39..18ece441da3df23de708eaae715b3bf2352f38a1 100755 (executable)
@@ -78,6 +78,24 @@ d_stop() {
        fi
 }
 
+d_status() {
+       PID=$( cat "$PIDFILE" 2> /dev/null ) || true
+
+       if test -n "$PID" && kill -0 $PID 2> /dev/null; then
+               echo "collectd ($PID) is running."
+               exit 0
+       else
+               PID=$( pidof collectd ) || true
+
+               if test -n "$PID"; then
+                       echo "collectd ($PID) is running."
+                       exit 0
+               else
+                       echo "collectd is stopped."
+               fi
+       fi
+}
+
 case "$1" in
        start)
                echo -n "Starting $DESC: $NAME"
@@ -89,6 +107,9 @@ case "$1" in
                d_stop
                echo "."
                ;;
+       status)
+               d_status
+               ;;
        restart|force-reload)
                echo -n "Restarting $DESC: $NAME"
                d_stop