HealthChecks
HealthCheckExecutor
HealthCheckExecutor
The HealthCheckExecutor encapsulates the functionality to perform a health check on a site and properly notify users or update statuspage.io accordingly.
A Healthcheck represents a simple request to the defined url
. If a non-200 the
request generates an exception or a non-200 response, the site is determined to
be down.
If statuspage_operator
is present and the HealthCheckSettings have a component_id
set, statuspage.io will be updated according to the following rules.
- If the site returns a 2xx response and statuspage.io lists the component as
non-operational:
- The component's status will be set to operational
- Any open incidents associated with this component will be marked as resolved
- If the site returns a non-2xx response or an exception and statuspage.io lists
the component as operational:
- The component's status will be set to operational
- An incident will be opened using the
name
and associated with this component.
Attributes:
Name | Type | Description |
---|---|---|
statuspage_operator |
StatusPageOperator
|
The name of the site being checked |
notifier |
Notifier
|
The url to be fetched as part of the check |
Source code in pi_monitor/healthchecks.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__init__(status_operator, notifier)
Constructor
Constructs an instance of the HealthCheckExecutor with the given StatusPageOperator and Notifier.
Attributes:
Name | Type | Description |
---|---|---|
statuspage_operator |
The name of the site being checked |
|
notifier |
The url to be fetched as part of the check |
Source code in pi_monitor/healthchecks.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
_get_http(url)
Retrieve data from the URL
Attempt to get data from the provided URL
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The url to be retrieved |
required |
Returns:
Type | Description |
---|---|
HttpGetResult
|
Source code in pi_monitor/healthchecks.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
_process_response(response)
Process the HTTP Requests response
Convert the provided Response object from the requests module into an [HttpGetResult][healthchecks.HttpGetResult].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
Response
|
The [requests.Response] object from the HTTP operation |
required |
Returns:
Type | Description |
---|---|
HttpGetResult
|
An [HttpGetResult][healthchecks.HttpGetResult] |
Source code in pi_monitor/healthchecks.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
execute_health_check(check_settings)
Execute a health check
Executes a health check using the provided HealthCheckSettings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check_settings
|
HealthCheckSettings
|
An instance of HealthCheckSettings |
required |
Source code in pi_monitor/healthchecks.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
HttpGetResult
HttpGetResult
Attributes:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether or not the request was successful |
message |
str
|
The error message from an unsuccessful request |
raw_response |
str
|
The string value of the response body |
response |
any
|
An object representing the response body converted as JSON |
Source code in pi_monitor/healthchecks.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|