Pyng: HTTP check
Description
HTTP check provides flexible facilities to send HTTP requests.
HTTP requires curl command to be
present in $PATH.
Options
HTTP supports following options, which may be used upon creation
of a new check object:
- url
-
Target URL for the request (required)
- method
-
GET, HEAD, POST
or PUT method for the request
- headers
-
List of header: value HTTP header pairs to use for the request
- query
-
List of name=value query data pairs to append to the URL
- data
-
List of name=value data pairs to send in the request
- json
-
JSON encoded string to send in the request, or a list, tuple or
dictionary to encode as JSON and send in the request
- auth
-
Username and password to use for server authentication, provided
as a string with username and password separated with colon
(":")
- agent
-
HTTP User-Agent header to use for the request
- referer
-
Referrer URL to use for the request
- noverify
-
Set to True to skip TLS certificate verification
- ipv
-
IP version to use when resolving addresses (IPv6 or IPv4)
- socks5
-
SOCKS5 proxy to use for the request provided as host:[port]
In addition, HTTP supports following generic check settings:
- desc
-
Check description
- silent
-
Information about check runs is not output by certain runners
- interval
-
Number of seconds between check runs
- result
-
Require that check output matches result in order to
consider check successful. During the matching, check output is
evaluated as a list of lines of output without
newlines. result may be provided in multiple
ways:
-
None: always succeeds
-
string: succeeds if any line in the check's output
is equal to, or contains, result
-
list or a tuple: succeeds if all
elements of result are present in the check's
output (i.e. set of result items is a subset of
check output items)
-
set: succeeds if all lines in the check's
output are present in result (i.e. check output
is a subset of the set of result items)
-
Compiled regular expression object: succeeds if any
line in the check's output matches result
- alert
-
Callable (or a list of callables) to run in order to alert of
check status changes
- notify
-
Callable (or a list of callables) to run in order to notify of
changes in check's output
- run_condition
-
Callable to run to decide if check run should be skipped
- run_threshold
-
Threshold for mean run time in order to consider check to be
degraded
- result_filter
-
Callable to run to filter check command output lines prior to
matching check results
- on_result
- on_first
- on_up
- on_down
- on_degrade
- on_restore
- on_change
-
Callable to run with the result of the check on the specified
events
Example
# send HTTP request, verify the result
HTTP(
'https://get.uptime.is/api',
query=['sla=100'],
result='"SLA": 100.0',
)
Return to Pyng