ssh_alert_setup
Configure monitoring alerts for SSH servers by setting CPU, memory, and disk usage thresholds to detect performance issues.
Instructions
Configure health monitoring alerts and thresholds
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | Server name | |
| action | Yes | Action: set thresholds, get config, or check current metrics against thresholds | |
| cpuThreshold | No | CPU usage threshold percentage (e.g., 80) | |
| memoryThreshold | No | Memory usage threshold percentage (e.g., 90) | |
| diskThreshold | No | Disk usage threshold percentage (e.g., 85) | |
| enabled | No | Enable or disable alerts (default: true) |
Implementation Reference
- src/tool-registry.js:31-38 (registration)The 'ssh_alert_setup' tool is listed in the monitoring tool group in the centralized TOOL_GROUPS registry, used for conditional registration and validation of MCP tools based on user configuration.monitoring: [ 'ssh_health_check', 'ssh_service_status', 'ssh_process_manager', 'ssh_monitor', 'ssh_tail', 'ssh_alert_setup' ],
- src/health-monitor.js:278-353 (helper)Supporting utilities for alert setup including creating alert configurations with thresholds, commands to save/load alert config JSON on remote servers, and checking if current metrics exceed thresholds. These functions provide the core logic for implementing the ssh_alert_setup tool.*/ export function createAlertConfig(thresholds) { const defaults = { cpu: 80, memory: 90, disk: 85, enabled: true }; return { ...defaults, ...thresholds, created_at: new Date().toISOString() }; } /** * Build command to save alert config */ export function buildSaveAlertConfigCommand(config, configPath = '/etc/ssh-manager-alerts.json') { const jsonData = JSON.stringify(config, null, 2); const escapedJson = jsonData.replace(/'/g, '\'\\\'\''); return `echo '${escapedJson}' > "${configPath}"`; } /** * Build command to load alert config */ export function buildLoadAlertConfigCommand(configPath = '/etc/ssh-manager-alerts.json') { return `cat "${configPath}" 2>/dev/null || echo '{}'`; } /** * Check if thresholds are exceeded */ export function checkAlertThresholds(metrics, thresholds) { const alerts = []; if (thresholds.cpu && metrics.cpu && metrics.cpu.percent > thresholds.cpu) { alerts.push({ type: 'cpu', severity: 'warning', message: `CPU usage (${metrics.cpu.percent}%) exceeds threshold (${thresholds.cpu}%)`, value: metrics.cpu.percent, threshold: thresholds.cpu }); } if (thresholds.memory && metrics.memory && metrics.memory.percent > thresholds.memory) { alerts.push({ type: 'memory', severity: 'warning', message: `Memory usage (${metrics.memory.percent}%) exceeds threshold (${thresholds.memory}%)`, value: metrics.memory.percent, threshold: thresholds.memory }); } if (thresholds.disk && metrics.disks) { for (const disk of metrics.disks) { if (disk.percent > thresholds.disk) { alerts.push({ type: 'disk', severity: 'warning', message: `Disk usage on ${disk.mount} (${disk.percent}%) exceeds threshold (${thresholds.disk}%)`, mount: disk.mount, value: disk.percent, threshold: thresholds.disk }); } } } return alerts; }