mirror of
https://gitlab.uzh.ch/stelian.tsekov/check_pyhttps.git
synced 2025-09-04 03:00:12 +00:00
Simple Nagios Plugin to check an HTTP/S endpoint using Python
.gitea/workflows | ||
.gitignore | ||
check_pyhttps.py | ||
LICENSE.md | ||
README.md | ||
requirements.txt |
check_pyhttps
A Nagios Plugin to check for an endpoint's HTTP status codes. This can be any website, either http or https.
Features
- Checks HTTP and HTTPS endpoints
- Supports custom port specification
- Configurable OK, WARNING, and CRITICAL status codes
- IPv4 and IPv6 support
- Adjustable connection timeout
- Option to disable SSL certificate warnings
Requirements
- Python 3.8+
Requests==2.32.3
urllib3==2.2.2
Installation
-
Ensure Python 3.8 or higher is installed on your system.
-
Install the required dependencies inside a virtual environment, or system-wide:
# install inside a virtual environment python3 -m venv venv source venv/bin/activate pip install -r requirements.txt # or system-wide with your package manager, example: sudo dnf install python3-requests sudo dnf install python3-urllib3
-
Download the
check_pyhttps.py
script to your Nagios plugins directory or any other location accessible by Nagios. -
Make the script executable:
chmod +x check_pyhttps.py
Usage
./check_pyhttps.py [-h] [--http] [-o OK] [-w WARN] [-c CRITICAL] [-t TIMEOUT] [--disable-ssl-warnings] host [port]
Options
host
: IP address or DNS name to check (required)port
: Port number (optional)--http
: Use HTTP instead of HTTPS-o OK
,--ok OK
: Comma-separated list of OK status codes (default: 200,201,204)-w WARN
,--warn WARN
: Comma-separated list of WARNING status codes (default: 301,302)-c CRITICAL
,--critical CRITICAL
: Comma-separated list of CRITICAL status codes (default: 400,401,403,404,409,410,500,501,502,503,504)-t TIMEOUT
,--timeout TIMEOUT
: Timeout in seconds (default: 10)--disable-ssl-warnings
: Disable SSL certificate warnings
Examples
-
Check HTTPS on default port (443):
./check_pyhttps.py example.com
-
Check HTTP on port 8080:
./check_pyhttps.py example.com 8080 --http
-
Custom status codes and timeout:
./check_pyhttps.py example.com -o 200,201 -w 301,302,307 -c 404,500 -t 5
-
Disable SSL warnings:
./check_pyhttps.py example.com --disable-ssl-warnings
License
Distributed under the MIT License. See LICENSE.md
file for more information.