mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-22 23:02:22 +01:00
Add disable-monitoring-lock configuration parameter
This commit is contained in:
parent
816bc95905
commit
0a7988f2ff
19
README.md
19
README.md
@ -34,6 +34,7 @@ core applications: https://status.twinnation.org/
|
||||
- [Recommended interval](#recommended-interval)
|
||||
- [Default timeouts](#default-timeouts)
|
||||
- [Monitoring a TCP service](#monitoring-a-tcp-service)
|
||||
- [disable-monitoring-lock](#disable-monitoring-lock)
|
||||
|
||||
|
||||
## Features
|
||||
@ -119,6 +120,7 @@ Note that you can also add environment variables in the configuration file (i.e.
|
||||
| `security.basic` | Basic authentication security configuration | `{}` |
|
||||
| `security.basic.username` | Username for Basic authentication | Required `""` |
|
||||
| `security.basic.password-sha512` | Password's SHA512 hash for Basic authentication | Required `""` |
|
||||
| `disable-monitoring-lock` | Whether to [disable the monitoring lock](#disable-monitoring-lock) | `false` |
|
||||
|
||||
|
||||
### Conditions
|
||||
@ -361,7 +363,10 @@ will send a `POST` request to `http://localhost:8080/playground` with the follow
|
||||
|
||||
### Recommended interval
|
||||
|
||||
To ensure that Gatus provides reliable and accurate results (i.e. response time), Gatus only evaluates one service at a time.
|
||||
**NOTE**: This does not _really_ apply if `disable-monitoring-lock` is set to `true`, as the monitoring lock is what
|
||||
tells Gatus to only evaluate one service at a time.
|
||||
|
||||
To ensure that Gatus provides reliable and accurate results (i.e. response time), Gatus only evaluates one service at a time
|
||||
In other words, even if you have multiple services with the exact same interval, they will not execute at the same time.
|
||||
|
||||
You can test this yourself by running Gatus with several services configured with a very short, unrealistic interval,
|
||||
@ -428,3 +433,15 @@ security:
|
||||
```
|
||||
|
||||
The example above will require that you authenticate with the username `john.doe` as well as the password `hunter2`.
|
||||
|
||||
|
||||
### disable-monitoring-lock
|
||||
|
||||
Setting `disable-monitoring-lock` to `true` means that multiple services could be monitored at the same time.
|
||||
|
||||
While this behavior wouldn't generally be harmful, conditions using the `[RESPONSE_TIME]` placeholder could be impacted
|
||||
by the evaluation of multiple services at the same time, therefore, the default value for this parameter is `false`.
|
||||
|
||||
There are two main reasons why you might want to disable the monitoring lock:
|
||||
- You're using Gatus for load testing (I mean, technically, each services run on a different goroutine... If you )
|
||||
- You have a _lot_ of services to monitor
|
@ -28,11 +28,25 @@ var (
|
||||
|
||||
// Config is the main configuration structure
|
||||
type Config struct {
|
||||
Metrics bool `yaml:"metrics"`
|
||||
Debug bool `yaml:"debug"`
|
||||
// Debug Whether to enable debug logs
|
||||
Debug bool `yaml:"debug"`
|
||||
|
||||
// Metrics Whether to expose metrics at /metrics
|
||||
Metrics bool `yaml:"metrics"`
|
||||
|
||||
// DisableMonitoringLock Whether to disable the monitoring lock
|
||||
// The monitoring lock is what prevents multiple services from being processed at the same time.
|
||||
// Disabling this may lead to inaccurate response times
|
||||
DisableMonitoringLock bool `yaml:"disable-monitoring-lock"`
|
||||
|
||||
// Security Configuration for securing access to Gatus
|
||||
Security *security.Config `yaml:"security"`
|
||||
|
||||
// Alerting Configuration for alerting
|
||||
Alerting *alerting.Config `yaml:"alerting"`
|
||||
Services []*core.Service `yaml:"services"`
|
||||
|
||||
// Services List of services to monitor
|
||||
Services []*core.Service `yaml:"services"`
|
||||
}
|
||||
|
||||
func Get() *Config {
|
||||
|
@ -44,9 +44,11 @@ func Monitor(cfg *config.Config) {
|
||||
func monitor(service *core.Service) {
|
||||
cfg := config.Get()
|
||||
for {
|
||||
// By placing the lock here, we prevent multiple services from being monitored at the exact same time, which
|
||||
// could cause performance issues and return inaccurate results
|
||||
monitoringMutex.Lock()
|
||||
if !cfg.DisableMonitoringLock {
|
||||
// By placing the lock here, we prevent multiple services from being monitored at the exact same time, which
|
||||
// could cause performance issues and return inaccurate results
|
||||
monitoringMutex.Lock()
|
||||
}
|
||||
if cfg.Debug {
|
||||
log.Printf("[watchdog][monitor] Monitoring serviceName=%s", service.Name)
|
||||
}
|
||||
@ -74,7 +76,9 @@ func monitor(service *core.Service) {
|
||||
if cfg.Debug {
|
||||
log.Printf("[watchdog][monitor] Waiting for interval=%s before monitoring serviceName=%s again", service.Interval, service.Name)
|
||||
}
|
||||
monitoringMutex.Unlock()
|
||||
if !cfg.DisableMonitoringLock {
|
||||
monitoringMutex.Unlock()
|
||||
}
|
||||
time.Sleep(service.Interval)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user