Add push monitor script deployment via SSH
All checks were successful
Build and Push Container / build (push) Successful in 33s
All checks were successful
Build and Push Container / build (push) Successful in 33s
- Add push_scripts.py with bash templates for heartbeat, disk, memory, cpu, and updates monitoring
- Modify kuma_client.py to return push token from created monitors
- Add deploy_push_script() to monitors.py for SSH-based script deployment
- Add heartbeat push_metric type to Claude agent suggestions
- Add /api/monitors/<id>/deploy-script and /api/monitors/deploy-all-scripts endpoints
- Update frontend to show push monitors with deployment status and retry buttons
Scripts are deployed to /usr/local/bin/kuma-push-{metric}-{id}.sh with cron entries.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -223,10 +223,21 @@ class UptimeKumaClient:
|
||||
if monitor.docker_host:
|
||||
kwargs["docker_host"] = monitor.docker_host
|
||||
elif monitor.type == "push":
|
||||
# Push monitors are created and get a token back
|
||||
# Push monitors don't need additional fields
|
||||
# The push token is returned in the result
|
||||
pass
|
||||
|
||||
# Add conditions field for Uptime Kuma v2 compatibility
|
||||
kwargs["conditions"] = []
|
||||
|
||||
result = api.add_monitor(**kwargs)
|
||||
|
||||
# For push monitors, extract the push token from the result
|
||||
if monitor.type == "push" and "monitorID" in result:
|
||||
monitor_data = api.get_monitor(result["monitorID"])
|
||||
if "pushToken" in monitor_data:
|
||||
result["pushToken"] = monitor_data["pushToken"]
|
||||
|
||||
return result
|
||||
except Exception as e:
|
||||
self._disconnect()
|
||||
@@ -272,6 +283,32 @@ class UptimeKumaClient:
|
||||
self._disconnect()
|
||||
return False
|
||||
|
||||
def get_push_url(self, push_token: str) -> str:
|
||||
"""Build the full push URL for a push monitor.
|
||||
|
||||
Args:
|
||||
push_token: The push token from the monitor
|
||||
|
||||
Returns:
|
||||
Full push URL like 'https://kuma.example.com/api/push/abc123'
|
||||
"""
|
||||
return f"{self.base_url}/api/push/{push_token}"
|
||||
|
||||
def get_monitor_push_token(self, monitor_id: int) -> Optional[str]:
|
||||
"""Get the push token for an existing push monitor.
|
||||
|
||||
Args:
|
||||
monitor_id: The Uptime Kuma monitor ID
|
||||
|
||||
Returns:
|
||||
The push token, or None if not a push monitor or not found
|
||||
"""
|
||||
try:
|
||||
monitor_data = self.get_monitor(monitor_id)
|
||||
return monitor_data.get("pushToken")
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
# Global client instance
|
||||
_kuma_client: Optional[UptimeKumaClient] = None
|
||||
|
||||
Reference in New Issue
Block a user