Skip to content

A simple bash script to check HTTP server.

Notifications You must be signed in to change notification settings

yjh1411/simple-health-checker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple health checker

A simple bash script to check HTTP server.

  1. Checking HTTP server responses with 2xx status
  2. Checking HTTP server response body includes target string

Discord webhook result

Why I did this

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.

Usage

bash run.sh [options]

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 TIMEOUTms even if server returns 200 OK. 500

Local server setting

-   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

Github actions setting

  1. Comment in schedule in .github/workflows/health-check.yml
  2. Add configs(eg. TIMEOUT, HTTP_STATUS_CHECK) in Actions Secrets

About

A simple bash script to check HTTP server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%