A simple bash script to check HTTP server.
- Checking HTTP server responses with
2xx
status - Checking HTTP server response body includes target string
I am running my own server at my home, and I do test experimental things before applying them to production.
This is a simple script to test I messed up something.
bash run.sh [options]
Option | Usage | Description | Default |
---|---|---|---|
M(mode) | arguments | Mode to run script. You can use local or actions |
local |
DISCORD_WEBHOOK_URI | config | URL of discord webhook. Click Copy Webhook URL in webhooks |
- |
TIMEOUT | config | Notifies you when curl takes longer time than TIMEOUT ms even if server returns 200 OK. |
500 |
- config.sh
- HTTP_RESPONSE_CHECK (optional)
The list of files you need to add.
Please place every file at root directory of this project.
#!/bin/bash
export DISCORD_WEBHOOK_URI='https://discord.com/api/webhooks/123/foo'
export TIMEOUT='1500'
Example of config.sh
.
Please notice that DISCORD_WEBHOOK_URI
is necessary to run this script.
https://example.com RESPONSE_STATUS 200 RESPONSE_INCLUDES FOO RESPONSE_NOT_INCLUDES BAR
https://example.com RESPONSE_STATUS 404 RESPONSE_INCLUDES FOO
https://example.com RESPONSE_INCLUDES BAZ
https://example.com RESPONSE_STATUS 200 RESPONSE_NOT_INCLUDES FIZZ
Example of HTTP_RESPONSE_CHECK
file.
Option | Description |
---|---|
RESPONSE_STATUS | The expected HTTP response status code |
RESPONSE_INCLUDES | Characters that expected to be included in the response body |
RESPONSE_NOT_INCLUDES | Characters that are NOT expected to be included in the response body |
- Comment in
schedule
in.github/workflows/health-check.yml
- Add configs(eg.
TIMEOUT
,HTTP_STATUS_CHECK
) in Actions Secrets