psvstat
is a command-line utility for checking and printing the status of runit
services. This tool reads the service status from the supervise/status
file of each specified runit
service and displays relevant information in a user-friendly format.
- Displays whether the service is a user service or a system service.
- Shows the service name, desired state, and current state.
- Indicates if the service is paused, down, running, or finished.
- Provides the time elapsed since the last status change.
- Displays the process ID and command name of the running service.
To compile the program, run the following command:
$ make
$ make PREFIX=$HOME/.local install
The psvstat
program takes one or more arguments, each representing the path to a runit
service directory. For example:
psvstat /etc/service/service1 /etc/service/service2
- service_path: The path to the
runit
service directory. The program expects the status file to be located atservice_path/supervise/status
.
The program prints the status of each specified service in a formatted manner. The output contains the following columns:
- Type: Indicates if the service is a user service (
user
) or a system service (sys
). - Name: The name of the service.
- Desired State: Indicates if the service's desired state matches its current state.
=
: The service's desired state matches its current state.v
: The service is up but should be down.^
: The service is down but should be up.
- Current State: The current state of the service.
paus
: The service is paused.down
: The service is down.run
: The service is running.fin
: The service has finished.???
: Unknown state.
- Time Since Last Change: The time elapsed since the last status change.
- PID: The process ID of the service if it is running.
- Command: The command name of the running process if available.
sys service1 = run 2 hours 1234 myservice
sys service2 ^ down 5 minutes --- ---
In this example:
service1
is a system service (sys
), its desired state matches its current state (=
), it is currently running (run
), the status changed 2 hours ago, its PID is 1234, and the command name ismyservice
.service2
is a system service (sys
), its desired state does not match its current state (v
), it should be down but is up, the status changed 5 minutes ago, it is not running (---
), and no command name is available (---
).
The program handles several error conditions and prints appropriate messages to stderr
:
- If it is unable to open the
supervise/status
file, it prints:<service_path>: unable to open supervise/status
- If it is unable to read the
supervise/status
file, it prints:<service_path>: unable to read status
- HOME: Used to determine if a service is a user service.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Written by Friedel Schon.
Thanks to the developers and community of runit
for their excellent software and documentation.