/systemd-state

This package provides an object oriented way to access your systemd service state.

Primary LanguagePHPMIT LicenseMIT

systemd-state

Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads Latest Unstable Version License

This package provides an object oriented way to access your systemd service state.

Tested Versions

  • Ubuntu: systemd 229
  • Debian: systemd 215,232
  • CentOS: systemd 219

Usage

composer require cyberline/systemd-state

# get info about systemd itself:
$systemdState = new SystemdState;
$info = $systemdState->getSystemdInfo();
...

# get info about specific services:
$systemdState = new SystemdState;
$systemdState
    ->addCheckUnit('nginx');
    ->addCheckUnit('redis');
$info = $systemdState->getReport();
...

# get info from pregenerated file
# /bin/systemctl show * --no-pager > systemd.txt
$systemdState = new SystemdState;
$info = $systemdState
    ->checkFromString(file_get_contents('systemd.txt'))
    ->getReport();
...

# get info about all services:
$systemdState = new SystemdState;
$systemdState->addAllUnits();
$info = $systemdState->getReport();