1
0
Fork 0
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
Find a file
2024-08-20 14:55:16 +02:00
.gitea/workflows [c] adapt workflow to only publish script on new *-release tags 2024-08-20 14:55:16 +02:00
.gitignore Initial Commit 2024-08-19 15:21:08 +02:00
check_pyhttps.py [a] workflow automation 2024-08-20 14:28:31 +02:00
LICENSE.md Initial Commit 2024-08-19 15:21:08 +02:00
README.md [c] update readme defaults 2024-08-19 16:07:41 +02:00
requirements.txt Initial Commit 2024-08-19 15:21:08 +02:00

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

  1. Ensure Python 3.8 or higher is installed on your system.

  2. 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
    
  3. Download the check_pyhttps.py script to your Nagios plugins directory or any other location accessible by Nagios.

  4. 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

  1. Check HTTPS on default port (443):

    ./check_pyhttps.py example.com
    
  2. Check HTTP on port 8080:

    ./check_pyhttps.py example.com 8080 --http
    
  3. Custom status codes and timeout:

    ./check_pyhttps.py example.com -o 200,201 -w 301,302,307 -c 404,500 -t 5
    
  4. Disable SSL warnings:

    ./check_pyhttps.py example.com --disable-ssl-warnings
    

License

Distributed under the MIT License. See LICENSE.md file for more information.