Files
bvandeusen 35f658b573
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 8s
CI / integration (push) Successful in 2m17s
CI / publish (push) Successful in 1m10s
feat(monitors): unify ping/dns/http into one Monitor entity + custom targets
Collapse the three former check types into a single core `Monitor` entity
with one management surface (/monitors), one result table (monitor_results),
and a single scheduled task. Every type can now watch a free-standing custom
destination (optional host_id) — not just a registered Host.

- models: Monitor + MonitorResult replace PingResult/DnsResult; Host loses its
  ping/dns facet columns (now Monitor rows linked by host_id).
- checks: monitors/{ping,dns,http}.py pure probes + runner.run_monitor
  dispatcher; one monitor_check scheduler with a per-monitor due-filter.
- status: single monitor_status_source replaces the three sources.
- UI: /monitors blueprint (type-aware add/edit/list/widget); host hub shows a
  host's linked monitors + "add monitor for this host"; nav + widget registry
  + alert metric catalog rewired. http plugin folded into core and removed.
- migration 0022 merges the http branch, data-migrates host facets +
  http_monitors + all three result histories, drops the old tables/columns.

Resolves the per-host ping/dns auto-attach issue (#275): monitors are now
explicit, never auto-added to every host.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
2026-06-18 08:56:13 -04:00

65 lines
3.0 KiB
HTML

{# Shared type-specific monitor form fields. Every field is rendered; a tiny
script (mtoggle) shows only the ones relevant to the selected type. #}
{% macro type_fields(config={}) %}
{% set inp = "width:100%;padding:0.4rem 0.65rem;background:var(--bg);border:1px solid var(--border-mid);border-radius:4px;color:var(--text);font-size:0.88rem;" %}
{% set lbl = "font-size:0.75rem;color:var(--text-muted);display:block;margin-bottom:0.2rem;" %}
{# tcp #}
<div class="mfield" data-types="tcp">
<label style="{{ lbl }}">Port</label>
<input type="number" name="port" value="{{ config.get('port', 80) }}" min="1" max="65535" style="{{ inp }}">
</div>
{# dns #}
<div class="mfield" data-types="dns">
<label style="{{ lbl }}">Expected IP <span style="color:var(--text-dim);">(optional)</span></label>
<input type="text" name="expected_ip" value="{{ config.get('expected_ip') or '' }}"
placeholder="e.g. 192.0.2.10" autocomplete="off" style="{{ inp }}">
</div>
{# http #}
<div class="mfield" data-types="http">
<label style="{{ lbl }}">Method</label>
<select name="method" style="{{ inp }}">
{% for opt in ["GET", "HEAD", "POST"] %}
<option value="{{ opt }}" {% if config.get('method', 'GET') == opt %}selected{% endif %}>{{ opt }}</option>
{% endfor %}
</select>
</div>
<div class="mfield" data-types="http">
<label style="{{ lbl }}">Expected status</label>
<input type="number" name="expected_status" value="{{ config.get('expected_status', 200) }}"
min="100" max="599" style="{{ inp }}">
</div>
<div class="mfield" data-types="http">
<label style="{{ lbl }}">Timeout (s)</label>
<input type="number" name="timeout_seconds" value="{{ config.get('timeout_seconds', 10) }}"
min="1" max="60" style="{{ inp }}">
</div>
<div class="mfield" data-types="http">
<label style="{{ lbl }}">Content match <span style="color:var(--text-dim);">(substring)</span></label>
<input type="text" name="content_match" value="{{ config.get('content_match', '') }}"
placeholder="optional" autocomplete="off" style="{{ inp }}">
</div>
<div class="mfield" data-types="http" style="display:flex;flex-direction:column;gap:0.3rem;justify-content:flex-end;">
<label style="display:flex;align-items:center;gap:0.4rem;font-size:0.82rem;cursor:pointer;">
<input type="checkbox" name="follow_redirects" {% if config.get('follow_redirects', True) %}checked{% endif %}> Follow redirects
</label>
<label style="display:flex;align-items:center;gap:0.4rem;font-size:0.82rem;cursor:pointer;">
<input type="checkbox" name="verify_ssl" {% if config.get('verify_ssl', True) %}checked{% endif %}> Verify SSL
</label>
</div>
{% endmacro %}
{# Show only the fields whose data-types matches the active monitor type. #}
{% macro toggle_script() %}
<script>
function mtoggle(t) {
document.querySelectorAll('.mfield').forEach(function (el) {
var types = (el.getAttribute('data-types') || '').split(',');
el.style.display = types.indexOf(t) !== -1 ? '' : 'none';
});
}
</script>
{% endmacro %}