Skip to main content

Simple library for control status of systemctl service

Project description

Python-Systemctl-Libary

Python library providing a direct interface to systemd via systemctl for service management and inspection.

The library exposes a single high-level class, Systemctl, mapping one-to-one to common systemctl operations and queries.


Installation

From PyPI:

pip install pysysctllib

From source:

git clone https://github.com/Sesdear/Python-Systemctl-Libary.git
cd Python-Systemctl-Libary
pip install .

Environment

  • Python >= 3.7
  • Linux with systemd
  • systemctl available
  • Appropriate privileges for service control

Basic Usage

from pysysctllib import Systemctl

svc = Systemctl("nginx.service")

svc.start()
svc.stop()
svc.restart()
svc.reload()

svc.enable()
svc.disable()

svc.mask()
svc.unmask()

svc.is_active()
svc.is_enabled()
svc.is_masked()

svc.show()
svc.show_full()
svc.status()
svc.get_main_pid()
svc.get_description()
svc.get_unit_file_state()
svc.list_dependencies()

svc.reload_daemon()

API

Systemctl(name: str)

Service unit controller bound to a specific systemd unit name.


Lifecycle Operations

  • start() -> bool
  • stop() -> bool
  • restart() -> bool
  • reload() -> bool

Enablement

  • enable() -> bool
  • disable() -> bool
  • is_enabled() -> bool

Masking

  • mask() -> bool
  • unmask() -> bool
  • is_masked() -> bool

State and Metadata

  • show() -> str
  • show_full() -> ShowModel
  • status() -> StatusModel
  • is_active() -> bool
  • get_main_pid() -> int
  • get_description() -> str
  • get_unit_file_state() -> str
  • list_dependencies() -> list

systemd Manager

  • reload_daemon() -> bool

License

GPL-2.0


Author

Sesdear

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysysctllib-0.0.5.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysysctllib-0.0.5-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pysysctllib-0.0.5.tar.gz.

File metadata

  • Download URL: pysysctllib-0.0.5.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pysysctllib-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7a14972cd48c5bcfa9866fb5aa288f40ba4cb6c6a15a3004ff79b1d98433fcf9
MD5 08f607ea6c1576d1f0a78b0412033c00
BLAKE2b-256 05a149eeb1360c320413987597d645e812a6747c6ed78d8a7eba5d9a7a1d3145

See more details on using hashes here.

File details

Details for the file pysysctllib-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pysysctllib-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pysysctllib-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b3c43a3e55f62f30f638fa9da091049e9fb51422cffb3b8120e3fdef194a7d
MD5 00077b6a1d56def0a2a512d8f81580b5
BLAKE2b-256 87e16c6a2f3b19575dc1757a88d1cd2f4a0da94b8840441e51b5d4adafb0a300

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page