feat(core): Centralize timeouts/constants, add CLI prompt helpers, and introduce webhook/script actions with safety and SNMP refactors
This commit is contained in:
136
readme.md
136
readme.md
@@ -8,6 +8,10 @@ maximum reliability.
|
||||
**Version 5.0+** is powered by Deno and distributed as single pre-compiled binaries—no installation,
|
||||
no setup, just run.
|
||||
|
||||
## Issue Reporting and Security
|
||||
|
||||
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- **🔌 Multi-UPS Support**: Monitor multiple UPS devices from a single installation
|
||||
@@ -18,6 +22,8 @@ no setup, just run.
|
||||
- Battery threshold triggers
|
||||
- Runtime threshold triggers
|
||||
- Power status change triggers
|
||||
- Webhook notifications
|
||||
- Custom shell scripts
|
||||
- Configurable shutdown delays
|
||||
- **🌐 Universal SNMP Support**: Full support for SNMP v1, v2c, and v3 with authentication and
|
||||
encryption
|
||||
@@ -178,7 +184,7 @@ nupst group remove <id> # Remove a group
|
||||
nupst group list # List all groups
|
||||
```
|
||||
|
||||
### Action Management 🆕
|
||||
### Action Management
|
||||
|
||||
Actions define what happens when UPS conditions are met. Actions can be attached to individual UPS
|
||||
devices or to groups.
|
||||
@@ -197,6 +203,14 @@ nupst action list
|
||||
nupst action list <ups-id|group-id>
|
||||
```
|
||||
|
||||
**Supported Action Types:**
|
||||
|
||||
| Type | Description |
|
||||
| ---------- | ------------------------------------------------ |
|
||||
| `shutdown` | Graceful system shutdown with configurable delay |
|
||||
| `webhook` | HTTP POST/GET notification to external services |
|
||||
| `script` | Execute custom shell scripts from `/etc/nupst/` |
|
||||
|
||||
**Example: Adding an action**
|
||||
|
||||
```bash
|
||||
@@ -221,7 +235,7 @@ Add Action to UPS Main Server UPS
|
||||
Changes saved and will be applied automatically
|
||||
```
|
||||
|
||||
### Feature Management 🆕
|
||||
### Feature Management
|
||||
|
||||
Optional features like the HTTP server for JSON status export:
|
||||
|
||||
@@ -312,7 +326,7 @@ nupst config show # Display current configuration
|
||||
NUPST stores configuration at `/etc/nupst/config.json`. The easiest way to configure is through
|
||||
interactive commands, but you can also edit the JSON directly.
|
||||
|
||||
### Example Configuration (v4.1+)
|
||||
### Example Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -453,11 +467,26 @@ Actions define automated responses to UPS conditions:
|
||||
|
||||
| Field | Description | Values |
|
||||
| --------------- | -------------------------------- | -------------------------------------- |
|
||||
| `type` | Action type | Currently only 'shutdown' |
|
||||
| `type` | Action type | 'shutdown', 'webhook', 'script' |
|
||||
| `thresholds` | Battery and runtime limits | `{ battery: 0-100, runtime: minutes }` |
|
||||
| `triggerMode` | When to trigger action | See Trigger Modes below |
|
||||
| `shutdownDelay` | Delay before executing (seconds) | Default: 5 |
|
||||
|
||||
**Webhook-Specific Fields:**
|
||||
|
||||
| Field | Description | Values |
|
||||
| ---------------- | -------------------------- | ---------------- |
|
||||
| `webhookUrl` | URL to call | HTTP/HTTPS URL |
|
||||
| `webhookMethod` | HTTP method | 'POST' or 'GET' |
|
||||
| `webhookTimeout` | Request timeout in ms | Default: 10000 |
|
||||
|
||||
**Script-Specific Fields:**
|
||||
|
||||
| Field | Description | Values |
|
||||
| --------------- | ---------------------------------- | ----------------------- |
|
||||
| `scriptPath` | Script filename in `/etc/nupst/` | Must end with `.sh` |
|
||||
| `scriptTimeout` | Execution timeout in ms | Default: 60000 |
|
||||
|
||||
**Trigger Modes:**
|
||||
|
||||
| Mode | Description |
|
||||
@@ -488,7 +517,7 @@ Groups allow coordinated management of multiple UPS devices:
|
||||
- **`nonRedundant`**: System shuts down when ANY UPS device in the group is critical. Used when all
|
||||
UPS devices must be operational.
|
||||
|
||||
#### HTTP Server Configuration 🆕
|
||||
#### HTTP Server Configuration
|
||||
|
||||
Enable optional HTTP server for JSON status export with authentication:
|
||||
|
||||
@@ -816,7 +845,7 @@ When installed, NUPST makes the following changes:
|
||||
|
||||
## 🚀 Migration from v3.x
|
||||
|
||||
Upgrading from NUPST v3.x (Node.js) to v4.x (Deno) is seamless:
|
||||
Upgrading from NUPST v3.x (Node.js) to v4.x+ (Deno) is seamless:
|
||||
|
||||
```bash
|
||||
# One command to migrate everything
|
||||
@@ -828,12 +857,12 @@ curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh |
|
||||
- Detects v3.x installation
|
||||
- Stops the service
|
||||
- Replaces Node.js version with Deno binary
|
||||
- Migrates configuration (v4.0 → v4.1 format if needed)
|
||||
- Migrates configuration (v4.0 → v4.2 format if needed)
|
||||
- Restarts the service
|
||||
|
||||
### Key Changes in v4.x
|
||||
### Key Changes in v4.x+
|
||||
|
||||
| Aspect | v3.x | v4.x |
|
||||
| Aspect | v3.x | v4.x+ |
|
||||
| ------------------------ | -------------------------- | ----------------------------- |
|
||||
| **Runtime** | Node.js + npm | Deno |
|
||||
| **Distribution** | Git repo + npm install | Pre-compiled binaries |
|
||||
@@ -845,38 +874,7 @@ curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh |
|
||||
|
||||
### Configuration Compatibility
|
||||
|
||||
Your v3.x configuration is **fully compatible**. The migration system automatically converts:
|
||||
|
||||
**v4.0 format** (UPS-level thresholds):
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "4.0",
|
||||
"upsDevices": [{
|
||||
"id": "ups-1",
|
||||
"thresholds": { "battery": 60, "runtime": 20 }
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
**v4.1 format** (action-based thresholds):
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "4.1",
|
||||
"upsDevices": [{
|
||||
"id": "ups-1",
|
||||
"actions": [{
|
||||
"type": "shutdown",
|
||||
"thresholds": { "battery": 60, "runtime": 20 },
|
||||
"triggerMode": "onlyThresholds",
|
||||
"shutdownDelay": 5
|
||||
}]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
Migration happens automatically on first run—no manual changes needed.
|
||||
Your v3.x configuration is **fully compatible**. The migration system automatically converts older formats to the current version.
|
||||
|
||||
## 💻 Development
|
||||
|
||||
@@ -911,49 +909,39 @@ deno task compile
|
||||
nupst/
|
||||
├── mod.ts # Entry point
|
||||
├── ts/
|
||||
│ ├── cli.ts # CLI command routing
|
||||
│ ├── nupst.ts # Main coordinator class
|
||||
│ ├── daemon.ts # Background monitoring daemon
|
||||
│ ├── systemd.ts # Systemd service management
|
||||
│ ├── snmp/ # SNMP implementation
|
||||
│ ├── actions/ # Action system
|
||||
│ ├── migrations/ # Config migration system
|
||||
│ └── cli/ # CLI handlers
|
||||
├── test/ # Test files
|
||||
├── scripts/ # Build scripts
|
||||
└── deno.json # Deno configuration
|
||||
│ ├── cli.ts # CLI command routing
|
||||
│ ├── nupst.ts # Main coordinator class
|
||||
│ ├── daemon.ts # Background monitoring daemon
|
||||
│ ├── systemd.ts # Systemd service management
|
||||
│ ├── constants.ts # Centralized configuration constants
|
||||
│ ├── interfaces/ # TypeScript interfaces
|
||||
│ ├── snmp/ # SNMP implementation
|
||||
│ ├── actions/ # Action system (shutdown, webhook, script)
|
||||
│ ├── helpers/ # Utility functions
|
||||
│ ├── migrations/ # Config migration system
|
||||
│ └── cli/ # CLI handlers
|
||||
├── test/ # Test files
|
||||
├── scripts/ # Build scripts
|
||||
└── deno.json # Deno configuration
|
||||
```
|
||||
|
||||
## 📞 Support
|
||||
|
||||
- **Issues**: [Report bugs or request features](https://code.foss.global/serve.zone/nupst/issues)
|
||||
- **Documentation**: [Full documentation](https://code.foss.global/serve.zone/nupst)
|
||||
- **Source Code**: [View source](https://code.foss.global/serve.zone/nupst)
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT
|
||||
License can be found in the [license](license) file within this repository.
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the project, except as required for reasonable and customary use
|
||||
in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated
|
||||
with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture
|
||||
Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these
|
||||
trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be
|
||||
approved in writing by Task Venture Capital GmbH.
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
||||
|
||||
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH Registered at District court Bremen HRB 35230 HB, Germany
|
||||
Task Venture Capital GmbH
|
||||
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at
|
||||
hello@task.vc.
|
||||
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its
|
||||
terms, and understand that the licensing of the code does not imply endorsement by Task Venture
|
||||
Capital GmbH of any derivative works.
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
||||
Reference in New Issue
Block a user