copr-fe: catch exceptions while checking uptime robot
This commit is contained in:
parent
17a83f33e2
commit
39070dc595
1 changed files with 38 additions and 2 deletions
|
@ -1,8 +1,40 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
Ask UptimeRobot service how the CDN works.
|
||||||
|
|
||||||
|
The API output looks like:
|
||||||
|
|
||||||
|
{
|
||||||
|
"stat": "ok",
|
||||||
|
"pagination": {
|
||||||
|
"offset": 0,
|
||||||
|
"limit": 50,
|
||||||
|
"total": 1
|
||||||
|
},
|
||||||
|
"monitors": [
|
||||||
|
{
|
||||||
|
"id": 788475080,
|
||||||
|
"friendly_name": "Copr's CDN",
|
||||||
|
"url": "https://download.copr.fedorainfracloud.org/",
|
||||||
|
"type": 1,
|
||||||
|
"sub_type": "",
|
||||||
|
"keyword_type": null,
|
||||||
|
"keyword_case_type": 0,
|
||||||
|
"keyword_value": "",
|
||||||
|
"port": "",
|
||||||
|
"interval": 600,
|
||||||
|
"timeout": 30,
|
||||||
|
"status": 2,
|
||||||
|
"create_datetime": 1624272619
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
import logging
|
|
||||||
|
|
||||||
# NAGIOS exit codes
|
# NAGIOS exit codes
|
||||||
NAG_UNKNOWN = 3
|
NAG_UNKNOWN = 3
|
||||||
|
@ -93,5 +125,9 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.exception("some exception occured: %s", exc)
|
||||||
|
|
||||||
sys.exit(NAG_UNKNOWN)
|
sys.exit(NAG_UNKNOWN)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue