-
-
Notifications
You must be signed in to change notification settings - Fork 119
+ Add UptimeRobot all monitors features #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,26 +256,109 @@ func (monitor *UpTimeMonitorService) processProviderConfig(m models.Monitor, cre | |
| body += "&type=2" | ||
|
|
||
| if providerConfig != nil && len(providerConfig.KeywordExists) != 0 { | ||
|
|
||
| if strings.Contains(strings.ToLower(providerConfig.KeywordExists), "yes") { | ||
| body += "&keyword_type=1" | ||
| } else if strings.Contains(strings.ToLower(providerConfig.KeywordExists), "no") { | ||
| body += "&keyword_type=2" | ||
| } | ||
|
|
||
| } else { | ||
| body += "&keyword_type=1" // By default 1 (check if keyword exists) | ||
| } | ||
|
|
||
| // Keyword Value (Required for keyword monitoring) | ||
| if providerConfig != nil && len(providerConfig.KeywordValue) != 0 { | ||
| body += "&keyword_value=" + providerConfig.KeywordValue | ||
| body += "&keyword_value=" + url.QueryEscape(providerConfig.KeywordValue) | ||
| } else { | ||
| log.Error(nil, "Monitor is of type Keyword but the `keyword-value` is missing") | ||
| } | ||
| } | ||
| } else { | ||
| body += "&type=1" // By default monitor is of type HTTP | ||
| } | ||
|
|
||
| // SubType (Optional for certain types) | ||
| if providerConfig != nil && len(providerConfig.SubType) != 0 { | ||
| body += "&sub_type=" + url.QueryEscape(providerConfig.SubType) | ||
| } | ||
|
|
||
| // Port (Optional for certain types) | ||
| if providerConfig != nil && providerConfig.Port > 0 { | ||
| body += "&port=" + strconv.Itoa(providerConfig.Port) | ||
| } | ||
|
|
||
| // Interval (Optional, in seconds) | ||
| if providerConfig != nil && providerConfig.Interval > 0 { | ||
| body += "&interval=" + strconv.Itoa(providerConfig.Interval) | ||
| } else { | ||
| body += "&interval=" + strconv.Itoa(DefaultInterval) | ||
| } | ||
|
Comment on lines
+289
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be removed (duplicates of lines 237-242), generates an error: "Error: "interval" must be a string" |
||
|
|
||
| // Timeout (Optional, in seconds) | ||
| if providerConfig != nil && providerConfig.Timeout > 0 { | ||
| body += "&timeout=" + strconv.Itoa(providerConfig.Timeout) | ||
| } | ||
|
|
||
| // HTTP Auth (Optional) | ||
| if providerConfig != nil && len(providerConfig.HTTPAuthUsername) != 0 && len(providerConfig.HTTPAuthPassword) != 0 { | ||
| body += "&http_username=" + url.QueryEscape(providerConfig.HTTPAuthUsername) | ||
| body += "&http_password=" + url.QueryEscape(providerConfig.HTTPAuthPassword) | ||
| if providerConfig.HTTPAuthType > 0 { | ||
| body += "&http_auth_type=" + strconv.Itoa(providerConfig.HTTPAuthType) | ||
| } | ||
| } | ||
|
|
||
| // Post Type (Optional) | ||
| if providerConfig != nil && len(providerConfig.PostType) != 0 { | ||
| body += "&post_type=" + url.QueryEscape(providerConfig.PostType) | ||
| } | ||
|
|
||
| // Post Value (Optional) | ||
| if providerConfig != nil && len(providerConfig.PostValue) != 0 { | ||
| body += "&post_value=" + url.QueryEscape(providerConfig.PostValue) | ||
| } | ||
|
|
||
| // HTTP Method (Optional) | ||
| if providerConfig != nil && len(providerConfig.HTTPMethod) != 0 { | ||
| body += "&http_method=" + url.QueryEscape(providerConfig.HTTPMethod) | ||
| } | ||
|
|
||
| // Post Content Type (Optional) | ||
| if providerConfig != nil && len(providerConfig.PostContentType) != 0 { | ||
| body += "&post_content_type=" + url.QueryEscape(providerConfig.PostContentType) | ||
| } | ||
|
|
||
| // Alert Contacts (Optional) | ||
| if providerConfig != nil && len(providerConfig.AlertContacts) != 0 { | ||
| body += "&alert_contacts=" + url.QueryEscape(providerConfig.AlertContacts) | ||
| } else { | ||
| body += "&alert_contacts=" + url.QueryEscape(monitor.alertContacts) | ||
|
Comment on lines
+330
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be removed (duplicates of lines 231-235), generates an error: "Error: "alert_contacts" must be a string"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| } | ||
|
|
||
| // Maintenance Windows (Optional) | ||
| if providerConfig != nil && len(providerConfig.MaintenanceWindows) != 0 { | ||
| body += "&mwindows=" + url.QueryEscape(providerConfig.MaintenanceWindows) | ||
| } | ||
|
|
||
| // Custom HTTP Headers (Optional, must be sent as a JSON object) | ||
| if providerConfig != nil && len(providerConfig.CustomHTTPHeaders) != 0 { | ||
| body += "&custom_http_headers=" + url.QueryEscape(providerConfig.CustomHTTPHeaders) | ||
| } | ||
|
|
||
| // Custom HTTP Statuses (Optional, must be sent in specific format) | ||
| if providerConfig != nil && len(providerConfig.CustomHTTPStatuses) != 0 { | ||
| body += "&custom_http_statuses=" + url.QueryEscape(providerConfig.CustomHTTPStatuses) | ||
| } | ||
|
|
||
| // Ignore SSL Errors (Optional) | ||
| if providerConfig != nil && providerConfig.IgnoreSSLErrors > 0 { | ||
| body += "&ignore_ssl_errors=" + strconv.Itoa(providerConfig.IgnoreSSLErrors) | ||
| } | ||
|
|
||
| // Disable Domain Expire Notifications (Optional) | ||
| if providerConfig != nil && providerConfig.DisableDomainExpireNotifications > 0 { | ||
| body += "&disable_domain_expire_notifications=" + strconv.Itoa(providerConfig.DisableDomainExpireNotifications) | ||
| } | ||
|
|
||
| return body | ||
| } | ||
|
|
||
|
|
@@ -324,4 +407,4 @@ func (monitor *UpTimeMonitorService) updateStatusPages(statusPages string, monit | |
| if err != nil { | ||
| log.Info("Monitor couldn't be added to status page: " + err.Error()) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @dguihal commented we need to remove this block