S6-SVSTAT(8)

NAME
s6-svstat - print a short, human-readable or programmatically parsable summary of the state of a process monitored by s6-supervise(8)

SYNOPSIS
s6-svstat [-uwNrpest | -o up,wantedup,normallyup,ready,paused,pid,pgid,exitcode,signal,signum,updownsince,readysince,updownfor,readyfor] [-n] servicedir

DESCRIPTION
s6-svstat gives information about the process being monitored at the servicedir s6-service-directory(7), then exits 0.

When s6-svstat is invoked without options, or with only the -n option, it prints a human-readable summary of all the available information on the service. In this case, the -n option instructs it to print a signal number (instead of a signal name) if the supervised process was killed by a signal. The summary includes the following data:

•   whether the process is up or down, and if it's up, the number of seconds that it has been up.

•   the process' pid, if it is up, or its last exit code or terminating signal, if it is down.

•   what its default state is, if it is different from its current state.

•   the number of seconds since it last changed states.

•   whether the service is ready ( cf. s6-notifywhenup(7)) as notified by the daemon itself, and if it is, the number of seconds that it has been. A service reported as down and ready simply means that it is ready to be brought up. A service is down and not ready when it is in the cleanup phase, i.e. the ./finish script is still being executed.

When s6-svstat is invoked with one or several options other than -n, it outputs programmatically parsable information instead. The output is a series of space-separated values, one value per requested field. The valid options are as follows.

OPTIONS

-o fields
    List fields to print. fields is a list of comma-separated field names. The valid field names are the following:

    up  Print ‘true’ if the service is up and ‘false’ if it is down.

    wantedup
        Print ‘true’ if s6-supervise(8) is currently instructed to (re)start the service when it is down, and ‘false’ if s6-supervise(8) is currently instructed to leave the service alone.

    normallyup
        Print ‘true’ if the service is supposed to start when s6-supervise(8) starts (i.e. no ./down file), and ‘false’ if it is not (i.e. there is a ./down file).

    ready
        Print ‘true’ if the service is ready, and ‘false’ if it is not. Note that a service can be both down and ready: it simply means that it is ready to be started (i.e. no ./finish script is currently running). To check for service readiness, you should give this option along with ‘up’: the service is ready iff ‘s6-svstat -o up,ready’ prints ‘true true’. (The ‘true true’ case will never happen if the service does not support readiness notification.)

    paused
        Print ‘true’ if the service is paused (i.e. the process is currently stopped) and ‘false’ if it is not. It is a rare flag, you shouldn't normally need to use this option.

    pid Print the pid of the supervised process. If the service is currently down, ‘-1’ is printed instead.

    pgid
        Print the process group of the supervised process. If the service is currently down, print the process group of the last living instance of the service.

    exitcode
        Print the exit code of the last execution of ./run. If the service is currently up, or the last ./run process was killed by a signal, ‘-1’ is printed instead.

    signal
        Print the name of the signal the last ./run process was killed with. If the service is currently up, or the last ./run process was not killed by a signal, ‘NA’ is printed instead.

    signum
        Print the number of the signal the last ./run process was killed with. If the service is currently up, or the last ./run process was not killed by a signal, ‘-1’ is printed instead.

    updownsince
        Print a TAI64N[1] label representing the absolute date when the service last changed states.

    readysince
        Print a TAI64N[1] label representing the absolute date when the service last became ready. Note that this can either mean “service readiness” (if the service is currently up and ready), or “down readiness”, i.e. the last time when the service was down and ready to be started (if the service is not currently up and ready).

    updownfor
        Print the number of seconds that have elapsed since the service last changed states.

    readyfor
        Print the number of seconds that have elapsed since the service last became ready (or ready to be started if it's currently not up and ready).

-u  Equivalent to ‘-o up’.

-w  Equivalent to ‘-o wantedup’.

-N  Equivalent to ‘-o normallyup’.

-r  Equivalent to ‘-o ready’.

-p  Equivalent to ‘-o pid’.

-g  Equivalent to ‘-o pgid’.

-e  Equivalent to ‘-o exitcode’.

-s  Equivalent to ‘-o signal’.

-t  Equivalent to ‘-o updownfor’.

EXIT STATUS

0   Success.

1   s6-supervise(8) not running on servicedir.

100 Wrong usage.

111 System call failed.

EXAMPLES
    s6-svstat -o up,ready

or its equivalent, ‘s6-svstat -ur’, will print ‘true true’ if the service is up and ready, ‘true false’ if the service has been started but has not notified readiness yet, ‘false true’ if it is down and can be started, and ‘false false’ if it is down and there's a ./finish script running that needs to exit before the service can be restarted.

    s6-svstat -o pid,exitcode,signal

or its equivalent, ‘s6-svstat -pes’, will print ‘42 -1 NA’ if the service has been started and ./run' s pid is 42; it will print ‘-1 0 NA’ if the service is down and ./run last exited 0; it will print ‘-1 -1 SIGTERM’ if the service is down and ./run was last killed by a SIGTERM - as can happen, for instance, when you down the service via a call to ‘s6-svc -d’.

SEE ALSO
s6-notifyoncheck(8), s6-permafailon(8), s6-supervise(8), s6-svc(8), s6-svdt(8), s6-svdt-clear(8), s6-svlisten(8), s6-svlisten1(8), s6-svok(8), s6-svscan(8), s6-svscanctl(8), s6-svwait(8)

[1] https://cr.yp.to/libtai/tai64.html

This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/s6-svstat.html

AUTHORS
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)