-
-
Notifications
You must be signed in to change notification settings - Fork 421
Next release: feat: Implement DevicesHistory feature with triggers and history tracking #1701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jokob-sk
wants to merge
4
commits into
main
Choose a base branch
from
next_release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,811
−81
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,86 @@ | ||
| # Plugin development skill | ||
| --- | ||
| name: netalertx-plugin-development | ||
| description: Create and run NetAlertX plugins. Use this when asked to create plugin, run plugin, test plugin, or develop plugin functionality. | ||
| --- | ||
|
|
||
| 1. Assess requirements | ||
| 2. Read `docs/PLUGINS_DEV.md` | ||
| 3. Confirm field mapping | ||
| 4. Ask clarifying questions | ||
| 5. code placed in `front/plugins/<new plugin name>` | ||
| # Plugin Development | ||
|
|
||
| ## Expected Workflow | ||
|
|
||
| Plugin prefix: | ||
| 1. Read this skill and `docs/PLUGINS_DEV.md` for full context. | ||
| 2. Find or create the plugin in `front/plugins/<code_name>/`. | ||
| 3. Read the plugin's `config.json` and `script.py` to understand its functionality. | ||
| 4. Run: `python3 front/plugins/<code_name>/script.py` | ||
| 5. Retrieve the result from `/tmp/log/plugins/last_result.<PREF>.log` quickly — the backend deletes it after processing. | ||
|
|
||
| - has to be uppercase letters only (no underscores) | ||
| - must be unique | ||
| - keep short but readable if possible | ||
| ## Run a Plugin Manually | ||
|
|
||
| ```bash | ||
| python3 front/plugins/<code_name>/script.py | ||
| ``` | ||
|
|
||
| Ensure `sys.path` includes `/app/front/plugins` and `/app/server` (as in the template). | ||
|
|
||
| ## Plugin Structure | ||
|
|
||
| ```text | ||
| front/plugins/<code_name>/ | ||
| ├── config.json # Manifest with settings | ||
| ├── script.py # Main script | ||
| └── ... | ||
| ``` | ||
|
|
||
| ## Plugin Prefix Rules | ||
|
|
||
| - Uppercase letters only (no underscores, no numbers) | ||
| - Must be unique across all plugins | ||
| - Short but readable (e.g., `ARPSCAN`, `MQTT`, `UNIFI`) | ||
|
|
||
| ## Settings Pattern | ||
|
|
||
| - `<PREF>_RUN`: execution phase | ||
| - `<PREF>_RUN_SCHD`: cron-like schedule | ||
| - `<PREF>_CMD`: script path | ||
| - `<PREF>_RUN_TIMEOUT`: timeout in seconds | ||
| - `<PREF>_WATCH`: columns to watch for changes | ||
|
|
||
| ## Data Contract | ||
|
|
||
| Scripts write to `/tmp/log/plugins/last_result.<PREF>.log` using `plugin_helper.py`: | ||
|
|
||
| ```python | ||
| from plugin_helper import Plugin_Objects | ||
|
|
||
| plugin_objects = Plugin_Objects() | ||
| plugin_objects.add_object(...) # During processing | ||
| plugin_objects.write_result_file() # Exactly once at end | ||
| ``` | ||
|
|
||
| **Important:** The backend processes and deletes the result file almost immediately. Retrieve it quickly if inspecting output. | ||
|
|
||
| ## Execution Phases | ||
|
|
||
| | Phase | Trigger | | ||
| |-------|---------| | ||
| | `once` | Once at startup | | ||
| | `schedule` | On cron schedule | | ||
| | `always_after_scan` | After every scan | | ||
| | `before_name_updates` | Before name resolution | | ||
| | `on_new_device` | When new device detected | | ||
| | `on_notification` | When notification triggered | | ||
|
|
||
| ## Plugin Formats | ||
|
|
||
| | Format | Purpose | Phase | | ||
| |--------|---------|-------| | ||
| | publisher | Send notifications | `on_notification` | | ||
| | dev scanner | Create/manage devices | `schedule` | | ||
| | name discovery | Discover device names | `before_name_updates` | | ||
| | importer | Import from services | `schedule` | | ||
| | system | Core functionality | `schedule` | | ||
|
|
||
| ## Starting Point | ||
|
|
||
| Copy from `front/plugins/__template` and customize. Read `docs/PLUGINS_DEV.md` for the full development guide. | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.