Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🚦Bash script to generate a static status page.

License

NotificationsYou must be signed in to change notification settings

Cyclenerd/static_status

Repository files navigation

Badge: GNU BashBadge: ShellCheckBadge: Ubuntu 22.04 LTSBadge: Ubuntu 24.04 LTSBadge: GitHub

Description 📝

Simple Bash script to generate a static status page. Displays the status of websites, services (HTTP, SAP, MySQL...), and ping. Everything is easy to customize. 🤓

You can also easily check more complicated things with this script.For example, if a text is present on a web page or if a host appears in the route path (traceroute).Checking the route path is useful, for instance, if you have a backup mobile internet connection in addition to your cable connection.

Screenshot

In addition to the status web page, there is also a JSON version and an SVG icon.With the scriptalert.sh, you can be alerted by email, SMS or Pushover in case of a downtime.

Installation 📦

By default, it's a good practice to create astatus directory within your home directory and place everything in it :

mkdir~/statuscd~/status

1️⃣ Download Script

Download Bash scriptstatus.sh:

curl -O"https://raw.githubusercontent.com/Cyclenerd/static_status/master/status.sh"

💡 Tip: Update works exactly the same way as the installation. Simply download the latest version ofstatus.sh.

2️⃣ Download Configuration

Download configuration filestatus_hostname_list.txt:

curl -O"https://raw.githubusercontent.com/Cyclenerd/static_status/master/status_hostname_list.txt"

3️⃣ Customize

Customize thestatus_hostname_list.txt configuration file and define what you want to monitor:

vi status_hostname_list.txt

Optional

Edit the scriptstatus.sh, or better add more configuration to the configuration fileconfig.

Download the example configuration file:

curl \  -f"https://raw.githubusercontent.com/Cyclenerd/static_status/master/config-example" \  -o"config"

Customize the configuration file:

vi config

Run

bash status.sh

Usage 📋

Usage: status.sh [OPTION]:OPTION is one of the following: silent  no output from faulty connections to stout (default: no) loud    output from successful and faulty connections to stout (default: no) debug   displays all variables help    displays help (this message)

Example:

bash status.sh loud

Execute a cron job every minute:

crontab -e

Add:

*/1 * * * * bash "/path/to/status.sh" silent >> /dev/null

Requirements ⚙️

Onlybash,coreutilscurl,grep,nc,ping,sed andtraceroute.In many *NIX distributions (Ubuntu, macOS) the commands are already included.If not, the missing packages can be installed quickly.

On a debian-based system (Ubuntu), just run:

sudo apt install \  coreutils \  curl \  grep \  iputils-ping \  netcat-openbsd \  sed \  traceroute

💡 Tip: You can disable thetraceroute dependency. AddMY_TRACEROUTE_HOST='' to your config.

Demo 🌐

Thisdemo page is generated withGitHub Action:https://cyclenerd.github.io/static_status/

Screenshots 📷

ScreenshotScreenshotScreenshotScreenshotScreenshot

Custom Text 📄

You can display a custom text instead of the HOSTNAME/IP/URL (see example below).

Screenshot

status_hostname_list.txt:

ping;8.8.8.8|Google DNSnc;8.8.8.8|DNS @ Google;53curl;http://www.heise.de/ping|www.heise.detraceroute;192.168.211.1|DSL Internet;3script;/bin/true|always up

JSON 📊

You can also create a JSON status page.Configure the variableMY_STATUS_JSON with the location where the JSON file should be stored.

Example JSON:

[  {"site":"https://www.nkn-it.de/gibtesnicht","command":"curl","status":"Fail","time_sec":"282","updated":"2023-04-19 14:01:23 UTC"  },  {"site":"https://www.heise.de/ping","command":"curl","status":"OK","time_sec":"0","updated":"2023-04-19 14:01:23 UTC"  }]

SVG Icon 🖼️

If you want to signal directly if everything is fine or if something is wrong in the infrastructure, you can insert the SVG icon into your website.

Please remember to include the image with a cache breaker URL (eg. an appended timestamp:

<ahref="status.html">Status<imgsrc="status.svg?{{ timestamp }}"></a>

Static websites need to fallback to render the icon with javascript, eg with:

document.write('<imgsrc="status.svg?' + Date.now() + '">')

Custom Script Checks 🛠️

You can extend the checks ofstatus.sh with your own custom shell scripts.

If the shell script outputs a return code0 it is evaluated as available.With the special return code80, it is not classified as down but as degraded.With all other return codes, it is a failure (outage, down).

Add your script to thestatus_hostname_list.txt configuration file. Example:

script;script.shscript;/path/to/your/script.sh|Custom Textscript;/path/to/your/script.sh parameterA parameterB|Custom Text

The scriptcheck-websites.sh is an example.

TODO ✅

  1. Bug Fixes and Enhancements: Address any reported issues and consider adding new features to improve the script's functionality.

  2. Comprehensive Documentation: Create detailed documentation covering script configuration, customization, and advanced usage.

  3. Code Cleanup: Enhance code readability and performance for better maintainability.

  4. Security: Review and enhance security measures to protect against vulnerabilities.

License 📜

GNU Public License version 3.Please feel free to fork and modify this on GitHub (https://github.com/Cyclenerd/static_status).

Sponsor this project

 

Contributors27

Languages


[8]ページ先頭

©2009-2025 Movatter.jp