aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-19 16:59:59 -0800
committerFuwn <[email protected]>2026-01-19 16:59:59 -0800
commit697fc99d8e340ea44c73c5bb046cad09d759c4c3 (patch)
tree401c75aa8539fee5f94684f50a7f723f1a62079e
parentfeat: Add group defaults, content checking, SSL tracking for Gemini, hide/rou... (diff)
downloadkaze-697fc99d8e340ea44c73c5bb046cad09d759c4c3.tar.xz
kaze-697fc99d8e340ea44c73c5bb046cad09d759c4c3.zip
feat: Add round_uptime option to round uptime percentages
-rw-r--r--config.example.yaml2
-rw-r--r--internal/config/config.go1
-rw-r--r--internal/monitor/gemini.go7
-rw-r--r--internal/monitor/http.go7
-rw-r--r--internal/monitor/monitor.go3
-rw-r--r--internal/monitor/tcp.go7
6 files changed, 27 insertions, 0 deletions
diff --git a/config.example.yaml b/config.example.yaml
index 71c7e0c..32229d0 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -75,6 +75,7 @@ groups:
verify_ssl: true
# hide_ssl_days: false # Hide SSL certificate days left from display
# round_response_time: false # Round response time to nearest second
+ # round_uptime: false # Round uptime percentage (e.g., 99.99% → 100%)
- name: "API"
type: https
@@ -162,6 +163,7 @@ incidents:
# Automatically flips to false after reset completes
# hide_ssl_days: bool - Hide SSL/TLS certificate days left from display (default: false)
# round_response_time: bool - Round response time to nearest second (default: false)
+# round_uptime: bool - Round uptime percentage to whole number (e.g., 99.99% → 100%) (default: false)
#
# HTTP/HTTPS specific fields:
# expected_status: int - Expected HTTP status code (default: 200)
diff --git a/internal/config/config.go b/internal/config/config.go
index 13391e2..81f745c 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -85,6 +85,7 @@ type MonitorConfig struct {
VerifySSL *bool `yaml:"verify_ssl,omitempty"`
HideSSLDays bool `yaml:"hide_ssl_days,omitempty"` // Hide SSL days left from display
RoundResponseTime bool `yaml:"round_response_time,omitempty"` // Round response time to nearest second
+ RoundUptime bool `yaml:"round_uptime,omitempty"` // Round uptime percentage (e.g., 99.99% → 100%)
Method string `yaml:"method,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
Body string `yaml:"body,omitempty"`
diff --git a/internal/monitor/gemini.go b/internal/monitor/gemini.go
index fb75b7d..ed04e9d 100644
--- a/internal/monitor/gemini.go
+++ b/internal/monitor/gemini.go
@@ -22,6 +22,7 @@ type GeminiMonitor struct {
verifySSL bool
hideSSLDays bool
roundResponseTime bool
+ roundUptime bool
}
// NewGeminiMonitor creates a new Gemini monitor
@@ -60,6 +61,7 @@ func NewGeminiMonitor(cfg config.MonitorConfig) (*GeminiMonitor, error) {
verifySSL: verifySSL,
hideSSLDays: cfg.HideSSLDays,
roundResponseTime: cfg.RoundResponseTime,
+ roundUptime: cfg.RoundUptime,
}, nil
}
@@ -98,6 +100,11 @@ func (m *GeminiMonitor) RoundResponseTime() bool {
return m.roundResponseTime
}
+// RoundUptime returns whether to round uptime percentage
+func (m *GeminiMonitor) RoundUptime() bool {
+ return m.roundUptime
+}
+
// Check performs the Gemini protocol check
func (m *GeminiMonitor) Check(ctx context.Context) *Result {
result := &Result{
diff --git a/internal/monitor/http.go b/internal/monitor/http.go
index b8a0177..00e3e0a 100644
--- a/internal/monitor/http.go
+++ b/internal/monitor/http.go
@@ -29,6 +29,7 @@ type HTTPMonitor struct {
verifySSL bool
hideSSLDays bool
roundResponseTime bool
+ roundUptime bool
client *http.Client
}
@@ -94,6 +95,7 @@ func NewHTTPMonitor(cfg config.MonitorConfig) (*HTTPMonitor, error) {
verifySSL: verifySSL,
hideSSLDays: cfg.HideSSLDays,
roundResponseTime: cfg.RoundResponseTime,
+ roundUptime: cfg.RoundUptime,
client: client,
}, nil
}
@@ -133,6 +135,11 @@ func (m *HTTPMonitor) RoundResponseTime() bool {
return m.roundResponseTime
}
+// RoundUptime returns whether to round uptime percentage
+func (m *HTTPMonitor) RoundUptime() bool {
+ return m.roundUptime
+}
+
// Check performs the HTTP/HTTPS check
func (m *HTTPMonitor) Check(ctx context.Context) *Result {
result := &Result{
diff --git a/internal/monitor/monitor.go b/internal/monitor/monitor.go
index cbf01b3..f4a6f66 100644
--- a/internal/monitor/monitor.go
+++ b/internal/monitor/monitor.go
@@ -52,6 +52,9 @@ type Monitor interface {
// RoundResponseTime returns whether to round response time
RoundResponseTime() bool
+ // RoundUptime returns whether to round uptime percentage
+ RoundUptime() bool
+
// Check performs the monitoring check and returns the result
Check(ctx context.Context) *Result
}
diff --git a/internal/monitor/tcp.go b/internal/monitor/tcp.go
index d14a5f1..da0a822 100644
--- a/internal/monitor/tcp.go
+++ b/internal/monitor/tcp.go
@@ -17,6 +17,7 @@ type TCPMonitor struct {
timeout time.Duration
retries int
roundResponseTime bool
+ roundUptime bool
}
// NewTCPMonitor creates a new TCP monitor
@@ -34,6 +35,7 @@ func NewTCPMonitor(cfg config.MonitorConfig) (*TCPMonitor, error) {
timeout: cfg.Timeout.Duration,
retries: cfg.Retries,
roundResponseTime: cfg.RoundResponseTime,
+ roundUptime: cfg.RoundUptime,
}, nil
}
@@ -72,6 +74,11 @@ func (m *TCPMonitor) RoundResponseTime() bool {
return m.roundResponseTime
}
+// RoundUptime returns whether to round uptime percentage
+func (m *TCPMonitor) RoundUptime() bool {
+ return m.roundUptime
+}
+
// Check performs the TCP connection check
func (m *TCPMonitor) Check(ctx context.Context) *Result {
result := &Result{