feat: protocol monitors in the editor and API docs
ci / image (pull_request) Successful in 2m57s
ci / build (pull_request) Successful in 8m16s
ci / lint (pull_request) Canceled after 12m11s
ci / test (pull_request) Canceled after 12m0s

Editor fields and translations for gRPC, SMTP, RADIUS and SNMP; the
RADIUS secret and password and the SNMP community are sealed like other
monitor secrets.

Closes #95

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 16:51:23 +01:00
1 parent 03f6e9137f
commit 365152d164
9 files changed
+1295 -806

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ var endpoints = []endpoint{
description: "Only monitors the caller may read; header values and heartbeat tokens only for those who may change the monitor.", description: "Only monitors the caller may read; header values and heartbeat tokens only for those who may change the monitor.",
perm: "monitors.read", resp: obj{"monitors": []monitorView{}}}, perm: "monitors.read", resp: obj{"monitors": []monitorView{}}},
{method: "POST", path: "/api/v1/org/monitors", tag: "Monitors", summary: "Create a monitor", {method: "POST", path: "/api/v1/org/monitors", tag: "Monitors", summary: "Create a monitor",
description: "`type` is one of http, json, prometheus, tcp, tls, dns, icmp, postgres, mysql, mssql, mongodb, redis, mqtt, kafka, rabbitmq, heartbeat or alertmanager (GET /api/v1/org/check-types lists those offered); `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, DBConfig, BrokerConfig, HeartbeatConfig, AlertmanagerConfig). Passwords are stored encrypted and never returned: `secrets_set` names those set, and an update that leaves one empty keeps it. Heartbeat and alertmanager monitors take neither target nor regions; heartbeats return their `ping_url`.", description: "`type` is one of http, json, prometheus, tcp, tls, dns, icmp, postgres, mysql, mssql, mongodb, redis, mqtt, kafka, rabbitmq, grpc, smtp, radius, snmp, heartbeat or alertmanager (GET /api/v1/org/check-types lists those offered); `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, DBConfig, BrokerConfig, GRPCConfig, SMTPConfig, RADIUSConfig, SNMPConfig, HeartbeatConfig, AlertmanagerConfig). Passwords, RADIUS secrets and SNMP communities are stored encrypted and never returned: `secrets_set` names those set, and an update that leaves one empty keeps it. Heartbeat and alertmanager monitors take neither target nor regions; heartbeats return their `ping_url`.",
perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}}, perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}},
{method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write", {method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write",
req: monitorRequest{}, resp: monitorView{}}, req: monitorRequest{}, resp: monitorView{}},
+18
View File
@@ -633,6 +633,24 @@ func fillForm(f *web.MonitorForm, m store.Monitor) {
User: c.User, TLS: c.TLS, Topic: c.Topic, Expect: c.Expect, Message: c.Message, SASL: c.SASL, User: c.User, TLS: c.TLS, Topic: c.Topic, Expect: c.Expect, Message: c.Message, SASL: c.SASL,
Vhost: c.Vhost, Queue: c.Queue, PasswordSet: slices.Contains(secrets, "password"), Vhost: c.Vhost, Queue: c.Queue, PasswordSet: slices.Contains(secrets, "password"),
} }
case check.GRPC, check.SMTP, check.RADIUS, check.SNMP:
cfg, secrets := publicMonitorConfig(m.Config)
var (
g check.GRPCConfig
sm check.SMTPConfig
r check.RADIUSConfig
sn check.SNMPConfig
)
_ = json.Unmarshal(cfg, &g)
_ = json.Unmarshal(cfg, &sm)
_ = json.Unmarshal(cfg, &r)
_ = json.Unmarshal(cfg, &sn)
f.Proto = web.ProtocolForm{
Service: g.Service, TLS: g.TLS, ImplicitTLS: sm.ImplicitTLS,
User: r.User, NASIdentifier: r.NASIdentifier,
SecretSet: slices.Contains(secrets, "secret"), PasswordSet: slices.Contains(secrets, "password"), CommunitySet: slices.Contains(secrets, "community"),
Version: sn.Version, OID: sn.OID, Condition: sn.Condition, Value: sn.Value,
}
case check.Alertmanager: case check.Alertmanager:
var c check.AlertmanagerConfig var c check.AlertmanagerConfig
_ = json.Unmarshal(m.Config, &c) _ = json.Unmarshal(m.Config, &c)
+31
View File
@@ -71,3 +71,34 @@ func TestDatabaseMonitorSecrets(t *testing.T) {
} }
} }
} }
func TestProtocolMonitorSecrets(t *testing.T) {
e := newEnv(t)
_, region := e.platformChecker(t, uniq("eu-"))
owner := e.browser(t)
owner.signup("o@"+uniq("proto")+".test", uniq("proto-"))
for _, tc := range []struct {
typ, target string
config map[string]any
secrets string
}{
{"radius", "radius.example.com:1812", map[string]any{"secret": "radius-shared-1", "user": "probe", "password": "radius-pw-1"}, `["password","secret"]`},
{"snmp", "switch.example.com:161", map[string]any{"community": "snmp-comm-1", "oid": "1.3.6.1.2.1.1.5.0"}, `["community"]`},
} {
st, body := owner.do("POST", "/api/v1/org/monitors", map[string]any{
"name": tc.typ, "type": tc.typ, "target": tc.target, "interval_seconds": 60, "regions": []string{region}, "config": tc.config,
})
if st != http.StatusCreated || mustJSON(body["secrets_set"]) != tc.secrets {
t.Fatalf("create %s = %d %s", tc.typ, st, mustJSON(body))
}
_, _, page := owner.page("/monitors/" + body["id"].(string) + "/edit")
for _, v := range tc.config {
if s := v.(string); strings.Contains(s, "-1") && (strings.Contains(page, s) || strings.Contains(mustJSON(body), s)) {
t.Errorf("%s: secret %q leaves the server", tc.typ, s)
}
}
if !strings.Contains(page, `name="config.`) {
t.Errorf("%s: editor lacks the settings", tc.typ)
}
}
}
+1 -1
View File
@@ -236,7 +236,7 @@ func buildOpenAPI(publicURL string) map[string]any {
}, },
} }
// Monitor settings travel as untyped config; their shapes per type. // Monitor settings travel as untyped config; their shapes per type.
for _, c := range []any{check.HTTPConfig{}, check.JSONConfig{}, check.PrometheusConfig{}, check.DNSConfig{}, check.TLSConfig{}, check.DBConfig{}, check.BrokerConfig{}, check.HeartbeatConfig{}, check.AlertmanagerConfig{}} { for _, c := range []any{check.HTTPConfig{}, check.JSONConfig{}, check.PrometheusConfig{}, check.DNSConfig{}, check.TLSConfig{}, check.DBConfig{}, check.BrokerConfig{}, check.GRPCConfig{}, check.SMTPConfig{}, check.RADIUSConfig{}, check.SNMPConfig{}, check.HeartbeatConfig{}, check.AlertmanagerConfig{}} {
b.schema(reflect.TypeOf(c)) b.schema(reflect.TypeOf(c))
} }
paths := map[string]map[string]any{} paths := map[string]map[string]any{}
+2 -1
View File
@@ -152,7 +152,7 @@ func TestDynamicFamilies(t *testing.T) {
en := catalogKeys(t)["en"] en := catalogKeys(t)["en"]
families := map[string][]string{ families := map[string][]string{
"status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"}, "status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"},
"monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "postgres", "mysql", "mssql", "mongodb", "redis", "mqtt", "kafka", "rabbitmq", "heartbeat", "alertmanager"}, "monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "postgres", "mysql", "mssql", "mongodb", "redis", "mqtt", "kafka", "rabbitmq", "grpc", "smtp", "radius", "snmp", "heartbeat", "alertmanager"},
"channels.type_": {"webhook", "email", "slack", "discord", "teams", "googlechat", "mattermost", "rocketchat", "telegram", "matrix", "ntfy", "gotify", "pushover", "pushbullet", "signal", "pagerduty", "opsgenie", "apprise"}, "channels.type_": {"webhook", "email", "slack", "discord", "teams", "googlechat", "mattermost", "rocketchat", "telegram", "matrix", "ntfy", "gotify", "pushover", "pushbullet", "signal", "pagerduty", "opsgenie", "apprise"},
"agents.kind_": {"checker", "statuspage"}, "agents.kind_": {"checker", "statuspage"},
"page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"}, "page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"},
@@ -165,6 +165,7 @@ func TestDynamicFamilies(t *testing.T) {
"channels.field_": {"webhook_url", "channel", "bot_token", "chat_id", "thread_id", "api_url", "homeserver_url", "access_token", "room_id", "server_url", "topic", "priority", "app_token", "user_key", "device", "number", "recipients", "routing_key", "severity", "api_key", "region", "urls", "config_key"}, "channels.field_": {"webhook_url", "channel", "bot_token", "chat_id", "thread_id", "api_url", "homeserver_url", "access_token", "room_id", "server_url", "topic", "priority", "app_token", "user_key", "device", "number", "recipients", "routing_key", "severity", "api_key", "region", "urls", "config_key"},
"monitors.db_database_": {"postgres", "mysql", "mssql", "mongodb", "redis"}, "monitors.db_database_": {"postgres", "mysql", "mssql", "mongodb", "redis"},
"monitors.broker_hint_": {"mqtt", "kafka", "rabbitmq"}, "monitors.broker_hint_": {"mqtt", "kafka", "rabbitmq"},
"monitors.snmp_cond_": {"any", "eq", "ne", "contains", "gt", "ge", "lt", "le"},
"monitors.db_tls_": {"require", "verify", "disable"}, "monitors.db_tls_": {"require", "verify", "disable"},
"weekday.": {"0", "1", "2", "3", "4", "5", "6"}, "weekday.": {"0", "1", "2", "3", "4", "5", "6"},
"md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"}, "md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"},
+25
View File
@@ -614,6 +614,8 @@
"monitors.follow_redirects": "Weiterleitungen folgen", "monitors.follow_redirects": "Weiterleitungen folgen",
"monitors.grace": "Toleranz (Sekunden)", "monitors.grace": "Toleranz (Sekunden)",
"monitors.grace_hint": "Wie spät ein Ping sein darf, für Jobs, die manchmal länger laufen.", "monitors.grace_hint": "Wie spät ein Ping sein darf, für Jobs, die manchmal länger laufen.",
"monitors.grpc_hint": "Ziel ist host:port. Fragt den Standard-Health-Service von gRPC (grpc.health.v1); die Antwort muss SERVING sein.",
"monitors.grpc_service": "Service (optional, leer = ganzer Server)",
"monitors.headers": "Request-Header", "monitors.headers": "Request-Header",
"monitors.headers_hint": "Einer pro Zeile, „Name: Wert“. Nur Mitglieder, die den Monitor bearbeiten dürfen, sehen die Werte.", "monitors.headers_hint": "Einer pro Zeile, „Name: Wert“. Nur Mitglieder, die den Monitor bearbeiten dürfen, sehen die Werte.",
"monitors.heartbeat_hint": "Dein Job ruft bei jedem Lauf eine geheime URL auf. Kommt innerhalb von Intervall plus Toleranz kein Aufruf, gilt der Monitor als ausgefallen. Die URL wird nach dem Speichern angezeigt.", "monitors.heartbeat_hint": "Dein Job ruft bei jedem Lauf eine geheime URL auf. Kommt innerhalb von Intervall plus Toleranz kein Aufruf, gilt der Monitor als ausgefallen. Die URL wird nach dem Speichern angezeigt.",
@@ -649,6 +651,9 @@
"monitors.prom_mode_any": "Eine Serie mit erfüllter Bedingung genügt", "monitors.prom_mode_any": "Eine Serie mit erfüllter Bedingung genügt",
"monitors.prom_query": "PromQL-Abfrage", "monitors.prom_query": "PromQL-Abfrage",
"monitors.prom_threshold": "Schwellwert", "monitors.prom_threshold": "Schwellwert",
"monitors.radius_hint": "Ziel ist host:port (meist 1812). Sendet einen Access-Request mit diesen Zugangsdaten; Access-Accept gilt als erreichbar.",
"monitors.radius_nas": "NAS-Identifier (optional)",
"monitors.radius_secret": "Gemeinsames Geheimnis",
"monitors.range": "Zeitraum", "monitors.range": "Zeitraum",
"monitors.range_not_enough": "Für weniger als die Hälfte dieses Zeitraums liegen bisher Daten vor.", "monitors.range_not_enough": "Für weniger als die Hälfte dieses Zeitraums liegen bisher Daten vor.",
"monitors.range_note": "SLA und Balken: letzte {{.Range}}", "monitors.range_note": "SLA und Balken: letzte {{.Range}}",
@@ -658,6 +663,22 @@
"monitors.secret_unchanged": "unverändert", "monitors.secret_unchanged": "unverändert",
"monitors.sla": "SLA", "monitors.sla": "SLA",
"monitors.sla_table": "SLA nach Zeitraum", "monitors.sla_table": "SLA nach Zeitraum",
"monitors.smtp_hint": "Ziel ist host:port (25, 587 oder 465). Wartet auf die Begrüßung und sendet EHLO; mit Verschlüsselung muss STARTTLS gelingen.",
"monitors.smtp_implicit_tls": "Von Anfang an verschlüsselt (SMTPS, Port 465)",
"monitors.snmp_community": "Community (leer = public)",
"monitors.snmp_cond_any": "beliebiger Wert",
"monitors.snmp_cond_contains": "enthält",
"monitors.snmp_cond_eq": "gleich",
"monitors.snmp_cond_ge": "mindestens",
"monitors.snmp_cond_gt": "größer als",
"monitors.snmp_cond_le": "höchstens",
"monitors.snmp_cond_lt": "kleiner als",
"monitors.snmp_cond_ne": "ungleich",
"monitors.snmp_condition": "Bedingung",
"monitors.snmp_hint": "Ziel ist host:port (meist 161). Liest eine OID per SNMP v1 oder v2c und kann ihren Wert vergleichen.",
"monitors.snmp_oid": "OID",
"monitors.snmp_value": "Wert",
"monitors.snmp_version": "Version",
"monitors.stale_hours": "Verfällt nach (Stunden)", "monitors.stale_hours": "Verfällt nach (Stunden)",
"monitors.stale_hours_hint": "Ein feuernder Alert, den Alertmanager nicht mehr wiederholt, gilt nach dieser Zeit als beendet. Halte sie über repeat_interval.", "monitors.stale_hours_hint": "Ein feuernder Alert, den Alertmanager nicht mehr wiederholt, gilt nach dieser Zeit als beendet. Halte sie über repeat_interval.",
"monitors.target": "Ziel", "monitors.target": "Ziel",
@@ -668,6 +689,7 @@
"monitors.type": "Check-Typ", "monitors.type": "Check-Typ",
"monitors.type_alertmanager": "Alertmanager", "monitors.type_alertmanager": "Alertmanager",
"monitors.type_dns": "DNS", "monitors.type_dns": "DNS",
"monitors.type_grpc": "gRPC",
"monitors.type_heartbeat": "Heartbeat", "monitors.type_heartbeat": "Heartbeat",
"monitors.type_http": "HTTP(S)", "monitors.type_http": "HTTP(S)",
"monitors.type_icmp": "Ping (ICMP)", "monitors.type_icmp": "Ping (ICMP)",
@@ -680,7 +702,10 @@
"monitors.type_postgres": "PostgreSQL", "monitors.type_postgres": "PostgreSQL",
"monitors.type_prometheus": "Prometheus", "monitors.type_prometheus": "Prometheus",
"monitors.type_rabbitmq": "RabbitMQ", "monitors.type_rabbitmq": "RabbitMQ",
"monitors.type_radius": "RADIUS",
"monitors.type_redis": "Redis", "monitors.type_redis": "Redis",
"monitors.type_smtp": "SMTP",
"monitors.type_snmp": "SNMP",
"monitors.type_tcp": "TCP-Port", "monitors.type_tcp": "TCP-Port",
"monitors.type_tls": "TLS-Zertifikat", "monitors.type_tls": "TLS-Zertifikat",
"monitors.uptime_chart": "Uptime pro Zeitraum", "monitors.uptime_chart": "Uptime pro Zeitraum",
+25
View File
@@ -614,6 +614,8 @@
"monitors.follow_redirects": "Follow redirects", "monitors.follow_redirects": "Follow redirects",
"monitors.grace": "Grace period (seconds)", "monitors.grace": "Grace period (seconds)",
"monitors.grace_hint": "How late a ping may be, for jobs that sometimes run longer.", "monitors.grace_hint": "How late a ping may be, for jobs that sometimes run longer.",
"monitors.grpc_hint": "Target is host:port. Asks the standard gRPC health service (grpc.health.v1); the answer must be SERVING.",
"monitors.grpc_service": "Service (optional, empty = whole server)",
"monitors.headers": "Request headers", "monitors.headers": "Request headers",
"monitors.headers_hint": "One per line, \"Name: value\". Only members who may edit the monitor see the values.", "monitors.headers_hint": "One per line, \"Name: value\". Only members who may edit the monitor see the values.",
"monitors.heartbeat_hint": "Your job calls a secret URL each time it runs. If no call arrives within the interval plus the grace period, the monitor is down. The URL is shown after saving.", "monitors.heartbeat_hint": "Your job calls a secret URL each time it runs. If no call arrives within the interval plus the grace period, the monitor is down. The URL is shown after saving.",
@@ -649,6 +651,9 @@
"monitors.prom_mode_any": "One series meeting the condition is enough", "monitors.prom_mode_any": "One series meeting the condition is enough",
"monitors.prom_query": "PromQL query", "monitors.prom_query": "PromQL query",
"monitors.prom_threshold": "Threshold", "monitors.prom_threshold": "Threshold",
"monitors.radius_hint": "Target is host:port (usually 1812). Sends an Access-Request with these credentials; Access-Accept counts as up.",
"monitors.radius_nas": "NAS identifier (optional)",
"monitors.radius_secret": "Shared secret",
"monitors.range": "Time range", "monitors.range": "Time range",
"monitors.range_not_enough": "Less than half of this period is covered by data yet.", "monitors.range_not_enough": "Less than half of this period is covered by data yet.",
"monitors.range_note": "SLA and bars: last {{.Range}}", "monitors.range_note": "SLA and bars: last {{.Range}}",
@@ -658,6 +663,22 @@
"monitors.secret_unchanged": "unchanged", "monitors.secret_unchanged": "unchanged",
"monitors.sla": "SLA", "monitors.sla": "SLA",
"monitors.sla_table": "SLA by period", "monitors.sla_table": "SLA by period",
"monitors.smtp_hint": "Target is host:port (25, 587 or 465). Waits for the greeting and says EHLO; with encryption, STARTTLS must succeed.",
"monitors.smtp_implicit_tls": "Encrypted from the start (SMTPS, port 465)",
"monitors.snmp_community": "Community (empty = public)",
"monitors.snmp_cond_any": "any value",
"monitors.snmp_cond_contains": "contains",
"monitors.snmp_cond_eq": "equals",
"monitors.snmp_cond_ge": "at least",
"monitors.snmp_cond_gt": "greater than",
"monitors.snmp_cond_le": "at most",
"monitors.snmp_cond_lt": "less than",
"monitors.snmp_cond_ne": "not equal",
"monitors.snmp_condition": "Condition",
"monitors.snmp_hint": "Target is host:port (usually 161). Reads one OID over SNMP v1 or v2c and can compare its value.",
"monitors.snmp_oid": "OID",
"monitors.snmp_value": "Value",
"monitors.snmp_version": "Version",
"monitors.stale_hours": "Stale after (hours)", "monitors.stale_hours": "Stale after (hours)",
"monitors.stale_hours_hint": "A firing alert Alertmanager stops repeating counts as over after this time. Keep it above repeat_interval.", "monitors.stale_hours_hint": "A firing alert Alertmanager stops repeating counts as over after this time. Keep it above repeat_interval.",
"monitors.target": "Target", "monitors.target": "Target",
@@ -668,6 +689,7 @@
"monitors.type": "Check type", "monitors.type": "Check type",
"monitors.type_alertmanager": "Alertmanager", "monitors.type_alertmanager": "Alertmanager",
"monitors.type_dns": "DNS", "monitors.type_dns": "DNS",
"monitors.type_grpc": "gRPC",
"monitors.type_heartbeat": "Heartbeat", "monitors.type_heartbeat": "Heartbeat",
"monitors.type_http": "HTTP(S)", "monitors.type_http": "HTTP(S)",
"monitors.type_icmp": "Ping (ICMP)", "monitors.type_icmp": "Ping (ICMP)",
@@ -680,7 +702,10 @@
"monitors.type_postgres": "PostgreSQL", "monitors.type_postgres": "PostgreSQL",
"monitors.type_prometheus": "Prometheus", "monitors.type_prometheus": "Prometheus",
"monitors.type_rabbitmq": "RabbitMQ", "monitors.type_rabbitmq": "RabbitMQ",
"monitors.type_radius": "RADIUS",
"monitors.type_redis": "Redis", "monitors.type_redis": "Redis",
"monitors.type_smtp": "SMTP",
"monitors.type_snmp": "SNMP",
"monitors.type_tcp": "TCP port", "monitors.type_tcp": "TCP port",
"monitors.type_tls": "TLS certificate", "monitors.type_tls": "TLS certificate",
"monitors.uptime_chart": "Uptime per period", "monitors.uptime_chart": "Uptime per period",
+60
View File
@@ -493,6 +493,7 @@ type MonitorForm struct {
StaleHours int StaleHours int
DB DBForm DB DBForm
Broker BrokerForm Broker BrokerForm
Proto ProtocolForm
// Types are the check types to offer. // Types are the check types to offer.
Types []string Types []string
} }
@@ -503,6 +504,17 @@ type BrokerForm struct {
PasswordSet bool PasswordSet bool
} }
// ProtocolForm holds the settings of gRPC, SMTP, RADIUS and SNMP checks.
// Secrets are never filled in; the *Set fields tell the form one is
// stored.
type ProtocolForm struct {
Service, TLS string
ImplicitTLS bool
User, NASIdentifier string
SecretSet, PasswordSet, CommunitySet bool
Version, OID, Condition, Value string
}
// DBForm holds the settings of database checks. The password is never // DBForm holds the settings of database checks. The password is never
// filled in; PasswordSet tells the form one is stored. // filled in; PasswordSet tells the form one is stored.
type DBForm struct { type DBForm struct {
@@ -616,6 +628,47 @@ templ MonitorEditor(p Page, me Me, f MonitorForm) {
@brokerFields(t, f.Broker) @brokerFields(t, f.Broker)
} }
} }
@typeFields("grpc", f.Type) {
<p class="mb-4 text-xs text-muted">{ i18n.T(ctx, "monitors.grpc_hint") }</p>
@valueField(i18n.T(ctx, "monitors.grpc_service"), "config.service", f.Proto.Service, "shop.v1.Orders", false)
@tlsField(f.Proto.TLS, "verify", "require", "disable")
}
@typeFields("smtp", f.Type) {
<p class="mb-4 text-xs text-muted">{ i18n.T(ctx, "monitors.smtp_hint") }</p>
@tlsField(f.Proto.TLS, "verify", "require", "disable")
@checkbox(i18n.T(ctx, "monitors.smtp_implicit_tls"), "config.implicit_tls", f.Proto.ImplicitTLS)
}
@typeFields("radius", f.Type) {
<p class="mb-4 text-xs text-muted">{ i18n.T(ctx, "monitors.radius_hint") }</p>
@secretField(i18n.T(ctx, "monitors.radius_secret"), "config.secret", f.Proto.SecretSet)
@valueField(i18n.T(ctx, "monitors.db_user"), "config.user", f.Proto.User, "", false)
@secretField(i18n.T(ctx, "monitors.db_password"), "config.password", f.Proto.PasswordSet)
@valueField(i18n.T(ctx, "monitors.radius_nas"), "config.nas_identifier", f.Proto.NASIdentifier, "uptimesebi", false)
}
@typeFields("snmp", f.Type) {
<p class="mb-4 text-xs text-muted">{ i18n.T(ctx, "monitors.snmp_hint") }</p>
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.snmp_version") }</span>
<select name="config.version" class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
for _, v := range []string{"2c", "1"} {
<option value={ v } selected?={ v == f.Proto.Version }>{ "v" + v }</option>
}
</select>
</label>
@secretField(i18n.T(ctx, "monitors.snmp_community"), "config.community", f.Proto.CommunitySet)
@valueField(i18n.T(ctx, "monitors.snmp_oid"), "config.oid", f.Proto.OID, "1.3.6.1.2.1.1.3.0", false)
<div class="grid grid-cols-[auto_1fr] gap-3">
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "monitors.snmp_condition") }</span>
<select name="config.condition" class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
for _, c := range []string{"", "eq", "ne", "contains", "gt", "ge", "lt", "le"} {
<option value={ c } selected?={ c == f.Proto.Condition }>{ i18n.T(ctx, "monitors.snmp_cond_"+condKey(c)) }</option>
}
</select>
</label>
@valueField(i18n.T(ctx, "monitors.snmp_value"), "config.value", f.Proto.Value, "", false)
</div>
}
@typeFields("alertmanager", f.Type) { @typeFields("alertmanager", f.Type) {
<p class="mb-4 text-xs text-muted"> <p class="mb-4 text-xs text-muted">
{ i18n.T(ctx, "monitors.alertmanager_hint") } { i18n.T(ctx, "monitors.alertmanager_hint") }
@@ -1144,3 +1197,10 @@ templ brokerFields(typ string, b BrokerForm) {
@valueField(i18n.T(ctx, "monitors.broker_queue"), "config.queue", b.Queue, "", false) @valueField(i18n.T(ctx, "monitors.broker_queue"), "config.queue", b.Queue, "", false)
} }
} }
func condKey(c string) string {
if c == "" {
return "any"
}
return c
}
File diff suppressed because it is too large. Load diff