├── .github ├── FUNDING.yml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── demo_page.yml │ ├── shellcheck.yml │ ├── ubuntu_2204.yml │ └── ubuntu_2404.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── alert.sh ├── config-example ├── images ├── Status-Page-Custom-Text.png ├── Status-Page-Maintenance.jpg ├── Status-Page-Major_Outage.jpg ├── Status-Page-OK.jpg ├── Status-Page-Outage.jpg ├── Status-Page-Past-Incidents.jpg └── Status-Page-Screenshot.jpg ├── scripts └── check-websites.sh ├── status.sh ├── status_hostname_list.txt ├── status_maintenance_text.txt ├── status_website_list.txt └── test.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Cyclenerd 2 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | First off, thanks for taking the time to contribute! 2 | 3 | ## Please Complete the Following 4 | 5 | - [ ] I read [CONTRIBUTING.md](https://github.com/Cyclenerd/static_status/blob/master/CONTRIBUTING.md) 6 | - [ ] I used tabs to indent 7 | - [ ] I checked my code with [ShellCheck](https://www.shellcheck.net/) 8 | 9 | ## Notes 10 | 11 | Feel free to put whatever you want here. -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/workflows/demo_page.yml: -------------------------------------------------------------------------------- 1 | name: "Update status demo page" 2 | on: 3 | schedule: 4 | - cron: "* 6 15 * *" 5 | workflow_dispatch: 6 | 7 | jobs: 8 | build-and-deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Dependencies 🔧 12 | run: sudo apt-get install curl iputils-ping traceroute netcat-openbsd grep sed 13 | - name: Checkout 🛎️ 14 | uses: actions/checkout@v4 15 | - name: Configuration 🖊️ 16 | run: | 17 | mkdir -p "build/" 18 | mkdir -p "$HOME/status/" 19 | echo 'MY_STATUS_HTML="build/index.html"' > config 20 | echo 'MY_STATUS_JSON="build/status.json"' >> config 21 | echo 'MY_STATUS_ICON="build/status.svg"' >> config 22 | echo 'MY_MAINTENANCE_TEXT_FILE="status_maintenance_text.txt"' >> config 23 | echo 'MY_HOSTNAME_FILE="status_hostname_list.txt"' >> config 24 | echo 'This is a demo page of static_status.' > status_maintenance_text.txt 25 | echo 'There is also a JSON version and a SVG icon of this status page.' >> status_maintenance_text.txt 26 | echo 'This status page was generated with GitHub Action.' >> status_maintenance_text.txt 27 | echo 'curl;https://www.heise.de/ping|www.heise.de (curl)' > status_hostname_list.txt 28 | echo 'curl;ftp://ftp.usa.openbsd.org/pub/OpenBSD/timestamp|ftp.usa.openbsd.org (curl)' >> status_hostname_list.txt 29 | echo 'nc;8.8.8.8|DNS @ Google (nc);53' >> status_hostname_list.txt 30 | echo 'script;/bin/true|Always up (/bin/true)' >> status_hostname_list.txt 31 | echo 'script;exit 80|Always degraded (exit 80)' >> status_hostname_list.txt 32 | echo 'script;/bin/false|Always down (/bin/false)' >> status_hostname_list.txt 33 | echo "config" 34 | cat config 35 | echo "status_maintenance_text.txt" 36 | cat status_maintenance_text.txt 37 | echo "status_hostname_list.txt" 38 | cat status_hostname_list.txt 39 | - name: Debug 🤯 40 | run: bash status.sh debug 41 | - name: Status 🚦 42 | run: bash status.sh loud 43 | # https://github.com/marketplace/actions/deploy-to-github-pages 44 | - name: Deploy 🚀 45 | uses: JamesIves/github-pages-deploy-action@v4 46 | with: 47 | branch: gh-pages # The branch the action should deploy to. 48 | folder: build # The folder the action should deploy. -------------------------------------------------------------------------------- /.github/workflows/shellcheck.yml: -------------------------------------------------------------------------------- 1 | name: "ShellCheck" 2 | 3 | # Controls when the workflow will run 4 | on: 5 | push: 6 | branches: [ master ] 7 | pull_request: 8 | branches: [ master ] 9 | workflow_dispatch: 10 | 11 | jobs: 12 | shellcheck: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 🛎️ 16 | uses: actions/checkout@v4 17 | - name: ShellCheck 🔎 18 | run: shellcheck status.sh -------------------------------------------------------------------------------- /.github/workflows/ubuntu_2204.yml: -------------------------------------------------------------------------------- 1 | name: "Ubuntu 22.04 LTS" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | ubuntu-2204: 12 | name: Test Ubuntu 22.04 LTS 13 | # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md 14 | runs-on: ubuntu-22.04 15 | steps: 16 | - name: 🔧 Install dependencies 17 | run: | 18 | sudo apt-get install \ 19 | coreutils \ 20 | curl \ 21 | grep \ 22 | iputils-ping \ 23 | netcat-openbsd \ 24 | sed \ 25 | traceroute 26 | 27 | # Test commands 28 | - name: 🐧 Test ping 29 | run: ping -w 5 -c 2 '127.0.0.1' 30 | - name: 🐧 Test nc 31 | run: nc -z -w 5 'www.nkn-it.de' '443' 32 | - name: 🐧 Test curl 33 | run: curl -Is --max-time 5 'https://www.nkn-it.de/ci.txt' 34 | - name: 🐧 Test curl (http-status) 35 | run: curl -s -o /dev/null -I --max-time "5" -w "%{http_code}" "https://www.nkn-it.de/ci.txt" 36 | - name: 🐧 Test dig 37 | run: dig ns 'nkn-it.de' 38 | 39 | # git clone 40 | - name: 🛎️ Checkout 41 | uses: actions/checkout@v4 42 | 43 | - name: 🎁 Get assert.sh 44 | run: curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh 45 | 46 | # Run tests 47 | - name: 🛠️ Test 48 | run: bash test.sh 49 | 50 | # View files 51 | - name: 📃 status_hostname_list.txt 52 | run: cat $HOME/status/status_hostname_list.txt 53 | - name: 📃 status_hostname_ok.txt 54 | run: cat $HOME/status/status_hostname_ok.txt 55 | - name: 📃 status_hostname_down.txt 56 | run: cat $HOME/status/status_hostname_down.txt -------------------------------------------------------------------------------- /.github/workflows/ubuntu_2404.yml: -------------------------------------------------------------------------------- 1 | name: "Ubuntu 24.04 LTS" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | ubuntu-2404: 12 | name: Test Ubuntu 24.04 LTS 13 | # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md 14 | runs-on: ubuntu-24.04 15 | steps: 16 | - name: 🔧 Install dependencies 17 | run: | 18 | sudo apt-get install \ 19 | coreutils \ 20 | curl \ 21 | grep \ 22 | iputils-ping \ 23 | netcat-openbsd \ 24 | sed \ 25 | traceroute 26 | 27 | # Test commands 28 | - name: 🐧 Test ping 29 | run: ping -w 5 -c 2 '127.0.0.1' 30 | - name: 🐧 Test nc 31 | run: nc -z -w 5 'www.nkn-it.de' '443' 32 | - name: 🐧 Test curl 33 | run: curl -Is --max-time 5 'https://www.nkn-it.de/ci.txt' 34 | - name: 🐧 Test curl (http-status) 35 | run: curl -s -o /dev/null -I --max-time "5" -w "%{http_code}" "https://www.nkn-it.de/ci.txt" 36 | - name: 🐧 Test dig 37 | run: dig ns 'nkn-it.de' 38 | 39 | # git clone 40 | - name: 🛎️ Checkout 41 | uses: actions/checkout@v4 42 | 43 | - name: 🎁 Get assert.sh 44 | run: curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh 45 | 46 | # Run tests 47 | - name: 🛠️ Test 48 | run: bash test.sh 49 | 50 | # View files 51 | - name: 📃 status_hostname_list.txt 52 | run: cat $HOME/status/status_hostname_list.txt 53 | - name: 📃 status_hostname_ok.txt 54 | run: cat $HOME/status/status_hostname_ok.txt 55 | - name: 📃 status_hostname_down.txt 56 | run: cat $HOME/status/status_hostname_down.txt -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | assert.sh 3 | status_hostname_down.txt 4 | status_hostname_history.txt 5 | status_hostname_last.txt 6 | status_hostname_ok.txt 7 | *.html 8 | config 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 🤝 2 | 3 | ## Our Pledge 🙌 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 📜 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 😊 21 | * Being respectful of differing opinions, viewpoints, and experiences 🤝 22 | * Giving and gracefully accepting constructive feedback 🤗 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 🙏 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 🌍 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 🚫 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 🚫 33 | * Public or private harassment 🚫 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 🚫 36 | * Other conduct that could reasonably be considered inappropriate in a 37 | professional setting 🚫 38 | 39 | ## Enforcement Responsibilities 🚔 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 🔍 52 | 53 | This Code of Conduct applies within all community spaces and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 🔒 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | nils [at] nkn-it (dot) de. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 🚀 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 🖋 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning ⚠️ 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban ⛔ 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 🚫 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 📖 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the Project 2 | 3 | Thank you for considering contributing to our project! Your help and involvement are highly appreciated. 4 | This guide will help you get started with the contribution process. 5 | 6 | ## Table of Contents 7 | 8 | 1. [Fork the Repository](#fork-the-repository-) 9 | 2. [Clone Your Fork](#clone-your-fork-) 10 | 3. [Create a New Branch](#create-a-new-branch-) 11 | 4. [Submitting Changes](#submitting-changes-) 12 | 5. [Create a Pull Request](#create-a-pull-request-) 13 | 6. [Coding Style](#coding-style-) 14 | 7. [Keep It Simple](#keep-it-simple-) 15 | 16 | ## Fork the Repository 🍴 17 | 18 | Start by forking the repository. You can do this by clicking the "Fork" button in the 19 | upper right corner of the repository page. This will create a copy of the repository 20 | in your GitHub account. 21 | 22 | ## Clone Your Fork 📥 23 | 24 | Clone your newly created fork of the repository to your local machine with the following command: 25 | 26 | ```bash 27 | git clone https://github.com/your-username/static_status.git 28 | ``` 29 | 30 | ## Create a New Branch 🌿 31 | 32 | Create a new branch for the specific issue or feature you are working on. 33 | Use a descriptive branch name: 34 | 35 | ```bash 36 | git checkout -b "feature-or-issue-name" 37 | ``` 38 | 39 | ## Submitting Changes 🚀 40 | Make your desired changes to the codebase. 41 | 42 | Stage your changes using the following command: 43 | 44 | ```bash 45 | git add . 46 | ``` 47 | 48 | Commit your changes with a clear and concise commit message: 49 | 50 | ```bash 51 | git commit -m "A brief summary of the commit." 52 | ``` 53 | 54 | ## Create a Pull Request 🌟 55 | 56 | Go to your forked repository on GitHub and click on the "New Pull Request" button. 57 | This will open a new pull request to the original repository. 58 | 59 | ## Coding Style 📝 60 | 61 | Start reading the code, and you'll get the hang of it. It is optimized for readability: 62 | 63 | - Variables must be uppercase and should begin with `MY_`. 64 | - Functions must be lowercase. 65 | - Check your shell scripts with ShellCheck before submitting. 66 | - Please use tabs to indent. 67 | 68 | ## Keep It Simple 👍 69 | 70 | Simplicity is key. When making changes, aim for clean, easy-to-understand code that benefits all users. 71 | 72 | Thank you for your contribution! ❤️ 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # status.sh 🚀 2 | 3 | [![Badge: GNU Bash](https://img.shields.io/badge/GNU%20Bash-4EAA25.svg?logo=gnubash&logoColor=white)](#readme) 4 | [![Badge: ShellCheck](https://github.com/Cyclenerd/static_status/actions/workflows/shellcheck.yml/badge.svg?branch=master)](https://github.com/Cyclenerd/static_status/actions/workflows/shellcheck.yml) 5 | [![Badge: Ubuntu 22.04 LTS](https://github.com/Cyclenerd/static_status/actions/workflows/ubuntu_2204.yml/badge.svg?branch=master)](https://github.com/Cyclenerd/static_status/actions/workflows/ubuntu_2204.yml) 6 | [![Badge: Ubuntu 24.04 LTS](https://github.com/Cyclenerd/static_status/actions/workflows/ubuntu_2404.yml/badge.svg?branch=master)](https://github.com/Cyclenerd/static_status/actions/workflows/ubuntu_2404.yml) 7 | [![Badge: GitHub](https://img.shields.io/github/license/cyclenerd/static_status)](https://github.com/Cyclenerd/static_status/blob/master/LICENSE) 8 | 9 | ## Description 📝 10 | 11 | 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. 🤓 12 | 13 | You can also easily check more complicated things with this script. 14 | For example, if a text is present on a web page or if a host appears in the route path (traceroute). 15 | Checking the route path is useful, for instance, if you have a backup mobile internet connection in addition to your cable connection. 16 | 17 | ![Screenshot](images/Status-Page-Screenshot.jpg) 18 | 19 | In addition to the status web page, there is also a JSON version and an SVG icon. 20 | With the script `alert.sh`, you can be alerted by email, SMS or Pushover in case of a downtime. 21 | 22 | ## Installation 📦 23 | 24 | By default, it's a good practice to create a `status` directory within your home directory and place everything in it : 25 | ```shell 26 | mkdir ~/status 27 | cd ~/status 28 | ``` 29 | 30 | ### 1️⃣ Download Script 31 | 32 | Download Bash script `status.sh`: 33 | ```shell 34 | curl -O "https://raw.githubusercontent.com/Cyclenerd/static_status/master/status.sh" 35 | ``` 36 | 37 | > 💡 Tip: Update works exactly the same way as the installation. Simply download the latest version of `status.sh`. 38 | 39 | ### 2️⃣ Download Configuration 40 | 41 | Download configuration file `status_hostname_list.txt`: 42 | ```shell 43 | curl -O "https://raw.githubusercontent.com/Cyclenerd/static_status/master/status_hostname_list.txt" 44 | ``` 45 | 46 | ### 3️⃣ Customize 47 | 48 | Customize the `status_hostname_list.txt` configuration file and define what you want to monitor: 49 | ```shell 50 | vi status_hostname_list.txt 51 | ``` 52 | 53 | ### Optional 54 | 55 | Edit the script `status.sh`, or better add more configuration to the configuration file `config`. 56 | 57 | Download the example configuration file: 58 | ```shell 59 | curl \ 60 | -f "https://raw.githubusercontent.com/Cyclenerd/static_status/master/config-example" \ 61 | -o "config" 62 | ``` 63 | 64 | Customize the configuration file: 65 | ```shell 66 | vi config 67 | ``` 68 | 69 | ### Run 70 | 71 | ```shell 72 | bash status.sh 73 | ``` 74 | 75 | ## Usage 📋 76 | 77 | ```text 78 | Usage: status.sh [OPTION]: 79 | OPTION is one of the following: 80 | silent no output from faulty connections to stout (default: no) 81 | loud output from successful and faulty connections to stout (default: no) 82 | debug displays all variables 83 | help displays help (this message) 84 | ``` 85 | 86 | Example: 87 | 88 | ```shell 89 | bash status.sh loud 90 | ``` 91 | 92 | Execute a cron job every minute: 93 | 94 | ```shell 95 | crontab -e 96 | ``` 97 | 98 | Add: 99 | 100 | ```text 101 | */1 * * * * bash "/path/to/status.sh" silent >> /dev/null 102 | ``` 103 | 104 | ## Requirements ⚙️ 105 | 106 | Only 107 | `bash`, 108 | `coreutils` 109 | `curl`, 110 | `grep`, 111 | `nc`, 112 | `ping`, 113 | `sed` and `traceroute`. 114 | In many *NIX distributions (Ubuntu, macOS) the commands are already included. 115 | If not, the missing packages can be installed quickly. 116 | 117 | On a debian-based system (Ubuntu), just run: 118 | 119 | ```shell 120 | sudo apt install \ 121 | coreutils \ 122 | curl \ 123 | grep \ 124 | iputils-ping \ 125 | netcat-openbsd \ 126 | sed \ 127 | traceroute 128 | ``` 129 | 130 | > 💡 Tip: You can disable the `traceroute` dependency. Add `MY_TRACEROUTE_HOST=''` to your config. 131 | 132 | 133 | ## Demo 🌐 134 | 135 | This [demo page](https://cyclenerd.github.io/static_status/) is generated with [GitHub Action](https://github.com/Cyclenerd/static_status/blob/master/.github/workflows/demo_page.yml): 136 | 137 | 138 | ### Screenshots 📷 139 | 140 | ![Screenshot](images/Status-Page-Maintenance.jpg) 141 | ![Screenshot](images/Status-Page-OK.jpg) 142 | ![Screenshot](images/Status-Page-Outage.jpg) 143 | ![Screenshot](images/Status-Page-Major_Outage.jpg) 144 | ![Screenshot](images/Status-Page-Past-Incidents.jpg) 145 | 146 | ## Custom Text 📄 147 | 148 | You can display a custom text instead of the HOSTNAME/IP/URL (see example below). 149 | 150 | ![Screenshot](images/Status-Page-Custom-Text.png) 151 | 152 | status_hostname_list.txt: 153 | 154 | ```text 155 | ping;8.8.8.8|Google DNS 156 | nc;8.8.8.8|DNS @ Google;53 157 | curl;http://www.heise.de/ping|www.heise.de 158 | traceroute;192.168.211.1|DSL Internet;3 159 | script;/bin/true|always up 160 | ``` 161 | 162 | ## JSON 📊 163 | 164 | You can also create a JSON status page. 165 | Configure the variable `MY_STATUS_JSON` with the location where the JSON file should be stored. 166 | 167 | Example JSON: 168 | ```json 169 | [ 170 | { 171 | "site": "https://www.nkn-it.de/gibtesnicht", 172 | "command": "curl", 173 | "status": "Fail", 174 | "time_sec": "282", 175 | "updated": "2023-04-19 14:01:23 UTC" 176 | }, 177 | { 178 | "site": "https://www.heise.de/ping", 179 | "command": "curl", 180 | "status": "OK", 181 | "time_sec": "0", 182 | "updated": "2023-04-19 14:01:23 UTC" 183 | } 184 | ] 185 | ``` 186 | 187 | ## SVG Icon 🖼️ 188 | 189 | 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. 190 | 191 | Please remember to include the image with a cache breaker URL (eg. an appended timestamp: 192 | ```html 193 | Status 194 | ``` 195 | 196 | Static websites need to fallback to render the icon with javascript, eg with: 197 | ```html 198 | document.write('') 199 | ``` 200 | 201 | ## Custom Script Checks 🛠️ 202 | 203 | You can extend the checks of `status.sh` with your own custom shell scripts. 204 | 205 | If the shell script outputs a return code `0` it is evaluated as available. 206 | With the special return code `80`, it is not classified as down but as degraded. 207 | With all other return codes, it is a failure (outage, down). 208 | 209 | Add your script to the `status_hostname_list.txt` configuration file. Example: 210 | 211 | ```text 212 | script;script.sh 213 | script;/path/to/your/script.sh|Custom Text 214 | script;/path/to/your/script.sh parameterA parameterB|Custom Text 215 | ``` 216 | 217 | The script [`check-websites.sh`](./scripts/check-websites.sh) is an example. 218 | 219 | ## TODO ✅ 220 | 221 | 1. **Bug Fixes and Enhancements**: Address any reported issues and consider adding new features to improve the script's functionality. 222 | 223 | 2. **Comprehensive Documentation**: Create detailed documentation covering script configuration, customization, and advanced usage. 224 | 225 | 3. **Code Cleanup**: Enhance code readability and performance for better maintainability. 226 | 227 | 4. **Security**: Review and enhance security measures to protect against vulnerabilities. 228 | 229 | 230 | ## License 📜 231 | 232 | GNU Public License version 3. 233 | Please feel free to fork and modify this on GitHub (). 234 | -------------------------------------------------------------------------------- /alert.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # alert.sh 4 | # Author: Nils Knieling and Contributors- https://github.com/Cyclenerd/static_status 5 | 6 | # With this script you can send a notification when a check term occurs in the downtime file from status.sh 7 | # 8 | # The MY_HOSTNAME_STATUS_DOWN downtime file is searched with grep. 9 | # If the check term MY_CHECK is found, the seconds of the downtime are detected. 10 | # If the seconds of the downtime are greater than or equal to the defined seconds MY_ALERT_SEC, 11 | # an notification is triggered by email (mutt). The script is easily customizable to your own needs. 12 | # Alternative notification methods like SMS and Pushover are possible. 13 | # 14 | # Usage: alert.sh [-c ] [-m ] [-d ] [-h]: 15 | # [-c ] Check downtime file (default: www.nkn-it.de) 16 | # [-m ] Send notification to email address (default: root@localhost) 17 | # Alternatively, 'SMS' and 'Pushover' can be passed for alternative notification methods 18 | # [-d ] Notify if downtime is greater than N seconds (default: 300) 19 | # [-h] Displays help (this message) 20 | # 21 | # For notification by email the program 'mutt' is used. 22 | # 23 | # For notification by SMS the Perl script 'sipgate-sms.pl' is used. 24 | # Please see: https://github.com/Cyclenerd/notify-me/blob/master/sipgate-sms.pl 25 | # For notification by Pushover the Perl script 'pushover.pl' is used. 26 | # Please see: https://github.com/Cyclenerd/notify-me/blob/master/pushover.pl 27 | # If you use the Perl scripts always create the necessary configuration file. Only '--msg' is passed as parameter. 28 | # 29 | # Test notification without real check if downtime is present: 30 | # ./alert.sh -c "test notification" 31 | # ./alert.sh -c "test notification" -m "your@email.local" 32 | # ./alert.sh -c "test notification" -m "SMS" 33 | # ./alert.sh -c "test notification" -m "Pushover" 34 | # 35 | # Add this script to your crontab. Example: 36 | # */1 8-22 * * * bash alarm.sh -c "127.0.0.1" -m "nils@localhost" -d 60 37 | # */1 * * * * bash alarm.sh -c "nc;www.heise.de" -m "other@email.local" 38 | # 39 | # Tip! Combine checks. Alert only if the Google DNS server is reachable (Internet available): 40 | # grep -q "8.8.8.8" < status_hostname_ok.txt && bash alarm -c "www.nkn-it.de" -m "nils@localhost" 41 | # 42 | # Tested with Ubuntu 20.04 43 | 44 | MY_SCRIPT_NAME=$(basename "$0") 45 | BASE_PATH=$(dirname "$0") 46 | 47 | ################################################################################ 48 | #### Configuration Section 49 | ################################################################################ 50 | 51 | # Tip: You can also outsource configuration to an extra configuration file. 52 | # Just create a file named 'config' at the location of this script. 53 | 54 | # if a config file has been specified with MY_STATUS_CONFIG=myfile use this one, otherwise default to config 55 | if [[ -z "$MY_STATUS_CONFIG" ]]; then 56 | MY_STATUS_CONFIG="$BASE_PATH/config" 57 | fi 58 | if [ -e "$MY_STATUS_CONFIG" ]; then 59 | # ignore SC1090 60 | # shellcheck source=/dev/null 61 | source "$MY_STATUS_CONFIG" 62 | fi 63 | 64 | # Check if term MY_CHECK can be found in the MY_HOSTNAME_STATUS_DOWN downtime file for failures 65 | MY_CHECK=${MY_CHECK:-"www.nkn-it.de"} 66 | # Example: 67 | # Check if 'nkn-it.de' can be found and save the 805 seconds in MY_DOWN_SEC variable 68 | # status_hostname_down.txt: 69 | # curl;https://www.nkn-it.de/file_not_found;;805 70 | 71 | # Send notification to email address (program 'mutt' is used) 72 | MY_MAIL_TO=${MY_MAIL_TO:-"root@localhost"} 73 | 74 | # Send notification if downtime is greater than 75 | MY_ALERT_SEC=${MY_ALERT_SEC:-"300"} # 5 Minutes 76 | 77 | # Location for the downtime status file 78 | MY_STATUS_CONFIG_DIR=${MY_STATUS_CONFIG_DIR:-"$HOME/status"} 79 | MY_HOSTNAME_STATUS_DOWN=${MY_HOSTNAME_STATUS_DOWN:-"$MY_STATUS_CONFIG_DIR/status_hostname_down.txt"} 80 | MY_HOSTNAME_STATUS_DEGRADE=${MY_HOSTNAME_STATUS_DEGRADE:-"$MY_STATUS_CONFIG_DIR/status_hostname_degrade.txt"} 81 | 82 | ################################################################################ 83 | #### END Configuration Section 84 | ################################################################################ 85 | 86 | 87 | ################################################################################ 88 | # Usage 89 | ################################################################################ 90 | 91 | function usage { 92 | MY_RETURN_CODE="$1" 93 | echo -e "Usage: $MY_SCRIPT_NAME [-c ] [-m ] [-d ] [-h]: 94 | [-c ] Check downtime file (default: $MY_CHECK) 95 | [-m ] Send notification to email address (default: $MY_MAIL_TO) 96 | Alternative options: 'SMS', 'Pushover', or path to custom script 97 | [-d ] Notify if downtime is greater than N seconds (default: $MY_ALERT_SEC) 98 | [-h] Displays help (this message)" 99 | exit "$MY_RETURN_CODE" 100 | } 101 | 102 | ################################################################################ 103 | # MAIN 104 | ################################################################################ 105 | 106 | while getopts ":test:c:m:d:h" opt; do 107 | case $opt in 108 | c) 109 | MY_CHECK="$OPTARG" 110 | ;; 111 | m) 112 | MY_MAIL_TO="$OPTARG" 113 | ;; 114 | d) 115 | MY_ALERT_SEC="$OPTARG" 116 | ;; 117 | h) 118 | usage 0 119 | ;; 120 | *) 121 | echo "Invalid option: -$OPTARG" 122 | usage 1 123 | ;; 124 | esac 125 | done 126 | 127 | # Check commands 128 | command -v md5sum >/dev/null 2>&1 || { echo >&2 "!!! md5sum it's not installed. Please install."; exit 1; } 129 | command -v mutt >/dev/null 2>&1 || { echo >&2 "!!! mutt it's not installed. Please install."; exit 1; } 130 | 131 | # Check scripts for alternative notification methods 132 | if [[ "$MY_MAIL_TO" == "SMS" && ! -r "$HOME/sipgate-sms.pl" ]]; then 133 | # SMS : https://github.com/Cyclenerd/notify-me/blob/master/sipgate-sms.pl 134 | echo "!!! Can not read Perl script '$HOME/sipgate-sms.pl'." 135 | echo " Please download 'sipgate-sms.pl' and save it in your home folder:" 136 | echo ' curl -f "https://raw.githubusercontent.com/Cyclenerd/toolbox/master/sipgate-sms.pl" -o ~/sipgate-sms.pl' 137 | exit 9 138 | fi 139 | if [[ "$MY_MAIL_TO" == "Pushover" && ! -r "$HOME/pushover.pl" ]]; then 140 | # Pushover : https://github.com/Cyclenerd/notify-me/blob/master/pushover.pl 141 | echo "!!! Can not read Perl script '$HOME/pushover.pl'." 142 | echo " Please download 'pushover.pl' and save it in your home folder:" 143 | echo ' curl -f "https://raw.githubusercontent.com/Cyclenerd/toolbox/master/pushover.pl" -o ~/pushover.pl' 144 | exit 9 145 | fi 146 | if [[ -e "$MY_MAIL_TO" && ! -x "$MY_MAIL_TO" ]]; then 147 | echo "!!! Notification script '$MY_MAIL_TO' it's not executable." 148 | exit 9 149 | fi 150 | 151 | # Check downtime file 152 | if [ ! -r "$MY_HOSTNAME_STATUS_DOWN" ]; then 153 | echo "Can not read downtime file '$MY_HOSTNAME_STATUS_DOWN'" 154 | exit 9 155 | fi 156 | 157 | # Check downgrade file 158 | if [ ! -r "$MY_HOSTNAME_STATUS_DEGRADE" ]; then 159 | echo "Can not read downgrade file '$MY_HOSTNAME_STATUS_DEGRADE'" 160 | exit 9 161 | fi 162 | 163 | # Check term with grep 164 | MY_CHECK_MD5=$(echo "$MY_CHECK" | md5sum | grep -E -o '[a-z,0-9]+') 165 | MY_HOSTNAME_STATUS_ALERT="/tmp/status_hostname_alert_$MY_CHECK_MD5" 166 | MY_HOSTNAME_STATUS_ALERT_DEGRADE="/tmp/status_hostname_alert_degrade_$MY_CHECK_MD5" 167 | MY_DOWN_SEC=$(grep "$MY_CHECK" < "$MY_HOSTNAME_STATUS_DOWN" | grep -E -o '[0-9]+$') 168 | MY_DEGRADE_SEC=$(grep "$MY_CHECK" < "$MY_HOSTNAME_STATUS_DEGRADE" | grep -E -o '[0-9]+$') 169 | MY_DEGRADED_BEFORE="false" 170 | MY_ALERT_NOW="false" 171 | 172 | # Test to check setup 173 | if [[ "$MY_CHECK" == "test notification" ]]; then 174 | echo "TEST NOTIFICATION FROM HOSTNAME: '$HOSTNAME'" 175 | if [[ "$MY_MAIL_TO" == "SMS" ]]; then 176 | perl "$HOME/sipgate-sms.pl" --msg="Test from $HOSTNAME" && echo "(notified by SMS)" 177 | elif [[ "$MY_MAIL_TO" == "Pushover" ]]; then 178 | perl "$HOME/pushover.pl" --msg="Test from $HOSTNAME" && echo "(notified by Pushover)" 179 | # Use a script/binary 180 | elif [[ -x "$MY_MAIL_TO" ]]; then 181 | $MY_MAIL_TO "Test from $HOSTNAME" &> /dev/null && echo "(notified by script)" 182 | else 183 | echo "Test from $HOSTNAME" | mutt -s "TEST: This is a test" "$MY_MAIL_TO" && echo "(notified by email)" 184 | fi 185 | echo -n "TEST" > "$MY_HOSTNAME_STATUS_ALERT" 186 | rm -f "$MY_HOSTNAME_STATUS_ALERT" 187 | exit 188 | fi 189 | 190 | # MY_CHECK is down now and was degraded before 191 | if grep -q "$MY_CHECK" "$MY_HOSTNAME_STATUS_DOWN" && [ -f "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" ]; then 192 | MY_DEGRADED_BEFORE="true" 193 | MY_ALERT_TYPE="DOWN" 194 | MY_ALERT_NOW="true" 195 | fi 196 | 197 | # When downtime or degradatime is greater than MY_ALERT_SEC, we have to notify 198 | if [[ -n "$MY_DOWN_SEC" && "$MY_DOWN_SEC" -ge "$MY_ALERT_SEC" ]]; then 199 | MY_ALERT_TIME="$MY_DOWN_SEC" 200 | MY_ALERT_TYPE="DOWN" 201 | MY_ALERT_NOW="true" 202 | elif [[ -n "$MY_DEGRADE_SEC" && "$MY_DEGRADE_SEC" -ge "$MY_ALERT_SEC" ]]; then 203 | MY_ALERT_TIME="$MY_DEGRADE_SEC" 204 | MY_ALERT_TYPE="DEGRADED" 205 | MY_ALERT_NOW="true" 206 | fi 207 | 208 | # Check if downtime is greater than MY_ALERT_SEC 209 | if [ "$MY_ALERT_NOW" == "true" ]; then 210 | MY_ALERT_TYPE_LC=$(echo "$MY_ALERT_TYPE" | tr '[:upper:]' '[:lower:]') 211 | echo -n "$MY_ALERT_TYPE: $MY_CHECK is $MY_ALERT_TYPE_LC for $MY_ALERT_TIME sec." 212 | # Check if either MY_HOSTNAME_STATUS_ALERT or MY_HOSTNAME_STATUS_ALERT_DEGRADE (without MY_DEGRADED_BEFORE), then notification was sent already 213 | if [[ -f "$MY_HOSTNAME_STATUS_ALERT" ]]; then 214 | echo "(already notified)" 215 | # Update downtime 216 | echo -n "$MY_DOWN_SEC" > "$MY_HOSTNAME_STATUS_ALERT" 217 | elif [[ -f "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" && "$MY_DEGRADED_BEFORE" == "false" ]]; then 218 | echo "(already notified)" 219 | # Update degradetime 220 | echo -n "$MY_DEGRADE_SEC" > "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" 221 | else 222 | # Update degradetime or downtime 223 | if [ -n "$MY_DEGRADE_SEC" ]; then 224 | echo -n "$MY_DEGRADE_SEC" > "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" 225 | else 226 | echo -n "$MY_DOWN_SEC" > "$MY_HOSTNAME_STATUS_ALERT" 227 | fi 228 | # Send notification and safe alert 229 | if [[ "$MY_MAIL_TO" == "SMS" ]]; then 230 | perl "$HOME/sipgate-sms.pl" --msg="$MY_CHECK is $MY_ALERT_TYPE_LC from $HOSTNAME" && echo "(notified by SMS)" 231 | elif [[ "$MY_MAIL_TO" == "Pushover" ]]; then 232 | perl "$HOME/pushover.pl" --msg="$MY_CHECK is $MY_ALERT_TYPE_LC from $HOSTNAME" && echo "(notified by Pushover)" 233 | # Use a script/binary 234 | elif [[ -x "$MY_MAIL_TO" ]]; then 235 | $MY_MAIL_TO "$MY_CHECK is $MY_ALERT_TYPE_LC from $HOSTNAME" &> /dev/null && echo "(notified by script)" 236 | else 237 | echo "$MY_CHECK is $MY_ALERT_TYPE_LC" | mutt -s "$MY_ALERT_TYPE: $MY_CHECK" "$MY_MAIL_TO" && echo "(notified by email)" 238 | fi 239 | fi 240 | exit # Exit program to prevent further checks 241 | fi 242 | 243 | # Check if MY_HOSTNAME_STATUS_ALERT file exists. 244 | # This means that an notification was already send. 245 | # When the program gets here, the MY_CHECK term is no longer in the MY_HOSTNAME_STATUS_DOWN file and the alert can be deleted. 246 | if [[ -f "$MY_HOSTNAME_STATUS_ALERT" || -f "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" ]]; then 247 | echo -n "UP: $MY_CHECK is up again." 248 | 249 | # Remove downtime and degradetime alert 250 | if [ -f "$MY_HOSTNAME_STATUS_ALERT" ]; then 251 | rm -f "$MY_HOSTNAME_STATUS_ALERT" 252 | fi 253 | if [ -f "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" ]; then 254 | rm -f "$MY_HOSTNAME_STATUS_ALERT_DEGRADE" 255 | fi 256 | 257 | # Send notification and safe alert 258 | if [[ "$MY_MAIL_TO" == "SMS" ]]; then 259 | perl "$HOME/sipgate-sms.pl" --msg="$MY_CHECK is up again from $HOSTNAME" && echo "(notified by SMS)" 260 | # Pushover : https://github.com/Cyclenerd/notify-me/blob/master/pushover.pl 261 | elif [[ "$MY_MAIL_TO" == "Pushover" ]]; then 262 | perl "$HOME/pushover.pl" --msg="$MY_CHECK is up again from $HOSTNAME" && echo "(notified by Pushover)" 263 | # Use a script/binary 264 | elif [[ -x "$MY_MAIL_TO" ]]; then 265 | $MY_MAIL_TO "$MY_CHECK is up again from $HOSTNAME" &> /dev/null && echo "(notified by script)" 266 | # Email : mutt 267 | else 268 | echo "$MY_CHECK is up again" | mutt -s "UP: $MY_CHECK" "$MY_MAIL_TO" && echo "(notified)" 269 | fi 270 | fi 271 | -------------------------------------------------------------------------------- /config-example: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #### Configuration Section 3 | ################################################################################ 4 | 5 | # Title for the status page 6 | MY_STATUS_TITLE="Status Page" 7 | 8 | # Link for the homepage button 9 | MY_HOMEPAGE_URL="https://github.com/Cyclenerd/static_status" 10 | 11 | # Text for the homepage button 12 | MY_HOMEPAGE_TITLE="Homepage" 13 | 14 | # Auto refresh interval in seconds 0 is no refresh 15 | MY_AUTOREFRESH="0" 16 | 17 | # Shortcut to place the configuration file in a folder. 18 | # Save it without / at the end. 19 | MY_STATUS_CONFIG_DIR="$HOME/status" 20 | 21 | # List with the configuration. What do we want to monitor? 22 | MY_HOSTNAME_FILE="$MY_STATUS_CONFIG_DIR/status_hostname_list.txt" 23 | 24 | # Where should the HTML status page be stored? 25 | MY_STATUS_HTML="$HOME/status_index.html" 26 | 27 | # Where should the SVG status icon be stored? 28 | MY_STATUS_ICON="$HOME/status.svg" 29 | # Icon colors 30 | MY_STATUS_ICON_COLOR_SUCCESS="lime" 31 | MY_STATUS_ICON_COLOR_WARNING="orange" 32 | MY_STATUS_ICON_COLOR_DANGER="red" 33 | 34 | # Where should the JSON status page be stored? Set to "" to disable JSON output 35 | MY_STATUS_JSON="$HOME/status.json" 36 | 37 | # Text file in which you can place a status message. 38 | # If the file exists and has a content, all errors on the status page are overwritten. 39 | MY_MAINTENANCE_TEXT_FILE="$MY_STATUS_CONFIG_DIR/status_maintenance_text.txt" 40 | 41 | # Duration we wait for response (nc, curl and traceroute). 42 | MY_TIMEOUT="2" 43 | 44 | # Duration we wait for response (only ping). 45 | MY_PING_TIMEOUT="4" 46 | MY_PING_COUNT="2" 47 | 48 | # Duration we wait for response (only script). 49 | MY_SCRIPT_TIMEOUT="20" 50 | 51 | # Route to host 52 | MY_TRACEROUTE_HOST="1.1.1.1" # Cloudflare DNS 53 | # Sets the number of probe packets per hop 54 | MY_TRACEROUTE_NQUERIES="1" 55 | 56 | # Location for the status files. Please do not edit created files. 57 | MY_HOSTNAME_STATUS_OK="$MY_STATUS_CONFIG_DIR/status_hostname_ok.txt" 58 | MY_HOSTNAME_STATUS_DOWN="$MY_STATUS_CONFIG_DIR/status_hostname_down.txt" 59 | MY_HOSTNAME_STATUS_LASTRUN="$MY_STATUS_CONFIG_DIR/status_hostname_last.txt" 60 | MY_HOSTNAME_STATUS_DEGRADE="$MY_STATUS_CONFIG_DIR/status_hostname_degrade.txt" 61 | MY_HOSTNAME_STATUS_LASTRUN_DEGRADE="$MY_STATUS_CONFIG_DIR/status_hostname_last_degrade.txt" 62 | MY_HOSTNAME_STATUS_HISTORY="$MY_STATUS_CONFIG_DIR/status_hostname_history.txt" 63 | MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT="/tmp/status_hostname_history_sort.txt" 64 | 65 | # Minimum downtime in seconds to display in past incidents 66 | MY_MIN_DOWN_TIME="60" 67 | 68 | # CSS Stylesheet for the status page 69 | MY_STATUS_STYLESHEET="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" 70 | 71 | # FontAwesome for the status page 72 | MY_STATUS_FONTAWESOME="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" 73 | 74 | # A footer 75 | MY_STATUS_FOOTER='Powered by static_status' 76 | 77 | # Lock file to prevent duplicate execution. 78 | # If this file exists, status.sh script is terminated. 79 | # If something has gone wrong and the file has not been deleted automatically, you can delete it. 80 | MY_STATUS_LOCKFILE="/tmp/STATUS_SH_IS_RUNNING.lock" 81 | 82 | # Hook to call when a hostname status changes 83 | # The hook script must be executable and receives three arguments: 84 | # 1. New status, either up, down or degraded 85 | # 2. Command used 86 | # 3. Hostname 87 | MY_HOOK_STATUS="" 88 | 89 | # Date format for the web page. 90 | # UTC (`-u`) is the default. 91 | # Example: 2021-12-23 12:34:55 UTC 92 | # More details can be found in `man date`. 93 | # Avoid semicolons. 94 | MY_DATE_TIME=$(date -u "+%Y-%m-%d %H:%M:%S %Z") 95 | 96 | # Tip: You can tweak curl parameters via .curlrc config file. 97 | # The default curl config file is checked for in the following places in this order: 98 | # 1. "$CURL_HOME/.curlrc" 99 | # 2. "$HOME/.curlrc" 100 | # 101 | # ~~~ Example .curlrc file ~~~ 102 | # # this is a comment 103 | # # change the useragent string 104 | # -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0" 105 | # # ok if certification validation fails 106 | # --insecure 107 | # ~~~ End of example file ~~~ 108 | -------------------------------------------------------------------------------- /images/Status-Page-Custom-Text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Custom-Text.png -------------------------------------------------------------------------------- /images/Status-Page-Maintenance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Maintenance.jpg -------------------------------------------------------------------------------- /images/Status-Page-Major_Outage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Major_Outage.jpg -------------------------------------------------------------------------------- /images/Status-Page-OK.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-OK.jpg -------------------------------------------------------------------------------- /images/Status-Page-Outage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Outage.jpg -------------------------------------------------------------------------------- /images/Status-Page-Past-Incidents.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Past-Incidents.jpg -------------------------------------------------------------------------------- /images/Status-Page-Screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyclenerd/static_status/4e40daa4b51da824703eb9af490c2fd266a067f1/images/Status-Page-Screenshot.jpg -------------------------------------------------------------------------------- /scripts/check-websites.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR=$(dirname "$(readlink -f "$0")") 3 | WEBSITES=$(cat "$DIR"/../status_website_list.txt) 4 | TIMEOUT="10" 5 | for WEBSITE in $WEBSITES 6 | do 7 | # Check multiple websites and exit with returncode 80 if one is failing 8 | /usr/bin/curl --write-out "%{http_code}" --silent --location --head --max-time "$TIMEOUT" "$WEBSITE" --output /dev/null | grep -q "200" || exit 80 9 | done 10 | exit 0 11 | -------------------------------------------------------------------------------- /status.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # status.sh 4 | # Author: Nils Knieling and Contributors- https://github.com/Cyclenerd/static_status 5 | 6 | # Simple Bash script to generate a status page. 7 | 8 | ME=$(basename "$0") 9 | BASE_PATH=$(dirname "$0") 10 | MY_TIMESTAMP=$(date -u "+%s") 11 | MY_LASTRUN_TIME="0" 12 | BE_LOUD="no" 13 | BE_QUIET="no" 14 | 15 | ################################################################################ 16 | # Usage 17 | ################################################################################ 18 | 19 | function usage { 20 | returnCode="$1" 21 | echo -e "Usage: $ME [OPTION]: 22 | OPTION is one of the following: 23 | \\t silent no output from faulty connections to stout (default: $BE_QUIET) 24 | \\t loud output from successful and faulty connections to stout (default: $BE_LOUD) 25 | \\t debug displays all variables 26 | \\t help displays help (this message)" 27 | exit "$returnCode" 28 | } 29 | 30 | case "$1" in 31 | "") 32 | # called without arguments 33 | ;; 34 | "silent") 35 | BE_QUIET="yes" 36 | ;; 37 | "loud") 38 | BE_LOUD="yes" 39 | ;; 40 | "debug") 41 | ONLY_OUTPUT_DEBUG_VARIABLES="yes" 42 | ;; 43 | "h" | "help" | "-h" | "-help" | "-?" | *) 44 | usage 0 45 | ;; 46 | esac 47 | 48 | ################################################################################ 49 | #### Configuration Section 50 | ################################################################################ 51 | 52 | # Tip: You can also outsource configuration to an extra configuration file. 53 | # Just create a file named 'config' at the location of this script. 54 | # You can find an example here: 55 | # https://github.com/Cyclenerd/static_status/blob/master/config-example 56 | # You can also pass a configuration file with the variable MY_STATUS_CONFIG. 57 | 58 | # if a config file has been specified with MY_STATUS_CONFIG=myfile use this one, otherwise default to config 59 | if [[ -z "$MY_STATUS_CONFIG" ]]; then 60 | MY_STATUS_CONFIG="$BASE_PATH/config" 61 | fi 62 | if [ -e "$MY_STATUS_CONFIG" ]; then 63 | if [[ "$BE_LOUD" = "yes" ]] || [[ "$BE_QUIET" = "no" ]]; then 64 | echo "using config from file: $MY_STATUS_CONFIG" 65 | fi 66 | # ignore SC1090 67 | # shellcheck source=/dev/null 68 | source "$MY_STATUS_CONFIG" 69 | fi 70 | 71 | # Tip: You can tweak curl parameters via .curlrc config file. 72 | # The default curl config file is checked for in the following places in this order: 73 | # 1. "$CURL_HOME/.curlrc" 74 | # 2. "$HOME/.curlrc" 75 | # 76 | # ~~~ Example .curlrc file ~~~ 77 | # # this is a comment 78 | # # change the useragent string 79 | # -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0" 80 | # # ok if certification validation fails 81 | # --insecure 82 | # ~~~ End of example file ~~~ 83 | 84 | # Title for the status page 85 | MY_STATUS_TITLE=${MY_STATUS_TITLE:-"Status Page"} 86 | 87 | # Link for the homepage button 88 | MY_HOMEPAGE_URL=${MY_HOMEPAGE_URL:-"https://github.com/Cyclenerd/static_status"} 89 | 90 | # Text for the homepage button 91 | MY_HOMEPAGE_TITLE=${MY_HOMEPAGE_TITLE:-"Homepage"} 92 | 93 | # Auto refresh interval in seconds 0 is no refresh 94 | MY_AUTOREFRESH=${MY_AUTOREFRESH:-"0"} 95 | 96 | # Shortcut to place the configuration file in a folder. 97 | # Save it without / at the end. 98 | MY_STATUS_CONFIG_DIR=${MY_STATUS_CONFIG_DIR:-"$HOME/status"} 99 | 100 | # List with the configuration. What do we want to monitor? 101 | MY_HOSTNAME_FILE=${MY_HOSTNAME_FILE:-"$MY_STATUS_CONFIG_DIR/status_hostname_list.txt"} 102 | 103 | # Where should the HTML status page be stored? 104 | MY_STATUS_HTML=${MY_STATUS_HTML:-"$HOME/status_index.html"} 105 | 106 | # Where should the SVG status icon be stored? 107 | MY_STATUS_ICON=${MY_STATUS_ICON:-"$HOME/status.svg"} 108 | # Icon colors 109 | MY_STATUS_ICON_COLOR_SUCCESS=${MY_STATUS_ICON_COLOR_SUCCESS:-"lime"} 110 | MY_STATUS_ICON_COLOR_WARNING=${MY_STATUS_ICON_COLOR_WARNING:-"orange"} 111 | MY_STATUS_ICON_COLOR_DANGER=${MY_STATUS_ICON_COLOR_DANGER:-"red"} 112 | 113 | # Where should the JSON status page be stored? Set to "" to disable JSON output 114 | MY_STATUS_JSON=${MY_STATUS_JSON:-"$HOME/status.json"} 115 | 116 | # Text file in which you can place a status message. 117 | # If the file exists and has a content, all errors on the status page are overwritten. 118 | MY_MAINTENANCE_TEXT_FILE=${MY_MAINTENANCE_TEXT_FILE:-"$MY_STATUS_CONFIG_DIR/status_maintenance_text.txt"} 119 | 120 | # Duration we wait for response (nc, curl and traceroute). 121 | MY_TIMEOUT=${MY_TIMEOUT:-"2"} 122 | 123 | # Duration we wait for response (only ping). 124 | MY_PING_TIMEOUT=${MY_PING_TIMEOUT:-"4"} 125 | MY_PING_COUNT=${MY_PING_COUNT:-"2"} 126 | 127 | # Duration we wait for response (only script) 128 | MY_SCRIPT_TIMEOUT=${MY_SCRIPT_TIMEOUT:-20} 129 | 130 | # Route to host 131 | MY_TRACEROUTE_HOST=${MY_TRACEROUTE_HOST:-"1.1.1.1"} # Cloudflare DNS 132 | # Sets the number of probe packets per hop 133 | MY_TRACEROUTE_NQUERIES=${MY_TRACEROUTE_NQUERIES:-"1"} 134 | 135 | # Location for the status files. Please do not edit created files. 136 | MY_HOSTNAME_STATUS_OK=${MY_HOSTNAME_STATUS_OK:-"$MY_STATUS_CONFIG_DIR/status_hostname_ok.txt"} 137 | MY_HOSTNAME_STATUS_DOWN=${MY_HOSTNAME_STATUS_DOWN:-"$MY_STATUS_CONFIG_DIR/status_hostname_down.txt"} 138 | MY_HOSTNAME_STATUS_LASTRUN=${MY_HOSTNAME_STATUS_LASTRUN:-"$MY_STATUS_CONFIG_DIR/status_hostname_last.txt"} 139 | MY_HOSTNAME_STATUS_DEGRADE=${MY_HOSTNAME_STATUS_DEGRADE:-"$MY_STATUS_CONFIG_DIR/status_hostname_degrade.txt"} 140 | MY_HOSTNAME_STATUS_LASTRUN_DEGRADE=${MY_HOSTNAME_STATUS_LASTRUN_DEGRADE:-"$MY_STATUS_CONFIG_DIR/status_hostname_last_degrade.txt"} 141 | MY_HOSTNAME_STATUS_HISTORY=${MY_HOSTNAME_STATUS_HISTORY:-"$MY_STATUS_CONFIG_DIR/status_hostname_history.txt"} 142 | MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT=${MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT:-"/tmp/status_hostname_history_sort.txt"} 143 | 144 | # Minimum downtime in seconds to display in past incidents 145 | MY_MIN_DOWN_TIME=${MY_MIN_DOWN_TIME:-"60"} 146 | 147 | # CSS Stylesheet for the status page 148 | MY_STATUS_STYLESHEET=${MY_STATUS_STYLESHEET:-"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css"} 149 | 150 | # FontAwesome for the status page 151 | MY_STATUS_FONTAWESOME=${MY_STATUS_FONTAWESOME:-"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"} 152 | 153 | # A footer 154 | MY_STATUS_FOOTER=${MY_STATUS_FOOTER:-'Powered by static_status'} 155 | 156 | # Lock file to prevent duplicate execution. 157 | # If this file exists, status.sh script is terminated. 158 | # If something has gone wrong and the file has not been deleted automatically, you can delete it. 159 | MY_STATUS_LOCKFILE=${MY_STATUS_LOCKFILE:-"/tmp/STATUS_SH_IS_RUNNING.lock"} 160 | 161 | # Date format for the web page. 162 | # UTC (`-u`) is the default. 163 | # Example: 2021-12-23 12:34:55 UTC 164 | MY_DATE_TIME=${MY_DATE_TIME:-$(date -u "+%Y-%m-%d %H:%M:%S %Z")} 165 | # Can be changed. Example with system time: 166 | # MY_DATE_TIME=$(date "+%Y-%m-%d %H:%M:%S") 167 | # Avoid semicolons. 168 | # More details can be found in `man date`. 169 | 170 | # Hook to call when a hostname status changes 171 | # The hook script must be executable and receives three arguments: 172 | # 1. New status, either up, down or degraded 173 | # 2. Command used 174 | # 3. Hostname 175 | MY_HOOK_STATUS=${MY_HOOK_STATUS:-""} 176 | 177 | ################################################################################ 178 | #### END Configuration Section 179 | ################################################################################ 180 | 181 | 182 | ################################################################################ 183 | # Helper 184 | ################################################################################ 185 | 186 | # debug_variables() print all script global variables to ease debugging 187 | debug_variables() { 188 | echo "USER: $USER" 189 | echo "SHELL: $SHELL" 190 | echo "BASH_VERSION: $BASH_VERSION" 191 | echo 192 | echo "MY_COMMANDS:" 193 | for MY_COMMAND in "${MY_COMMANDS[@]}"; do 194 | echo " $MY_COMMAND" 195 | done 196 | echo 197 | echo "MY_TIMEOUT: $MY_TIMEOUT" 198 | echo "MY_STATUS_CONFIG: $MY_STATUS_CONFIG" 199 | echo "MY_STATUS_CONFIG_DIR: $MY_STATUS_CONFIG_DIR" 200 | echo "MY_HOSTNAME_FILE: $MY_HOSTNAME_FILE" 201 | echo "MY_HOSTNAME_STATUS_OK: $MY_HOSTNAME_STATUS_OK" 202 | echo "MY_HOSTNAME_STATUS_DOWN: $MY_HOSTNAME_STATUS_DOWN" 203 | echo "MY_HOSTNAME_STATUS_LASTRUN: $MY_HOSTNAME_STATUS_LASTRUN" 204 | echo "MY_HOSTNAME_STATUS_DEGRADE: $MY_HOSTNAME_STATUS_DEGRADE" 205 | echo "MY_HOSTNAME_STATUS_LASTRUN_DEGRADE: $MY_HOSTNAME_STATUS_LASTRUN_DEGRADE" 206 | echo "MY_HOSTNAME_STATUS_HISTORY: $MY_HOSTNAME_STATUS_HISTORY" 207 | echo 208 | echo "MY_STATUS_HTML: $MY_STATUS_HTML" 209 | echo "MY_STATUS_ICON: $MY_STATUS_ICON" 210 | echo "MY_STATUS_JSON: $MY_STATUS_JSON" 211 | echo "MY_MAINTENANCE_TEXT_FILE: $MY_MAINTENANCE_TEXT_FILE" 212 | echo "MY_HOMEPAGE_URL: $MY_HOMEPAGE_URL" 213 | echo "MY_HOMEPAGE_TITLE: $MY_HOMEPAGE_TITLE" 214 | echo "MY_STATUS_TITLE: $MY_STATUS_TITLE" 215 | echo "MY_STATUS_STYLESHEET: $MY_STATUS_STYLESHEET" 216 | echo "MY_STATUS_FOOTER: $MY_STATUS_FOOTER" 217 | echo 218 | echo "MY_STATUS_LOCKFILE: $MY_STATUS_LOCKFILE" 219 | echo 220 | echo "MY_TIMEOUT: $MY_TIMEOUT" 221 | echo "MY_PING_TIMEOUT: $MY_PING_TIMEOUT" 222 | echo "MY_PING_COUNT: $MY_PING_COUNT" 223 | echo "MY_SCRIPT_TIMEOUT: $MY_SCRIPT_TIMEOUT" 224 | echo "MY_TRACEROUTE_HOST: $MY_TRACEROUTE_HOST" 225 | echo "MY_TRACEROUTE_NQUERIES: $MY_TRACEROUTE_NQUERIES" 226 | echo 227 | echo "MY_TIMESTAMP: $MY_TIMESTAMP" 228 | echo "MY_DATE_TIME: $MY_DATE_TIME" 229 | echo "MY_LASTRUN_TIME: $MY_LASTRUN_TIME" 230 | echo 231 | echo "MY_HOOK_STATUS: $MY_HOOK_STATUS" 232 | } 233 | 234 | # command_exists() tells if a given command exists. 235 | function command_exists() { 236 | command -v "$1" >/dev/null 2>&1 237 | } 238 | 239 | # check_bash() check if current shell is bash 240 | function check_bash() { 241 | if [[ "$0" == *"bash" ]]; then 242 | exit_with_failure "Your current shell is $0" 243 | fi 244 | } 245 | 246 | # check_command() check if command exists and exit if not exists 247 | function check_command() { 248 | if ! command_exists "$1"; then 249 | exit_with_failure "Command '$1' not found" 250 | fi 251 | } 252 | 253 | # check_config() check if the configuration file is readable 254 | function check_config() { 255 | if [ ! -r "$1" ]; then 256 | exit_with_failure "Can not read required configuration file '$1'" 257 | fi 258 | } 259 | 260 | # check_file() check if the file exists if not create the file 261 | function check_file() { 262 | if [ ! -f "$1" ]; then 263 | if ! echo > "$1"; then 264 | exit_with_failure "Can not create file '$1'" 265 | fi 266 | fi 267 | if [ ! -w "$1" ]; then 268 | exit_with_failure "Can not write file '$1'" 269 | fi 270 | } 271 | 272 | # exit_with_failure() outputs a message before exiting the script. 273 | function exit_with_failure() { 274 | echo 275 | echo "FAILURE: $1" 276 | echo 277 | debug_variables 278 | echo 279 | del_lock 280 | exit 1 281 | } 282 | 283 | # echo_warning() outputs a warning message. 284 | function echo_warning() { 285 | echo 286 | echo "WARNING: $1, will attempt to continue..." 287 | echo 288 | } 289 | 290 | # echo_do_not_edit() outputs a "do not edit" message to write to a file 291 | function echo_do_not_edit() { 292 | echo "#" 293 | echo "# !!! Do not edit this file !!!" 294 | echo "#" 295 | echo "# To reset everything, delete the files:" 296 | echo "# $MY_HOSTNAME_STATUS_OK" 297 | echo "# $MY_HOSTNAME_STATUS_DOWN" 298 | echo "# $MY_HOSTNAME_STATUS_LASTRUN" 299 | echo "# $MY_HOSTNAME_STATUS_DEGRADE" 300 | echo "# $MY_HOSTNAME_STATUS_LASTRUN_DEGRADE" 301 | echo "# $MY_HOSTNAME_STATUS_HISTORY" 302 | echo "#" 303 | } 304 | 305 | # set_lock() sets lock file 306 | function set_lock() { 307 | if ! echo "$MY_DATE_TIME" > "$MY_STATUS_LOCKFILE"; then 308 | exit_with_failure "Can not create lock file '$MY_STATUS_LOCKFILE'" 309 | fi 310 | } 311 | 312 | # del_lock() deletes lock file 313 | function del_lock() { 314 | rm "$MY_STATUS_LOCKFILE" &> /dev/null 315 | } 316 | 317 | # check_lock() checks lock file and exit if the file exists 318 | function check_lock() { 319 | if [ -f "$MY_STATUS_LOCKFILE" ]; then 320 | exit_with_failure "$ME is already running. Please wait... In case of problems simply delete the file: '$MY_STATUS_LOCKFILE'" 321 | fi 322 | } 323 | 324 | # port_to_name() outputs name of well-known ports 325 | # https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports 326 | function port_to_name() { 327 | case "$1" in 328 | 32[0-9][0-9]) 329 | MY_PORT_NAME="SAP Dispatcher" 330 | ;; 331 | 33[0-9][0-9]) 332 | MY_PORT_NAME="SAP Gateway" 333 | ;; 334 | 80[0-9][0-9]) 335 | MY_PORT_NAME="SAP ICM HTTP" 336 | ;; 337 | 443[0-9][0-9]) 338 | MY_PORT_NAME="SAP ICM HTTPS" 339 | ;; 340 | 36[0-9][0-9]) 341 | MY_PORT_NAME="SAP Message Server" 342 | ;; 343 | 5[0-9][0-9]00) 344 | MY_PORT_NAME="SAP J2EE HTTP" 345 | ;; 346 | 5[0-9][0-9]01) 347 | MY_PORT_NAME="SAP J2EE HTTPS" 348 | ;; 349 | 5[0-9][0-9]04) 350 | MY_PORT_NAME="SAP P4" 351 | ;; 352 | 5[0-9][0-9]08) 353 | MY_PORT_NAME="SAP Telnet" 354 | ;; 355 | *) 356 | MY_SERVICE_NAME=$(awk '$2 ~ /^'"$1"'\// {print $1; exit}' "/etc/services" 2> /dev/null) 357 | if [ -n "$MY_SERVICE_NAME" ]; then 358 | MY_PORT_NAME=$(echo "$MY_SERVICE_NAME" | awk '{print toupper($0)}') 359 | else 360 | MY_PORT_NAME="Port $1" 361 | fi 362 | ;; 363 | esac 364 | printf "%s" "$MY_PORT_NAME" 365 | } 366 | 367 | # get_lastrun_time() 368 | function get_lastrun_time() { 369 | while IFS=';' read -r MY_LASTRUN_COMMAND MY_LASTRUN_TIMESTAMP || [[ -n "$MY_LASTRUN_COMMAND" ]]; do 370 | if [[ "$MY_LASTRUN_COMMAND" = "timestamp" ]]; then 371 | if [ "$MY_LASTRUN_TIMESTAMP" -ge "0" ]; then 372 | MY_LASTRUN_TIME="$((MY_TIMESTAMP-MY_LASTRUN_TIMESTAMP))" 373 | else 374 | MY_LASTRUN_TIME="0" 375 | fi 376 | fi 377 | done <"$MY_HOSTNAME_STATUS_LASTRUN" 378 | } 379 | 380 | # check_downtime() check whether a failure has already been documented 381 | # and determine the duration 382 | function check_downtime() { 383 | MY_COMMAND="$1" 384 | MY_HOSTNAME="$2" 385 | MY_PORT="$3" 386 | MY_DOWN_TIME="0" 387 | while IFS=';' read -r MY_DOWN_COMMAND MY_DOWN_HOSTNAME MY_DOWN_PORT MY_DOWN_TIME || [[ -n "$MY_DOWN_COMMAND" ]]; do 388 | if [[ "$MY_DOWN_COMMAND" = "ping" ]] || 389 | [[ "$MY_DOWN_COMMAND" = "ping6" ]] || 390 | [[ "$MY_DOWN_COMMAND" = "nc" ]] || 391 | [[ "$MY_DOWN_COMMAND" = "grep" ]] || 392 | [[ "$MY_DOWN_COMMAND" = "traceroute" ]] || 393 | [[ "$MY_DOWN_COMMAND" = "curl" ]] || 394 | [[ "$MY_DOWN_COMMAND" = "http-status" ]] || 395 | [[ "$MY_DOWN_COMMAND" = "script" ]]; then 396 | if [[ "$MY_DOWN_HOSTNAME" = "$MY_HOSTNAME" ]]; then 397 | if [[ "$MY_DOWN_PORT" = "$MY_PORT" ]]; then 398 | MY_DOWN_TIME="$((MY_DOWN_TIME+MY_LASTRUN_TIME))" 399 | break # Skip entire rest of loop. 400 | fi 401 | fi 402 | fi 403 | done <"$MY_HOSTNAME_STATUS_LASTRUN" # MY_HOSTNAME_STATUS_DOWN is copied to MY_HOSTNAME_STATUS_LASTRUN 404 | } 405 | 406 | # check_degradetime() check whether a degradation has already been documented 407 | # and determine the duration 408 | function check_degradetime() { 409 | MY_COMMAND="$1" 410 | MY_HOSTNAME="$2" 411 | MY_DEGRADE_TIME="0" 412 | while IFS=';' read -r MY_DEGRADE_COMMAND MY_DEGRADE_HOSTNAME MY_DEGRADE_TIME || [[ -n "$MY_DEGRADE_COMMAND" ]]; do 413 | if [[ "$MY_DEGRADE_COMMAND" = "script" ]]; then 414 | if [[ "$MY_DEGRADE_HOSTNAME" = "$MY_HOSTNAME" ]]; then 415 | MY_DEGRADE_TIME="$((MY_DEGRADE_TIME+MY_LASTRUN_TIME))" 416 | break # Skip entire rest of loop. 417 | fi 418 | fi 419 | done <"$MY_HOSTNAME_STATUS_LASTRUN_DEGRADE" # MY_HOSTNAME_STATUS_DEGRADE is copied to MY_HOSTNAME_STATUS_LASTRUN_DEGRADE 420 | } 421 | 422 | # save_downtime() 423 | function save_downtime() { 424 | MY_COMMAND="$1" 425 | MY_HOSTNAME="$2" 426 | MY_PORT="$3" 427 | MY_DOWN_TIME="$4" 428 | printf "\\n%s;%s;%s;%s" "$MY_COMMAND" "$MY_HOSTNAME" "$MY_PORT" "$MY_DOWN_TIME" >> "$MY_HOSTNAME_STATUS_DOWN" 429 | if [[ "$BE_LOUD" = "yes" ]] || [[ "$BE_QUIET" = "no" ]]; then 430 | printf "\\n%-5s %-4s %s" "DOWN:" "$MY_COMMAND" "$MY_HOSTNAME" 431 | if [[ $MY_COMMAND == "nc" ]]; then 432 | printf " %s" "$(port_to_name "$MY_PORT")" 433 | fi 434 | if [[ $MY_COMMAND == "grep" ]]; then 435 | printf " %s" "$MY_PORT" 436 | fi 437 | if [[ $MY_COMMAND == "http-status" ]]; then 438 | printf " %s" "$MY_PORT" 439 | fi 440 | fi 441 | 442 | if [[ -x "${MY_HOOK_STATUS}" ]] && ! grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN}" &> /dev/null; then 443 | ${MY_HOOK_STATUS} "down" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null 444 | fi 445 | } 446 | 447 | # save_degradetime() 448 | function save_degradetime() { 449 | MY_COMMAND="$1" 450 | MY_HOSTNAME="$2" 451 | MY_DEGRADE_TIME="$3" 452 | printf "\\n%s;%s;%s" "$MY_COMMAND" "$MY_HOSTNAME" "$MY_DEGRADE_TIME" >> "$MY_HOSTNAME_STATUS_DEGRADE" 453 | if [[ "$BE_LOUD" = "yes" ]] || [[ "$BE_QUIET" = "no" ]]; then 454 | printf "\\n%-5s %-4s %s" "DEGRADED:" "$MY_COMMAND" "$MY_HOSTNAME" 455 | fi 456 | 457 | if [[ -x "${MY_HOOK_STATUS}" ]] && ! grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN_DEGRADE}" &>/dev/null; then 458 | ${MY_HOOK_STATUS} "degraded" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null 459 | fi 460 | } 461 | 462 | # save_availability() 463 | function save_availability() { 464 | MY_COMMAND="$1" 465 | MY_HOSTNAME="$2" 466 | MY_PORT="$3" 467 | printf "\\n%s;%s;%s" "$MY_COMMAND" "$MY_HOSTNAME" "$MY_PORT" >> "$MY_HOSTNAME_STATUS_OK" 468 | if [[ "$BE_LOUD" = "yes" ]]; then 469 | printf "\\n%-5s %-4s %s" "UP:" "$MY_COMMAND" "$MY_HOSTNAME" 470 | if [[ $MY_COMMAND == "nc" ]]; then 471 | printf " %s" "$(port_to_name "$MY_PORT")" 472 | fi 473 | if [[ $MY_COMMAND == "grep" ]]; then 474 | printf " %s" "$MY_PORT" 475 | fi 476 | if [[ $MY_COMMAND == "http-status" ]]; then 477 | printf " %s" "$MY_PORT" 478 | fi 479 | fi 480 | 481 | if [[ -x "${MY_HOOK_STATUS}" ]]; then 482 | if grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN}" &>/dev/null || grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN_DEGRADE}" &>/dev/null; then 483 | ${MY_HOOK_STATUS} "up" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null 484 | fi 485 | fi 486 | } 487 | 488 | # save_history() 489 | function save_history() { 490 | MY_COMMAND="$1" 491 | MY_HOSTNAME="$2" 492 | MY_PORT="$3" 493 | MY_DOWN_TIME="$4" 494 | MY_DATE_TIME="$5" 495 | if cp "$MY_HOSTNAME_STATUS_HISTORY" "$MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT" &> /dev/null; then 496 | printf "\\n%s;%s;%s;%s;%s" "$MY_COMMAND" "$MY_HOSTNAME" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" > "$MY_HOSTNAME_STATUS_HISTORY" 497 | cat "$MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT" >> "$MY_HOSTNAME_STATUS_HISTORY" 498 | rm "$MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT" &> /dev/null 499 | else 500 | exit_with_failure "Can not copy file '$MY_HOSTNAME_STATUS_HISTORY' to '$MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT'" 501 | fi 502 | if [[ "$BE_LOUD" = "yes" ]]; then 503 | printf "\\n%-5s %-4s %s %s sec" "HIST:" "$MY_COMMAND" "$MY_HOSTNAME" "$MY_DOWN_TIME" 504 | if [[ $MY_COMMAND == "nc" ]]; then 505 | printf " %s" "$(port_to_name "$MY_PORT")" 506 | fi 507 | if [[ $MY_COMMAND == "grep" ]]; then 508 | printf " %s" "$MY_PORT" 509 | fi 510 | if [[ $MY_COMMAND == "http-status" ]]; then 511 | printf " %s" "$MY_PORT" 512 | fi 513 | fi 514 | } 515 | 516 | 517 | ################################################################################ 518 | # HTML 519 | ################################################################################ 520 | 521 | function page_header() { 522 | # check for autorefresh 523 | if [ "$MY_AUTOREFRESH" -gt 0 ] 524 | then 525 | MY_AUTOREFRESH_TEXT="" 526 | else 527 | MY_AUTOREFRESH_TEXT="" 528 | fi 529 | cat > "$MY_STATUS_HTML" << EOF 530 | 531 | 532 | 533 | 534 | $MY_STATUS_TITLE 535 | 536 | 537 | $MY_AUTOREFRESH_TEXT 538 | 539 | 540 | 541 | 542 | 543 |
544 |
545 |

$MY_STATUS_TITLE

546 |
547 | $MY_HOMEPAGE_TITLE 548 |
549 |
550 | EOF 551 | } 552 | 553 | function page_footer() { 554 | cat >> "$MY_STATUS_HTML" << EOF 555 |
556 |
557 |

$MY_STATUS_FOOTER

558 |

$MY_DATE_TIME

559 |
560 |
561 | 562 | 563 | 564 | EOF 565 | } 566 | 567 | function page_alert_success() { 568 | cat >> "$MY_STATUS_HTML" << EOF 569 | 573 | EOF 574 | } 575 | 576 | function page_alert_warning() { 577 | cat >> "$MY_STATUS_HTML" << EOF 578 | 582 | EOF 583 | } 584 | 585 | function page_alert_danger() { 586 | cat >> "$MY_STATUS_HTML" << EOF 587 | 591 | EOF 592 | } 593 | 594 | function page_alert_maintenance() { 595 | cat >> "$MY_STATUS_HTML" << EOF 596 |
597 |
598 | 599 | Maintenance 600 |
601 |
602 | EOF 603 | if [ -r "$MY_MAINTENANCE_TEXT_FILE" ]; then 604 | cat "$MY_MAINTENANCE_TEXT_FILE" >> "$MY_STATUS_HTML" 605 | else 606 | echo ":-(" >> "$MY_STATUS_HTML" 607 | echo_warning "Can not read file '$MY_MAINTENANCE_TEXT_FILE'" 608 | fi 609 | cat >> "$MY_STATUS_HTML" << EOF 610 |
611 |
612 | EOF 613 | } 614 | 615 | function item_ok() { 616 | echo '
  • ' 617 | if [[ -n "${MY_DISPLAY_TEXT}" ]]; then 618 | echo "${MY_DISPLAY_TEXT}" 619 | else 620 | if [[ "$MY_OK_COMMAND" = "ping" ]]; then 621 | echo "ping $MY_OK_HOSTNAME" 622 | elif [[ "$MY_OK_COMMAND" = "ping6" ]]; then 623 | echo "ping6 $MY_OK_HOSTNAME" 624 | elif [[ "$MY_OK_COMMAND" = "nc" ]]; then 625 | echo "$(port_to_name "$MY_OK_PORT") on $MY_OK_HOSTNAME" 626 | elif [[ "$MY_OK_COMMAND" = "curl" ]]; then 627 | echo "Site $MY_OK_HOSTNAME" 628 | elif [[ "$MY_OK_COMMAND" = "http-status" ]]; then 629 | echo "HTTP status $MY_OK_PORT of $MY_OK_HOSTNAME" 630 | elif [[ "$MY_OK_COMMAND" = "grep" ]]; then 631 | echo "Grep for \"$MY_OK_PORT\" on $MY_OK_HOSTNAME" 632 | elif [[ "$MY_OK_COMMAND" = "traceroute" ]]; then 633 | echo "Route path contains $MY_OK_HOSTNAME" 634 | elif [[ "$MY_OK_COMMAND" = "script" ]]; then 635 | echo "Script $MY_OK_HOSTNAME" 636 | fi 637 | fi 638 | cat < 640 |
  • 641 | EOF 642 | } 643 | 644 | function item_down() { 645 | echo '
  • ' 646 | if [[ -n "${MY_DISPLAY_TEXT}" ]]; then 647 | echo "${MY_DISPLAY_TEXT}" 648 | else 649 | if [[ "$MY_DOWN_COMMAND" = "ping" ]]; then 650 | echo "ping $MY_DOWN_HOSTNAME" 651 | elif [[ "$MY_DOWN_COMMAND" = "ping6" ]]; then 652 | echo "ping6 $MY_DOWN_HOSTNAME" 653 | elif [[ "$MY_DOWN_COMMAND" = "nc" ]]; then 654 | echo "$(port_to_name "$MY_DOWN_PORT") on $MY_DOWN_HOSTNAME" 655 | elif [[ "$MY_DOWN_COMMAND" = "curl" ]]; then 656 | echo "Site $MY_DOWN_HOSTNAME" 657 | elif [[ "$MY_DOWN_COMMAND" = "http-status" ]]; then 658 | echo "HTTP status $MY_DOWN_PORT of $MY_DOWN_HOSTNAME" 659 | elif [[ "$MY_DOWN_COMMAND" = "grep" ]]; then 660 | echo "Grep for \"$MY_DOWN_PORT\" on $MY_DOWN_HOSTNAME" 661 | elif [[ "$MY_DOWN_COMMAND" = "traceroute" ]]; then 662 | echo "Route path contains $MY_DOWN_HOSTNAME" 663 | elif [[ "$MY_DOWN_COMMAND" = "script" ]]; then 664 | echo "Script $MY_DOWN_HOSTNAME" 665 | fi 666 | fi 667 | printf ' ' 668 | if [[ "$MY_DOWN_TIME" -gt "1" ]]; then 669 | printf "%.0f min" "$((MY_DOWN_TIME/60))" 670 | else 671 | echo "" 672 | fi 673 | echo "
  • " 674 | } 675 | 676 | function item_degrade() { 677 | echo '
  • ' 678 | if [[ -n "${MY_DISPLAY_TEXT}" ]]; then 679 | echo "${MY_DISPLAY_TEXT}" 680 | else 681 | echo "Script $MY_DEGRADE_HOSTNAME" 682 | fi 683 | printf ' ' 684 | if [[ "$MY_DEGRADE_TIME" -gt "1" ]]; then 685 | printf "%.0f min" "$((MY_DEGRADE_TIME/60))" 686 | else 687 | echo "" 688 | fi 689 | echo "
  • " 690 | } 691 | 692 | 693 | function item_history() { 694 | echo '
  • ' 695 | echo '' 696 | if [[ -n "${MY_DISPLAY_TEXT}" ]]; then 697 | echo "${MY_DISPLAY_TEXT}" 698 | else 699 | if [[ "$MY_HISTORY_COMMAND" = "ping" ]]; then 700 | echo "ping $MY_HISTORY_HOSTNAME" 701 | elif [[ "$MY_HISTORY_COMMAND" = "ping6" ]]; then 702 | echo "ping6 $MY_HISTORY_HOSTNAME" 703 | elif [[ "$MY_HISTORY_COMMAND" = "nc" ]]; then 704 | echo "$(port_to_name "$MY_HISTORY_PORT") on $MY_HISTORY_HOSTNAME" 705 | elif [[ "$MY_HISTORY_COMMAND" = "curl" ]]; then 706 | echo "Site $MY_HISTORY_HOSTNAME" 707 | elif [[ "$MY_HISTORY_COMMAND" = "http-status" ]]; then 708 | echo "HTTP status $MY_HISTORY_PORT of $MY_HISTORY_HOSTNAME" 709 | elif [[ "$MY_HISTORY_COMMAND" = "grep" ]]; then 710 | echo "Grep for \"$MY_HISTORY_PORT\" on $MY_HISTORY_HOSTNAME" 711 | elif [[ "$MY_HISTORY_COMMAND" = "traceroute" ]]; then 712 | echo "Route path contains $MY_HISTORY_HOSTNAME" 713 | elif [[ "$MY_HISTORY_COMMAND" = "script" ]]; then 714 | echo "Script $MY_HISTORY_HOSTNAME" 715 | fi 716 | fi 717 | echo '' 718 | echo "$MY_HISTORY_DATE_TIME" 719 | echo '' 720 | echo '' 721 | printf ' ' 722 | if [[ "$MY_HISTORY_DOWN_TIME" -gt "1" ]]; then 723 | printf "%.0f min" "$((MY_HISTORY_DOWN_TIME/60))" 724 | else 725 | echo "" 726 | fi 727 | echo "
  • " 728 | } 729 | 730 | ################################################################################ 731 | # MAIN 732 | ################################################################################ 733 | 734 | check_bash 735 | 736 | # Commands we need 737 | MY_COMMANDS=( 738 | ping 739 | ping6 740 | nc 741 | curl 742 | grep 743 | sed 744 | ) 745 | # Add traceroute optional if MY_TRACEROUTE_HOST is set 746 | if [[ -n "$MY_TRACEROUTE_HOST" ]]; then 747 | MY_COMMANDS+=("traceroute") 748 | fi 749 | 750 | if [[ -n "$ONLY_OUTPUT_DEBUG_VARIABLES" ]]; then 751 | debug_variables 752 | exit 753 | fi 754 | 755 | for MY_COMMAND in "${MY_COMMANDS[@]}"; do 756 | check_command "$MY_COMMAND" 757 | done 758 | 759 | check_lock 760 | set_lock 761 | check_config "$MY_HOSTNAME_FILE" 762 | check_file "$MY_HOSTNAME_STATUS_DOWN" 763 | check_file "$MY_HOSTNAME_STATUS_LASTRUN" 764 | check_file "$MY_HOSTNAME_STATUS_DEGRADE" 765 | check_file "$MY_HOSTNAME_STATUS_LASTRUN_DEGRADE" 766 | check_file "$MY_HOSTNAME_STATUS_HISTORY" 767 | check_file "$MY_HOSTNAME_STATUS_HISTORY_TEMP_SORT" 768 | check_file "$MY_STATUS_HTML" 769 | # Optional checks 770 | if [ -n "$MY_STATUS_ICON" ]; then 771 | check_file "$MY_STATUS_ICON" # status.svg 772 | fi 773 | if [ -n "$MY_STATUS_JSON" ]; then 774 | check_file "$MY_STATUS_JSON" # status.json 775 | fi 776 | 777 | if cp "$MY_HOSTNAME_STATUS_DOWN" "$MY_HOSTNAME_STATUS_LASTRUN" && cp "$MY_HOSTNAME_STATUS_DEGRADE" "$MY_HOSTNAME_STATUS_LASTRUN_DEGRADE"; then 778 | get_lastrun_time 779 | else 780 | exit_with_failure "Can not copy file '$MY_HOSTNAME_STATUS_DOWN' to '$MY_HOSTNAME_STATUS_LASTRUN' or '$MY_HOSTNAME_STATUS_DEGRADE' to '$MY_HOSTNAME_STATUS_LASTRUN_DEGRADE'" 781 | fi 782 | 783 | { 784 | echo "# $MY_DATE_TIME" 785 | echo_do_not_edit 786 | } > "$MY_HOSTNAME_STATUS_OK" 787 | { 788 | echo "# $MY_DATE_TIME" 789 | echo_do_not_edit 790 | echo "timestamp;$MY_TIMESTAMP" 791 | } > "$MY_HOSTNAME_STATUS_DEGRADE" 792 | { 793 | echo "# $MY_DATE_TIME" 794 | echo_do_not_edit 795 | echo "timestamp;$MY_TIMESTAMP" 796 | } > "$MY_HOSTNAME_STATUS_DOWN" 797 | 798 | 799 | # 800 | # Check and save status 801 | # 802 | 803 | MY_HOSTNAME_COUNT=0 804 | while IFS=';' read -r MY_COMMAND MY_HOSTNAME_STRING MY_PORT || [[ -n "$MY_COMMAND" ]]; do 805 | MY_HOSTNAME="${MY_HOSTNAME_STRING%%|*}" # remove alternative display textS 806 | if [[ "$MY_COMMAND" = "ping" ]]; then 807 | (( MY_HOSTNAME_COUNT++ )) 808 | # Detect ping Version 809 | ping &> /dev/null 810 | # macOS: 64 = ping -n -t TIMEOUT 811 | # GNU: 2 = ping -n -w TIMEOUT (-t TTL) 812 | # OpenBSD: 1 = ping -n -w TIMEOUT (-t TTL) 813 | if [ $? -gt 2 ] || [[ "$OSTYPE" == "freebsd"* ]]; then 814 | # BSD ping 815 | MY_PING_COMMAND='ping -n -t' 816 | else 817 | # GNU or OpenBSD ping 818 | MY_PING_COMMAND='ping -n -w' 819 | fi 820 | if $MY_PING_COMMAND "$MY_PING_TIMEOUT" -c "$MY_PING_COUNT" "$MY_HOSTNAME" &> /dev/null; then 821 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 822 | # Check status change 823 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 824 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" "$MY_DATE_TIME" 825 | fi 826 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 827 | else 828 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 829 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" 830 | fi 831 | elif [[ "$MY_COMMAND" = "ping6" ]]; then 832 | (( MY_HOSTNAME_COUNT++ )) 833 | # Detect ping6 Version 834 | ping6 &> /dev/null 835 | # macOS: 64 = ping6 -n -t TIMEOUT 836 | # GNU: 2 = ping6 -n -w TIMEOUT (-t TTL) 837 | # OpenBSD: 1 = ping6 -n -w TIMEOUT (-t TTL) 838 | if [ $? -gt 2 ] || [[ "$OSTYPE" == "freebsd"* ]]; then 839 | # BSD ping6 840 | MY_PING6_COMMAND='ping6 -n -t' 841 | else 842 | # GNU or OpenBSD ping6 843 | MY_PING6_COMMAND='ping6 -n -w' 844 | fi 845 | if $MY_PING6_COMMAND "$MY_PING_TIMEOUT" -c "$MY_PING_COUNT" "$MY_HOSTNAME" &> /dev/null; then 846 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 847 | # Check status change 848 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 849 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" "$MY_DATE_TIME" 850 | fi 851 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 852 | else 853 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 854 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" 855 | fi 856 | elif [[ "$MY_COMMAND" = "nc" ]]; then 857 | (( MY_HOSTNAME_COUNT++ )) 858 | if nc -z -w "$MY_TIMEOUT" "$MY_HOSTNAME" "$MY_PORT" &> /dev/null; then 859 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 860 | # Check status change 861 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 862 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" 863 | fi 864 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 865 | else 866 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 867 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" 868 | fi 869 | elif [[ "$MY_COMMAND" = "curl" ]]; then 870 | (( MY_HOSTNAME_COUNT++ )) 871 | if curl -If --max-time "$MY_TIMEOUT" "$MY_HOSTNAME" &> /dev/null; then 872 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 873 | # Check status change 874 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 875 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" "$MY_DATE_TIME" 876 | fi 877 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 878 | else 879 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" 880 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "" "$MY_DOWN_TIME" 881 | fi 882 | elif [[ "$MY_COMMAND" = "http-status" ]]; then 883 | (( MY_HOSTNAME_COUNT++)) 884 | if [[ $(curl -s -o /dev/null -I --max-time "$MY_TIMEOUT" -w "%{http_code}" "$MY_HOSTNAME" 2>/dev/null) == "$MY_PORT" ]]; then 885 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 886 | # Check status change 887 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 888 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" 889 | fi 890 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 891 | else 892 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 893 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" 894 | fi 895 | elif [[ "$MY_COMMAND" = "grep" ]]; then 896 | (( MY_HOSTNAME_COUNT++ )) 897 | if curl --no-buffer -fs --max-time "$MY_TIMEOUT" "$MY_HOSTNAME" | grep -q "$MY_PORT" &> /dev/null; then 898 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 899 | # Check status change 900 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 901 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" 902 | fi 903 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 904 | else 905 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 906 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" 907 | fi 908 | elif [[ "$MY_COMMAND" = "traceroute" ]]; then 909 | (( MY_HOSTNAME_COUNT++ )) 910 | MY_PORT=${MY_PORT:=64} 911 | if traceroute -w "$MY_TIMEOUT" -q "$MY_TRACEROUTE_NQUERIES" -m "$MY_PORT" "$MY_TRACEROUTE_HOST" | grep -q "$MY_HOSTNAME" &> /dev/null; then 912 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 913 | # Check status change 914 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 915 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" 916 | fi 917 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 918 | else 919 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 920 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" 921 | fi 922 | elif [[ "$MY_COMMAND" = "script" ]]; then 923 | (( MY_HOSTNAME_COUNT++ )) 924 | if [[ -x "$MY_STATUS_CONFIG_DIR/$MY_HOSTNAME" ]]; then 925 | cmd="$MY_STATUS_CONFIG_DIR/$MY_HOSTNAME" 926 | else 927 | cmd="$MY_HOSTNAME" 928 | fi 929 | (timeout --preserve-status "$MY_SCRIPT_TIMEOUT" "$cmd" &> /dev/null) 930 | case "$?" in 931 | "0") 932 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 933 | # Check status change 934 | if [[ "$MY_DOWN_TIME" -gt "0" ]]; then 935 | save_history "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" "$MY_DATE_TIME" 936 | fi 937 | save_availability "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 938 | ;; 939 | "80") 940 | check_degradetime "$MY_COMMAND" "$MY_HOSTNAME_STRING" 941 | save_degradetime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_DEGRADE_TIME" 942 | ;; 943 | *) 944 | check_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" 945 | save_downtime "$MY_COMMAND" "$MY_HOSTNAME_STRING" "$MY_PORT" "$MY_DOWN_TIME" 946 | ;; 947 | esac 948 | fi 949 | done <"$MY_HOSTNAME_FILE" 950 | 951 | 952 | # 953 | # Create status page 954 | # 955 | 956 | page_header 957 | 958 | MY_ITEMS_JSON=() 959 | 960 | # Get outage 961 | MY_OUTAGE_COUNT=0 962 | MY_OUTAGE_ITEMS=() 963 | while IFS=';' read -r MY_DOWN_COMMAND MY_DOWN_HOSTNAME_STRING MY_DOWN_PORT MY_DOWN_TIME || [[ -n "$MY_DOWN_COMMAND" ]]; do 964 | if [[ "$MY_DOWN_COMMAND" = "ping" ]] || 965 | [[ "$MY_DOWN_COMMAND" = "ping6" ]] || 966 | [[ "$MY_DOWN_COMMAND" = "nc" ]] || 967 | [[ "$MY_DOWN_COMMAND" = "curl" ]] || 968 | [[ "$MY_DOWN_COMMAND" = "http-status" ]] || 969 | [[ "$MY_DOWN_COMMAND" = "grep" ]] || 970 | [[ "$MY_DOWN_COMMAND" = "script" ]] || 971 | [[ "$MY_DOWN_COMMAND" = "traceroute" ]]; then 972 | MY_DOWN_HOSTNAME="${MY_DOWN_HOSTNAME_STRING%%|*}" 973 | MY_DISPLAY_TEXT="${MY_DOWN_HOSTNAME_STRING/${MY_DOWN_HOSTNAME}/}" 974 | MY_DISPLAY_TEXT="${MY_DISPLAY_TEXT:1}" 975 | (( MY_OUTAGE_COUNT++ )) 976 | MY_OUTAGE_ITEMS+=("$(item_down)") 977 | MY_ITEMS_JSON+=("${MY_DISPLAY_TEXT:-${MY_DOWN_HOSTNAME}};$MY_DOWN_COMMAND;Fail;$MY_DOWN_TIME") 978 | fi 979 | done <"$MY_HOSTNAME_STATUS_DOWN" 980 | 981 | # Get degrades 982 | MY_DEGRADE_COUNT=0 983 | MY_DEGRADE_ITEMS=() 984 | while IFS=';' read -r MY_DEGRADE_COMMAND MY_DEGRADE_HOSTNAME_STRING MY_DEGRADE_TIME || [[ -n "$MY_DEGRADE_COMMAND" ]]; do 985 | if [[ "$MY_DEGRADE_COMMAND" = "script" ]]; then 986 | MY_DEGRADE_HOSTNAME="${MY_DEGRADE_HOSTNAME_STRING%%|*}" 987 | MY_DISPLAY_TEXT="${MY_DEGRADE_HOSTNAME_STRING/${MY_DEGRADE_HOSTNAME}/}" 988 | MY_DISPLAY_TEXT="${MY_DISPLAY_TEXT:1}" 989 | (( MY_DEGRADE_COUNT++ )) 990 | MY_DEGRADE_ITEMS+=("$(item_degrade)") 991 | MY_ITEMS_JSON+=("${MY_DISPLAY_TEXT:-${MY_DEGRADE_HOSTNAME}};$MY_DEGRADE_COMMAND;Degraded;$MY_DEGRADE_TIME") 992 | fi 993 | done <"$MY_HOSTNAME_STATUS_DEGRADE" 994 | 995 | # Get available systems 996 | MY_AVAILABLE_COUNT=0 997 | MY_AVAILABLE_ITEMS=() 998 | while IFS=';' read -r MY_OK_COMMAND MY_OK_HOSTNAME_STRING MY_OK_PORT || [[ -n "$MY_OK_COMMAND" ]]; do 999 | if [[ "$MY_OK_COMMAND" = "ping" ]] || 1000 | [[ "$MY_OK_COMMAND" = "ping6" ]] || 1001 | [[ "$MY_OK_COMMAND" = "nc" ]] || 1002 | [[ "$MY_OK_COMMAND" = "curl" ]] || 1003 | [[ "$MY_OK_COMMAND" = "http-status" ]] || 1004 | [[ "$MY_OK_COMMAND" = "grep" ]] || 1005 | [[ "$MY_OK_COMMAND" = "script" ]] || 1006 | [[ "$MY_OK_COMMAND" = "traceroute" ]]; then 1007 | MY_OK_HOSTNAME="${MY_OK_HOSTNAME_STRING%%|*}" 1008 | MY_DISPLAY_TEXT="${MY_OK_HOSTNAME_STRING/${MY_OK_HOSTNAME}/}" 1009 | MY_DISPLAY_TEXT="${MY_DISPLAY_TEXT:1}" 1010 | (( MY_AVAILABLE_COUNT++ )) 1011 | MY_AVAILABLE_ITEMS+=("$(item_ok)") 1012 | MY_ITEMS_JSON+=("${MY_DISPLAY_TEXT:-${MY_OK_HOSTNAME}};$MY_OK_COMMAND;OK;0") 1013 | fi 1014 | done <"$MY_HOSTNAME_STATUS_OK" 1015 | 1016 | MY_OUTAGED_AND_DEGRADE_COUNT=$((MY_OUTAGE_COUNT + MY_DEGRADE_COUNT)) 1017 | # Maintenance text 1018 | if [ -s "$MY_MAINTENANCE_TEXT_FILE" ]; then 1019 | page_alert_maintenance 1020 | # or status alert 1021 | elif [[ "$MY_OUTAGE_COUNT" -gt "$MY_AVAILABLE_COUNT" ]]; then 1022 | page_alert_danger 1023 | elif [[ "$MY_OUTAGED_AND_DEGRADE_COUNT" -gt "0" ]]; then 1024 | page_alert_warning 1025 | else 1026 | page_alert_success 1027 | fi 1028 | 1029 | # Outage to HTML 1030 | if [[ "$MY_OUTAGE_COUNT" -gt "0" ]]; then 1031 | cat >> "$MY_STATUS_HTML" << EOF 1032 |
    1033 |
      1034 |
    • Outage
    • 1035 | EOF 1036 | for MY_OUTAGE_ITEM in "${MY_OUTAGE_ITEMS[@]}"; do 1037 | echo "$MY_OUTAGE_ITEM" >> "$MY_STATUS_HTML" 1038 | done 1039 | echo "
    " >> "$MY_STATUS_HTML" 1040 | fi 1041 | 1042 | # Degraded to HTML 1043 | if [[ "$MY_DEGRADE_COUNT" -gt "0" ]]; then 1044 | cat >> "$MY_STATUS_HTML" << EOF 1045 |
    1046 |
      1047 |
    • Degraded
    • 1048 | EOF 1049 | for MY_DEGRADE_ITEM in "${MY_DEGRADE_ITEMS[@]}"; do 1050 | echo "$MY_DEGRADE_ITEM" >> "$MY_STATUS_HTML" 1051 | done 1052 | echo "
    " >> "$MY_STATUS_HTML" 1053 | fi 1054 | 1055 | # Operational to HTML 1056 | if [[ "$MY_AVAILABLE_COUNT" -gt "0" ]]; then 1057 | cat >> "$MY_STATUS_HTML" << EOF 1058 |
    1059 |
      1060 |
    • Operational
    • 1061 | EOF 1062 | for MY_AVAILABLE_ITEM in "${MY_AVAILABLE_ITEMS[@]}"; do 1063 | echo "$MY_AVAILABLE_ITEM" >> "$MY_STATUS_HTML" 1064 | done 1065 | echo "
    " >> "$MY_STATUS_HTML" 1066 | fi 1067 | 1068 | # Outage and operational to SVG 1069 | if [ -n "$MY_STATUS_ICON" ]; then 1070 | MY_STATUS_ICON_COLOR="$MY_STATUS_ICON_COLOR_SUCCESS" 1071 | if [[ "$MY_OUTAGE_COUNT" -gt "$MY_AVAILABLE_COUNT" ]]; then 1072 | MY_STATUS_ICON_COLOR="$MY_STATUS_ICON_COLOR_DANGER" 1073 | elif [[ "$MY_OUTAGE_COUNT" -gt "0" ]]; then 1074 | MY_STATUS_ICON_COLOR="$MY_STATUS_ICON_COLOR_WARNING" 1075 | fi 1076 | printf '' "$MY_STATUS_ICON_COLOR" > "$MY_STATUS_ICON" 1077 | fi 1078 | 1079 | # Outage and operational to JSON 1080 | if [ -n "$MY_STATUS_JSON" ]; then 1081 | printf "[\n" > "$MY_STATUS_JSON" 1082 | for ((position = 0; position < ${#MY_ITEMS_JSON[@]}; ++position)); do 1083 | IFS=";" read -r -a ITEMS <<< "${MY_ITEMS_JSON[$position]}" 1084 | # shellcheck disable=SC2001 1085 | MY_OUTAGE_ITEM=$(sed -e 's/<[^>]*>//g' <<< "${ITEMS[0]}") 1086 | MY_OUTAGE_ITEM_CMD="${ITEMS[1]}" 1087 | MY_OUTAGE_ITEM_STATUS="${ITEMS[2]}" 1088 | MY_OUTAGE_ITEM_TIME="${ITEMS[3]}" 1089 | printf ' {\n "site": "%s",\n "command": "%s",\n "status": "%s",\n "time_sec": "%s",\n "updated": "%s"\n }' \ 1090 | "$MY_OUTAGE_ITEM" "$MY_OUTAGE_ITEM_CMD" "$MY_OUTAGE_ITEM_STATUS" "$MY_OUTAGE_ITEM_TIME" "$MY_DATE_TIME" >> "$MY_STATUS_JSON" 1091 | if [ "$position" -lt "$(( ${#MY_ITEMS_JSON[@]} - 1 ))" ]; then 1092 | printf ",\n" >> "$MY_STATUS_JSON" 1093 | else 1094 | printf "\n" >> "$MY_STATUS_JSON" 1095 | fi 1096 | done 1097 | printf "]" >> "$MY_STATUS_JSON" 1098 | fi 1099 | 1100 | # Get history (last 10 incidents) 1101 | MY_HISTORY_COUNT=0 1102 | MY_HISTORY_ITEMS=() 1103 | MY_SHOW_INCIDENTS="false" 1104 | while IFS=';' read -r MY_HISTORY_COMMAND MY_HISTORY_HOSTNAME_STRING MY_HISTORY_PORT MY_HISTORY_DOWN_TIME MY_HISTORY_DATE_TIME || [[ -n "$MY_HISTORY_COMMAND" ]]; do 1105 | if [[ "$MY_HISTORY_DOWN_TIME" -ge "$MY_MIN_DOWN_TIME" ]]; then 1106 | MY_SHOW_INCIDENTS="true" 1107 | if [[ "$MY_HISTORY_COMMAND" = "ping" ]] || 1108 | [[ "$MY_HISTORY_COMMAND" = "ping6" ]] || 1109 | [[ "$MY_HISTORY_COMMAND" = "nc" ]] || 1110 | [[ "$MY_HISTORY_COMMAND" = "curl" ]] || 1111 | [[ "$MY_HISTORY_COMMAND" = "http-status" ]] || 1112 | [[ "$MY_HISTORY_COMMAND" = "grep" ]] || 1113 | [[ "$MY_HISTORY_COMMAND" = "script" ]] || 1114 | [[ "$MY_HISTORY_COMMAND" = "traceroute" ]]; then 1115 | MY_HISTORY_HOSTNAME="${MY_HISTORY_HOSTNAME_STRING%%|*}" 1116 | MY_DISPLAY_TEXT="${MY_HISTORY_HOSTNAME_STRING/${MY_HISTORY_HOSTNAME}/}" 1117 | MY_DISPLAY_TEXT="${MY_DISPLAY_TEXT:1}" 1118 | (( MY_HISTORY_COUNT++ )) 1119 | MY_HISTORY_ITEMS+=("$(item_history)") 1120 | fi 1121 | if [[ "$MY_HISTORY_COUNT" -gt "9" ]]; then 1122 | break 1123 | fi 1124 | fi 1125 | done <"$MY_HOSTNAME_STATUS_HISTORY" 1126 | 1127 | # History to HTML 1128 | if [[ "$MY_SHOW_INCIDENTS" == "true" ]]; then 1129 | cat >> "$MY_STATUS_HTML" << EOF 1130 |
    1131 |

    Past Incidents

    1132 |
    1133 |
      1134 | EOF 1135 | for MY_HISTORY_ITEM in "${MY_HISTORY_ITEMS[@]}"; do 1136 | echo "$MY_HISTORY_ITEM" >> "$MY_STATUS_HTML" 1137 | done 1138 | echo "
    " >> "$MY_STATUS_HTML" 1139 | fi 1140 | 1141 | page_footer 1142 | 1143 | del_lock 1144 | echo 1145 | -------------------------------------------------------------------------------- /status_hostname_list.txt: -------------------------------------------------------------------------------- 1 | # 2 | # status.sh Configuration File 3 | # 4 | # What should be monitored? Each line one entry. 5 | # 6 | # Structure: 7 | # ;; 8 | # 9 | # COMMAND: Command to run. Can be ping, curl or nc. 10 | # ping = send ICMP ECHO_REQUEST packets to network hosts 11 | # curl = transfer a URL 12 | # http-status = check the HTTP status of a URL 13 | # nc = check TCP and UDP connections 14 | # grep = extension to the curl check 15 | # curl downloads the webpage and pipes it to grep, 16 | # that checks if the keyword is in the page. 17 | # traceroute = check if host or ip exists in route path to MY_TRACEROUTE_HOST 18 | # script = execute a script which returns 0 on success 19 | # 20 | # HOSTNAME: Hostname for the 'ping', 'nc' or 'traceroute' command 21 | # IP: IP adress for the 'ping', 'nc' or 'traceroute' command 22 | # URL: URL called by the command 'curl', 'http-status' and 'grep'. I.e. https://www.heise.de/ping or ftp://ftp.debian.org/debian/README 23 | # PATH: PATH of the script called by the command 'script', eg. check.sh 24 | # The pipe `|` can be used as a separator to display a custom text instead of the HOSTNAME/IP/URL (see example below). 25 | # 26 | # PORT: Optional port specification. Only for 'nc' command. 27 | # GREP TEXT: Text to look for when using the 'grep' command. 28 | # HTTP STATUS: HTTP status code required to pass when using the 'http-status' command. 29 | # 30 | 31 | # 32 | # ping; 33 | # 34 | ping;www.heise.de 35 | ping;www.otto.de|custom text instead of hostname 36 | ping6;www.google.com|www.google.com (IPv6) 37 | # 38 | # nc;; 39 | # 40 | nc;www.heise.de;80 41 | nc;www.bsi.de|My secret Hostname;80 42 | 43 | # 44 | # curl;; 45 | # 46 | curl;https://www.heise.de/ping 47 | curl;ftp://ftp.debian.org/debian/README 48 | curl;https://example.com/|My secret URL 49 | 50 | # 51 | # http-status;; 52 | # 53 | http-status;https://www.nkn-it.de/ci.txt;200 54 | 55 | # 56 | # grep;; 57 | # 58 | grep;https://www.nkn-it.de/imprint.html;Nils 59 | 60 | 61 | # 62 | # traceroute;; 63 | # 64 | # Note: 65 | # This HOSTNAME or IP is not the host to which the route path is traced. This is done via the parameter MY_TRACEROUTE_HOST 66 | # This HOSTNAME or IP must be present in the route path. 67 | # MAX NUMBER OF HOPS sets the max time-to-live (max number of hops) used in outgoing probe packets. 68 | # If the hostname should always be the third hop, enter 3. 69 | # 70 | traceroute;your.isp.router;3 71 | traceroute;your.secret.router|My secret Hostname;2 72 | 73 | # 74 | # script; 75 | # 76 | # Note: Outage if returncode is not 0, Degraded if returncode is 80 77 | # 78 | script;/path/to/your/script.sh|My secret Name 79 | script;scripts/check-websites.sh|Multiple Websites 80 | -------------------------------------------------------------------------------- /status_maintenance_text.txt: -------------------------------------------------------------------------------- 1 | The content of status_maintenance_text.txt is displayed as a maintenance message at the top. 2 | If you do not have any maintenance, delete this file or empty it. -------------------------------------------------------------------------------- /status_website_list.txt: -------------------------------------------------------------------------------- 1 | example.com 2 | example.org 3 | github.com 4 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # status.sh Test Script 4 | 5 | # Get https://github.com/lehmannro/assert.sh 6 | if [ ! -e assert.sh ]; then 7 | echo "downloading unit test script" 8 | curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh 9 | fi 10 | 11 | # Create configuration 12 | mkdir "$HOME/status" &> /dev/null 13 | cat > "$HOME/status/status_hostname_list.txt" << EOF 14 | # UP 15 | ping;127.0.0.1 16 | nc;www.heise.de;80 17 | curl;https://www.heise.de/ping 18 | grep;https://www.nkn-it.de/ci.txt;3.14159 19 | http-status;https://www.nkn-it.de/ci.txt;200 20 | http-status;https://www.nkn-it.de/gibtesnicht;404 21 | script;/bin/true|Always up (/bin/true) 22 | # DEGRADED 23 | script;exit 80|Always degraded (exit 80) 24 | # DOWN 25 | ping;gibt.es.nicht.nkn-it.de 26 | nc;gibt.es.nicht.nkn-it.de;21 27 | curl;http://gibt.es.nicht.nkn-it.de 28 | curl;https://www.nkn-it.de/gibtesnicht 29 | grep;https://www.nkn-it.de/ci.txt;GibtEsNicht 30 | http-status;https://www.nkn-it.de/ci.txt;404 31 | http-status;https://www.nkn-it.de/gibtesnicht;200 32 | script;/bin/flase|Always down (/bin/false) 33 | EOF 34 | 35 | # shellcheck disable=SC1091 36 | source assert.sh 37 | 38 | # Run tests 39 | 40 | # $ bash status.sh silent 41 | assert "bash status.sh silent" 42 | 43 | # assert test expected output 44 | # UP 45 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'ping;127.0.0.1;'" "ping;127.0.0.1;" 46 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'nc;www.heise.de;80'" "nc;www.heise.de;80" 47 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'http-status;https://www.nkn-it.de/ci.txt;200'" "http-status;https://www.nkn-it.de/ci.txt;200" 48 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'http-status;https://www.nkn-it.de/gibtesnicht;404'" "http-status;https://www.nkn-it.de/gibtesnicht;404" 49 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'curl;https://www.heise.de/ping;'" "curl;https://www.heise.de/ping;" 50 | assert "cat $HOME/status/status_hostname_ok.txt | grep 'grep;https://www.nkn-it.de/ci.txt;3.14159'" "grep;https://www.nkn-it.de/ci.txt;3.14159" 51 | # DEGRADED 52 | assert "cat $HOME/status/status_hostname_last_degrade.txt | grep 'script;exit 80|Always degraded (exit 80);2'" 53 | # DOWN 54 | assert "cat $HOME/status/status_hostname_down.txt | grep 'nkn-it.de' | wc -l | perl -pe 's/\\s//g'" "7" # (7 test/sites with nkn-it.de) 55 | 56 | # $ bash status.sh loud 57 | assert_raises "bash status.sh loud" 58 | 59 | assert_end status_sh 60 | --------------------------------------------------------------------------------