Agent Skills › netalertx/NetAlertX › netalertx-plugin-run-development

netalertx-plugin-run-development

GitHub

指导如何开发、配置和手动运行 NetAlertX 插件。涵盖插件结构、配置文件设置模式、Python 脚本执行命令及结果日志的读取方法,帮助开发者完成插件创建与调试。

.github/skills/plugin-run-development/SKILL.md netalertx/NetAlertX

Trigger Scenarios

创建 NetAlertX 插件 运行或测试插件 插件开发相关任务

Install

npx skills add netalertx/NetAlertX --skill netalertx-plugin-run-development -g -y
More Options

Non-standard path

npx skills add https://github.com/netalertx/NetAlertX/tree/main/.github/skills/plugin-run-development -g -y

Use without installing

npx skills use netalertx/NetAlertX@netalertx-plugin-run-development

指定 Agent (Claude Code)

npx skills add netalertx/NetAlertX --skill netalertx-plugin-run-development -a claude-code -g -y

安装 repo 全部 skill

npx skills add netalertx/NetAlertX --all -g -y

预览 repo 内 skill

npx skills add netalertx/NetAlertX --list

SKILL.md

Frontmatter
{
    "name": "netalertx-plugin-run-development",
    "description": "Create and run NetAlertX plugins. Use this when asked to create plugin, run plugin, test plugin, plugin development, or execute plugin script."
}

Plugin Development

Expected Workflow for Running Plugins

  1. Read this skill document for context and instructions.
  2. Find the plugin in server/plugins/<code_name>/.
  3. Read the plugin's config.json and script.py to understand its functionality and settings.
  4. Formulate and run the command: python3 server/plugins/<code_name>/script.py.
  5. Retrieve the result from the plugin log folder (/tmp/log/plugins/last_result.<PREF>.log) quickly, as the backend may delete it after processing.

Run a Plugin Manually

python3 server/plugins/<code_name>/script.py

Ensure sys.path includes /app/server/plugins and /app/server (as in the template).

Plugin Structure

server/plugins/<code_name>/
├── config.json      # Manifest with settings
├── script.py        # Main script
└── ...

Manifest Location

server/plugins/<code_name>/config.json

  • code_name == folder name
  • unique_prefix drives settings and filenames (e.g., ARPSCAN)

Settings Pattern

  • <PREF>_RUN: execution phase
  • <PREF>_RUN_SCHD: cron-like schedule
  • <PREF>_CMD: script path
  • <PREF>_RUN_TIMEOUT: timeout in seconds — this is enforced by the core plugin runner as the whole script's kill-timeout (server/plugin.py passes it straight to subprocess(..., timeout=...)). It is not a safe per-HTTP-call timeout — don't reuse it for individual network calls in a loop, or one slow call can burn the whole budget and get the process killed before it writes its result file.
  • <PREF>_WATCH: columns to watch for changes
  • <PREF>_IMPORT_ON: optional — gates whether this run's rows get promoted into CurrentScan (only relevant if mapped_to_table: "CurrentScan"). See docs/PLUGINS_IMPORT_BEHAVIOR.md for the related per-row scanCreatesDevice/scanNotificationMode/scanPresence columns.
  • dataType and default_value must agree. dataType: "array"/"object" needs a real JSON literal for default_value ('["default"]'), not a bare string ("default"). setting_value_to_python_type() (server/helper.py) json.loads()s the default at runtime; a bare string fails silently — logged, and [] is returned instead of your default (e.g. devParentRelType, UI_theme, UI_TOPOLOGY_ORDER). If elementOptions already sets multiple/orderable: "false", the setting is scalar — use dataType: "string" instead.

Data Contract

Scripts write to /tmp/log/plugins/last_result.<PREF>.log

Important: The backend will almost immediately process this result file and delete it after ingestion. If you need to inspect the output, run the plugin and immediately retrieve the result file before the backend processes it.

Use server/plugins/plugin_helper.py:

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

Every mapped field (objectPrimaryId/objectSecondaryId/watchedValue1-4/extra/helpVal1-4) is HTML/control-char-stripped by default before it's persisted: plugin output is untrusted (network responses, device-reported names, etc.). foreignKey is always sanitized too, unconditionally. Only opt a column out ("allow_raw_text": true) if it's a display-only type (textarea_readonly); see docs/PLUGINS_DEV.md#field-sanitization.

