Skip to content
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

fix: prevent failures when unable to connect to *.nagios.com #51

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

cxdy
Copy link
Member

@cxdy cxdy commented Oct 19, 2024

Fixes #50

  • Creates an HTTP client with a specified timeout to catch 'connection timeout' errors instead of only waiting for an HTTP status code
  • Skip updating the metric if a version isn't returned from GetLatestNagiosXIVersion

Tested on our Nagios development instance:

root@nagiosxi-1-dev:~/cody/nagios_exporter# ./nagios_exporter --nagios.check-updates  --nagios.scrape-uri http://localhost --nagios.timeout 60
INFO[0000] Using connection endpoint: http://localhost
WARN[0031] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0034] Endpoint scraped and metrics updated
WARN[0071] Get "https://assets.nagios.com/downloads/nagiosxi/versions.php": dial tcp [2600:3c00::f03c:92ff:fef7:45ce]:443: connect: connection refused
WARN[0071] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0074] Endpoint scraped and metrics updated
WARN[0121] Get "https://assets.nagios.com/downloads/nagiosxi/versions.php": dial tcp [2600:3c00::f03c:92ff:fef7:45ce]:443: connect: connection refused
WARN[0121] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0124] Endpoint scraped and metrics updated
WARN[0161] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0164] Endpoint scraped and metrics updated
WARN[0211] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0214] Endpoint scraped and metrics updated
WARN[0251] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0254] Endpoint scraped and metrics updated
WARN[0301] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0304] Endpoint scraped and metrics updated
WARN[0341] Nagios version wasn't found, not updating `nagios_update_available_info` metric
INFO[0344] Endpoint scraped and metrics updated

@cxdy cxdy requested review from wbollock and dennisme October 19, 2024 16:09
@cxdy
Copy link
Member Author

cxdy commented Oct 19, 2024

Confirmed this continues working properly after Nagios fixes their web server 😆

ime="2024-10-19T12:26:22-04:00" level=warning msg="Nagios version wasn't found, not updating `nagios_update_available_info` metric"
ime="2024-10-19T12:26:25-04:00" level=info msg="Endpoint scraped and metrics updated"
ime="2024-10-19T12:27:02-04:00" level=warning msg="Nagios version wasn't found, not updating `nagios_update_available_info` metric"
ime="2024-10-19T12:27:05-04:00" level=info msg="Endpoint scraped and metrics updated"
ime="2024-10-19T12:27:55-04:00" level=info msg="Endpoint scraped and metrics updated"
ime="2024-10-19T12:28:35-04:00" level=info msg="Endpoint scraped and metrics updated"
ime="2024-10-19T12:29:25-04:00" level=info msg="Endpoint scraped and metrics updated"
ime="2024-10-19T12:30:05-04:00" level=info msg="Endpoint scraped and metrics updated"

Fixes linode-obs#50

- Creates an HTTP client with a specified timeout to catch 'connection timeout' errors instead of only waiting for an HTTP status code
- Skip updating the metric if a version isn't returned from GetLatestNagiosXIVersion
@cxdy cxdy force-pushed the fix/issue-50/handle-timeouts branch from 31dbb54 to 5fdea25 Compare October 19, 2024 22:39
@cxdy cxdy merged commit dfbfc8c into linode-obs:main Oct 21, 2024
2 checks passed
@cxdy cxdy deleted the fix/issue-50/handle-timeouts branch October 21, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle *.nagios.com outages / "malformed version" better
3 participants