Summary
Add a hook mechanism that allows administrators to trigger external scripts automatically when specific events occur within NPMPlus.
Motivation
Currently, there is no way to automatically react to host lifecycle changes within NPMPlus. Integrations that depend on these events—such as dynamic DNS management, monitoring configuration, or automated provisioning—require manual intervention or periodic polling. Introducing hooks would allow for immediate, event-driven automation.
Proposed Functionality
Implement a configurable hook system that executes user-defined shell commands or scripts when defined events occur. Scripts would receive relevant event data (e.g., host name, host ID, state) as input, allowing external systems to respond accordingly.
Example Events
- Host Added: Trigger when a new host is added to NPMPlus (e.g., run a script to create corresponding DNS entries).
- Host Removed: Trigger when a host is deleted (e.g., run a script to clean up DNS entries or remove monitoring checks).
- Host Enabled/Disabled: Trigger when a host’s active state changes (e.g., update load balancer configuration or alerting systems).
Implementation Concept
Hooks could be defined in the configuration file or via the UI. Each hook entry would specify:
- The event to listen for.
- The command or script to execute.
- Whether the hook runs synchronously or asynchronously.
- Optional environment variables or arguments to pass to the script.
Example configuration:
hooks:
- event: host_added
command: /usr/local/bin/add_to_dns.sh
- event: host_removed
command: /usr/local/bin/remove_from_dns.sh
- event: host_disabled
command: /usr/local/bin/disable_in_monitoring.py
Data Input
The hook system should pass structured data to the command, either via environment variables or STDIN, such as:
{
"event": "host_added",
"host": {
"id": "123",
"name": "web01.example.com",
"ip": "192.168.1.10",
"enabled": true
}
}
Benefits
- Enables seamless integration with DNS, monitoring, and automation systems.
- Reduces manual configuration drift.
- Supports event-driven workflows for dynamic environments.
Summary
Add a hook mechanism that allows administrators to trigger external scripts automatically when specific events occur within NPMPlus.
Motivation
Currently, there is no way to automatically react to host lifecycle changes within NPMPlus. Integrations that depend on these events—such as dynamic DNS management, monitoring configuration, or automated provisioning—require manual intervention or periodic polling. Introducing hooks would allow for immediate, event-driven automation.
Proposed Functionality
Implement a configurable hook system that executes user-defined shell commands or scripts when defined events occur. Scripts would receive relevant event data (e.g., host name, host ID, state) as input, allowing external systems to respond accordingly.
Example Events
Implementation Concept
Hooks could be defined in the configuration file or via the UI. Each hook entry would specify:
Example configuration:
Data Input
The hook system should pass structured data to the command, either via environment variables or STDIN, such as:
{ "event": "host_added", "host": { "id": "123", "name": "web01.example.com", "ip": "192.168.1.10", "enabled": true } }Benefits