Commit e1edf139 authored by A Rabbit's avatar A Rabbit Committed by Remy
Browse files

Add CGI mode

parent 8ebe67de
......@@ -33,7 +33,7 @@ Clone the git repository:
git clone https://github.com/RaymiiOrg/bash-http-monitoring.git
cd bash-http-monitoring
Edit the `srvmon.sh` script and add your sites. A few examples are provided. This is the syntax:
Edit the `srvmon` script and add your sites. A few examples are provided. This is the syntax:
urls[gists]="https://gist.github.com"
urls[lobsters]="https://lobste.rs"
......@@ -54,11 +54,12 @@ Further global configuration options include:
maxConcurrentCurls=12 # How many curl checks to run at the same time
defaultTimeOut=10 # Max timeout of a check in seconds
flapRetry=5 # After how many seconds should we re-check any failed checks? (To prevent flapping)
title="Status Dashboard" # Title of the webpage
title="Status Dashboard" # Title of the webpage
cgi=false # Enable or disable CGI mode
Execute the script and send the output to a file in your webservers documentroot:
bash srvmon.sh > /var/www/index.html
bash srvmon > /var/www/index.html
View that file in a web browser.
......@@ -68,10 +69,18 @@ If you want to set up a cronjob, send the output to a temp file and when finishe
file over the "actual" file. Otherwise you might end up with an incomplete page when the checks are
running. Like so:
* * * * * /bin/bash /opt/srvmon/srvmon.sh > /var/www/index.html.tmp && /bin/mv /var/www/index.html.tmp /var/www/index.html
* * * * * /bin/bash /opt/srvmon/srvmon > /var/www/index.html.tmp && /bin/mv /var/www/index.html.tmp /var/www/index.html
If the check fails for whatever reason, the "old" page will not be overridden.
### CGI mode
If you want to set up CGI mode, you need to copy the script to your server CGI directory.
You can use `docker` for this purpose. Like so:
docker run -d -p 9090:80 -v $PWD/srvmon:/usr/local/apache2/cgi-bin/srvmon hypoport/httpd-cgi
## Screenshots
......
......@@ -46,6 +46,9 @@ flapRetry=5
# Title of the webpage
title="Status Dashboard"
# Use CGI mode
cgi=false
# Start of script. Do not edit below
# Exit immediately if a command exits with a non-zero status.
set -e
......@@ -220,6 +223,9 @@ cleanupOKCheckFiles() {
writeHeader() {
if [[ "$cgi" = true ]]; then
printf "Content-type: text/html\n\n";
fi
echo '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">'
echo "<title>${title}</title>"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment