Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Patap
bash-http-monitoring
Commits
e1edf139
Commit
e1edf139
authored
Dec 28, 2020
by
A Rabbit
Committed by
Remy
Dec 28, 2020
Browse files
Add CGI mode
parent
8ebe67de
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
e1edf139
...
...
@@ -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
...
...
srvmon
.sh
→
srvmon
100644 → 100755
View file @
e1edf139
...
...
@@ -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>
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment