Skip to main content

OOP Linux operations SDK with workflows

Project description

ServerKit

Object-oriented Python SDK for Linux operations — processes, logs, workflows, and system resources with a fluent, chainable API.

Think structured objects instead of parsing ps aux, grep, and one-off shell pipelines.

Architecture

Layer Owner Path
SDK (core) Dev 1 serverkit/* resource modules
Interactive shell Dev 2 serverkit/shell
AI (Ollama) Dev 2 serverkit/ai

Dev 2 consumes the SDK via Server — see docs/DEV2_CONTRACTS.md.

Server API

from serverkit import Server

server = Server()

server.processes().memory_above(500).sort_by_memory().all()
print(server.processes().display_by_name())  # task-manager style (RSS per app name)
server.logs("app.log").errors().match(r"timeout").all()
server.memory().summarize()
server.disk().usage_above(80).summarize()
server.network().interfaces().sort_by_traffic().summarize()
server.ports().listening().summarize()
server.systemctl().list_units().active().summarize()
server.cron().suspicious_only().all()
server.users().logged_in().summarize()
server.env().keys_matching("PATH").all()
server.docker().containers().running().summarize()  # needs [docker] extra
server.containers().running().summarize()           # alias for docker().containers()

server.services().active().summarize()
server.service("nginx").restart()

server.disk().largest_files("/home", limit=10).display()
server.import_workflow("nginx_health_check")
server.run("nginx_health_check")

server.workflow("audit").processes().memory_above(1000).summarize().save()
server.run("audit", dry_run=True)

Future extensions (v0.3)

Bundled workflow catalog, high-level services API, and SSH remote facade:

from serverkit import Server

# Catalog templates (no filesystem path needed)
Server().import_workflow("memory_audit")

# Remote host (requires pip install serverkit[remote])
with Server.connect("vm1.example", user="deploy", key_path="~/.ssh/id_ed25519") as remote:
    print(remote.processes().memory_above(200).summarize())
    print(remote.memory().summarize())
    remote.service("nginx").status()
    remote.run("memory_audit")  # workflow steps use remote processes/logs

Configure SSH defaults in ~/.serverkit/config.json:

{
  "remote": {
    "default_user": "deploy",
    "key_path": "/home/you/.ssh/id_ed25519",
    "port": 22
  }
}

See examples/import_catalog_workflow.py and examples/remote_audit.py.

Setup

Requires Python 3.10+.

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"           # core + pytest
pip install -e ".[rich]"          # table output
pip install -e ".[docker]"        # container support
pip install -e ".[remote]"        # SSH remote Server.connect()
pip install -e ".[ai]"            # Ollama natural-language (requests)
pip install -e ".[all]"           # everything
pytest                              # offline unit tests (default)
pytest -m integration               # live OS / psutil tests

Config: ~/.serverkit/config.json (executor, rich output, Ollama model defaults).

OOP patterns used

Pattern Where
Facade Server
Factory ProcessFactory, StepFactory
Fluent collection ProcessCollection, LogFile, DiskCollection, …
Composite Workflow + WorkflowStep
Strategy SequentialExecutor / ParallelExecutor
Builder WorkflowBuilder

Design rules

  • Eager execution — filters run immediately; .all() / .summarize() are terminal.
  • Workflow JSONschema_version: 2 under ~/.serverkit/workflows/.
  • Optional depsrich, docker, remote (paramiko), ai (requests / Ollama) fail with OptionalDependencyError if missing.

Documentation

Document Description
docs/serverkit_main.pdf Full architecture
docs/serverkit_dev1_sdk_core.pdf Dev 1 SDK spec
docs/serverkit_dev2_shell_ai.pdf Dev 2 shell + AI
docs/DEV2_CONTRACTS.md Stable integration API
docs/AI_TESTING.md AI layer install, automated tests, manual Ollama checks

License

TBD

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

serverkit-0.3.0.tar.gz (50.3 kB view details)

Uploaded Source

Built Distribution

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

serverkit-0.3.0-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

Details for the file serverkit-0.3.0.tar.gz.

File metadata

  • Download URL: serverkit-0.3.0.tar.gz
  • Upload date:
  • Size: 50.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for serverkit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9384080ac35afc09e8d92499f086fc91157e4d40a098c4c4884ac831fff7c02e
MD5 856f9c2b84d5c12e01942515f7d548ca
BLAKE2b-256 843aa6595897fe441ae4a26eabd17c4408353688d90f4d542d2a7e892349bd14

See more details on using hashes here.

File details

Details for the file serverkit-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: serverkit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 64.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for serverkit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50f1c92a66d84f8f8a7b2f008ce8282fcaa158ccd672c05f5da2ecb82602a547
MD5 2cec95ad77e34e7de265150df2f4bd08
BLAKE2b-256 c0b6c62755ddbee14d53f294a183bfc0457c4accf7fac2e3100153d7dc3594f2

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