Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reubenmiller/tedge-provider
Research: thin-edge.io providers for extensible plugins
https://github.com/reubenmiller/tedge-provider
Last synced: 1 day ago
JSON representation
Research: thin-edge.io providers for extensible plugins
- Host: GitHub
- URL: https://github.com/reubenmiller/tedge-provider
- Owner: reubenmiller
- License: apache-2.0
- Created: 2024-10-28T19:55:37.000Z (22 days ago)
- Default Branch: main
- Last Pushed: 2024-10-28T21:11:01.000Z (22 days ago)
- Last Synced: 2024-10-28T22:22:09.365Z (22 days ago)
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Plugins
thin-edge.io research into using extendable providers for:
* tedge-log-plugin## tedge-log-provider
### Adding a provider
Providers can be added to the following directory.
```sh
/usr/lib/tedge-log-provider/providers
```Each provider must support the following subcommands:
```sh
# List the types that should be added
myprovider list# Fetch the logs given the search parameters
myprovider logs [--service ""] [--since ""] [--until ""] [--text ] [--max-lines ]
```### Example log provider
A log provider can execute any command to retrieve and print the logs. The `log_provider` is then responsible for integrating the provider with thin-edge.io.
The following shows how to add your own log provider to retrieve logs from a custom source (e.g. sqlite, or some other 3rd party interface).
1. Create a provider file
**File: /usr/lib/tedge-log-provider/providers/plclog**
```sh
#!/bin/sh
set -eSEARCH_TEXT=
DATE_FROM=${DATE_FROM:-"24h"}
DATE_TO=${DATE_TO:-"0m"}
MAX_LINES=${MAX_LINES:-1000}
SERVICE=# Arg parsing
ACTION="$1"
shift
while [ $# -gt 0 ]; do
case "$1" in
--service)
SERVICE="$2"
shift
;;
--since)
DATE_FROM="$2"
shift
;;
--until)
DATE_TO="$2"
shift
;;
--text)
SEARCH_TEXT="$2"
shift
;;
--max-lines|-n)
MAX_LINES="$2"
shift
;;
--help|-h)
;;
*)
;;
esac
shift
donelist() {
# Print 1 item per line to stdout, with the format "/"
provider_name=$(basename "$0")
echo "$provider_name/instance1"
echo "$provider_name/instance2"
}logs() {
# Fetch the logs and print the log contents to stdout
# Additional logging should be written to stderr
echo "Fetching logs. Parameters: SERVICE=$SERVICE, SINCE=$DATE_FROM, UNTIL=$DATE_TO, TEXT=$SEARCH_TEXT, MAX_LINES=$MAX_LINES" >&2echo "TODO: Run your logic to print the log contents to stdout"
}#
# Main
#
case "$ACTION" in
logs)
logs
;;
list)
list
;;
*)
echo "Unsupported command" >&2
exit 1
;;
esac
```2. Allow the provider to be executed
```sh
chmod a+x /usr/lib/tedge-log-provider/providers/plclog
```3. Add the log types to the `tedge-log-plugin.toml` from each provider by running the following command:
```sh
log_provider export-all 2>&1
```**Note** The above command can also be executed via the Cumulocity shell interface