diff options
| author | Fuwn <[email protected]> | 2026-01-19 16:59:59 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-19 16:59:59 -0800 |
| commit | 697fc99d8e340ea44c73c5bb046cad09d759c4c3 (patch) | |
| tree | 401c75aa8539fee5f94684f50a7f723f1a62079e /internal/monitor | |
| parent | feat: Add group defaults, content checking, SSL tracking for Gemini, hide/rou... (diff) | |
| download | kaze-697fc99d8e340ea44c73c5bb046cad09d759c4c3.tar.xz kaze-697fc99d8e340ea44c73c5bb046cad09d759c4c3.zip | |
feat: Add round_uptime option to round uptime percentages
Diffstat (limited to 'internal/monitor')
| -rw-r--r-- | internal/monitor/gemini.go | 7 | ||||
| -rw-r--r-- | internal/monitor/http.go | 7 | ||||
| -rw-r--r-- | internal/monitor/monitor.go | 3 | ||||
| -rw-r--r-- | internal/monitor/tcp.go | 7 |
4 files changed, 24 insertions, 0 deletions
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{ |