teaql-provider-linux
TeaQL data service provider for Linux system information. This crate allows you to query the local Linux system's /proc filesystem directly through TeaQL.
Features
This provider uses procfs to extract real-time system metrics and exposes them as TeaQL queryable entities. It currently supports reading:
- SystemInfo: Global system metrics including load averages, uptime, and memory usage.
- Process: Information about running processes (PID, state, CPU usage, memory, command line, etc.).
- Thread: Thread-level information for specific processes.
Note: This provider is read-only. It acts only as a QueryExecutor and will not modify the underlying system.
Usage
The recommended way to use this provider is alongside the TeaQL Code Generator. While you can manually define models and use the provider, using the generator makes querying the Linux system fully type-safe and incredibly ergonomic.
-
Generate the Domain Library Use
teaql-code-gento generate a native Rust library from your domain model that containsSystemInfo,Process, andThreadentities. -
Add Dependencies In your application, depend on the generated library and this provider:
[] = { = "../your-generated-lib" } = "4.1.0" = "4.1.0" -
Initialize the Context Construct the
LinuxDataServiceExecutorand provide it to the generated user context to execute queries against the system:use LinuxDataServiceExecutor; use UserContext; use Process; async
Full Example
For a complete, runnable example of using teaql-provider-linux with generated code, see the Linux System Info Application Example in the teaql-rust-app-examples repository.
Entities Mapping
The following entity queries are resolved dynamically by querying /proc on-the-fly:
SystemInfo-> Returns a single record reflecting the current system state.Process-> Supports fetching all processes or fetching a specific process by itsid(PID).Thread-> Supports fetching threads.
Permissions
Some metrics require elevated permissions to read (e.g., certain memory metrics or inspecting processes owned by other users). If the provider lacks permission to read specific /proc entries, it will gracefully skip them or leave those fields empty.