Execution Phases

  • once: runs once at startup
  • schedule: runs on cron schedule
  • always_after_scan: runs after every scan
  • before_name_updates: runs before name resolution
  • on_new_device: runs when new device detected
  • on_notification: runs when notification triggered

Plugin Formats

Format Purpose Runs
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

Before Opening a PR

Check the plugin against the Conventions Checklist in docs/PLUGINS_DEV.md — RUN default, schedule precedent, RUN_TIMEOUT semantics, reusing core settings, description length, the multi-instance settings pattern, allow_raw_text restricted to display-only column types, and scanSourcePlugin's static value matching unique_prefix exactly. Most plugin PR review comments trace back to one of these.

If the plugin needs a new system package or Python dependency, mirroring it into the root Dockerfile/requirements.txt alone is not enough: see the Conventions Checklist's build-target-mirroring bullet for .devcontainer/Dockerfile (regenerate via .devcontainer/scripts/generate-configs.sh, don't hand-edit it), Dockerfile.debian, and install/ubuntu24/install/proxmox's own requirements.txt files.

Starting Point

Copy from server/plugins/__template and customize.

Version History

  • f6010e0 Current 2026-09-27 22:54
  • cd1d0ed 2026-09-22 11:08

    补充了 dataType 与 default_value 一致性要求、execution phases 说明及 plugin_helper 使用细节,清理了旧版文档。

  • a686a01 2026-09-03 06:47

    改进了脚手架支持并优化了文档说明。

  • 548d698 2026-08-19 22:09

    插件目录从front/plugins迁移至server/plugins,并新增网站监控插件及相关工作流配置更新。

  • 8aec57b 2026-07-24 22:14

Same Skill Collection

.claude/skills/database-patterns/SKILL.md
.claude/skills/git-workflow/SKILL.md
.claude/skills/install-scripts/SKILL.md
.claude/skills/plugin-development/SKILL.md
.claude/skills/plugin-readme/SKILL.md
.claude/skills/plugin-review/SKILL.md
.claude/skills/pr-analysis/SKILL.md
.claude/skills/prd-writing/SKILL.md
.claude/skills/scan-pipeline/SKILL.md
.claude/skills/skill-hygiene/SKILL.md
.claude/skills/testing-workflow/SKILL.md
.claude/skills/ux-design-patterns/SKILL.md
.gemini/skills/database-patterns/SKILL.md
.gemini/skills/devcontainer-management/SKILL.md
.gemini/skills/git-workflow/SKILL.md
.gemini/skills/install-scripts/SKILL.md
.gemini/skills/logging-standards/SKILL.md
.gemini/skills/mcp-activation/SKILL.md
.gemini/skills/plugin-review/SKILL.md
.gemini/skills/pr-analysis/SKILL.md
.gemini/skills/prd-writing/SKILL.md
.gemini/skills/project-navigation/SKILL.md
.gemini/skills/scan-pipeline/SKILL.md
.gemini/skills/settings/SKILL.md
.gemini/skills/skill-hygiene/SKILL.md
.gemini/skills/skills-index/SKILL.md
.gemini/skills/testing-workflow/SKILL.md
.gemini/skills/ux-design-patterns/SKILL.md
.github/skills/api-development/SKILL.md
.github/skills/authentication/SKILL.md
.github/skills/code-standards/SKILL.md
.github/skills/database-patterns/SKILL.md
.github/skills/database-reset/SKILL.md
.github/skills/devcontainer-configs/SKILL.md
.github/skills/devcontainer-services/SKILL.md
.github/skills/devcontainer-setup/SKILL.md
.github/skills/docker-build/SKILL.md
.github/skills/docker-prune/SKILL.md
.github/skills/git-workflow/SKILL.md
.github/skills/install-scripts/SKILL.md
.github/skills/logging-standards/SKILL.md
.github/skills/mcp-activation/SKILL.md
.github/skills/plugin-readme/SKILL.md
.github/skills/plugin-review/SKILL.md
.github/skills/pr-analysis/SKILL.md
.github/skills/prd-writing/SKILL.md
.github/skills/project-navigation/SKILL.md
.github/skills/sample-data/SKILL.md
.github/skills/scan-pipeline/SKILL.md

Metadata

Files
0
Version
f6010e0
Hash
015dceba
Indexed
2026-07-24 22:14

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-01 09:17
浙ICP备14020137号-1