Skip to content

Automates the integration of Pingdom checks into Zabbix for centralized monitoring. Fetches Pingdom check statuses, creates Zabbix hosts, items, and triggers, and updates statuses via APIs.

License

Notifications You must be signed in to change notification settings

MattTHG/Pingdom-To-Zabbix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pingdom-Zabbix Integration Script

This script integrates Pingdom monitoring with Zabbix for automated host creation, item monitoring, trigger creation, and status updates. It fetches Pingdom checks, creates corresponding hosts in Zabbix if necessary, and synchronizes their status periodically.

Table of Contents

  1. Script Details
  2. Prerequisites
  3. Setup
  4. Configuration
  5. Usage
  6. Logging
  7. Error Handling
  8. Cronjob Setup
  9. License

Script Details

Functionality

The script automates the integration between Pingdom and Zabbix for monitoring purposes. It fetches Pingdom checks using the Pingdom API, creates corresponding hosts in Zabbix if they don't exist, sets up monitoring items and triggers, and updates Zabbix with the latest status from Pingdom checks.

Key Features

  • Pingdom Integration: Fetches Pingdom checks using the Pingdom API.
  • Zabbix Host Management: Creates Zabbix hosts dynamically based on Pingdom checks.
  • Item and Trigger Creation: Sets up Zabbix items and triggers to monitor Pingdom check statuses.
  • Status Synchronization: Updates Zabbix with the latest status information retrieved from Pingdom.

Prerequisites

Before running the script, ensure you have the following:

  • Python 3.7+: Installed on your system. Download Python
  • Pingdom API Credentials:
    • API key (PINGDOM_API_KEY).
  • Zabbix API Credentials:
    • API URL (ZABBIX_API_URL).
    • Username (ZABBIX_API_USER).
    • Password (ZABBIX_API_PASSWORD).
  • Zabbix Configuration:
    • Host group ID (ZABBIX_HOST_GROUP_ID): ID of the host group in Zabbix where hosts will be created.
    • Template ID (ZABBIX_TEMPLATE_ID): ID of the template in Zabbix to link with the created hosts.

Environment variables should be set up in a .env file in the root directory of the script with the following format:

PINGDOM_API_KEY=your_pingdom_api_key
ZABBIX_API_URL=your_zabbix_api_url
ZABBIX_API_USER=your_zabbix_api_user
ZABBIX_API_PASSWORD=your_zabbix_api_password
ZABBIX_HOST_GROUP_ID=your_zabbix_host_group_id
ZABBIX_TEMPLATE_ID=your_zabbix_template_id
  • PINGDOM_API_KEY: API key for accessing Pingdom API (e.g., abcdef123456).
  • ZABBIX_API_URL: URL of the Zabbix API (e.g., https://zabbix.example.com/api_jsonrpc.php).
  • ZABBIX_API_USER: Username for Zabbix API authentication (e.g., admin).
  • ZABBIX_API_PASSWORD: Password for Zabbix API authentication (e.g., mypassword).
  • ZABBIX_HOST_GROUP_ID: ID of the Zabbix host group to place new hosts (e.g., 1234).
  • ZABBIX_TEMPLATE_ID: ID of the Zabbix template to apply to new hosts (e.g., 5678).

Setup

  1. Clone the repository:
git clone https://github.com/MattTHG/pingdom-to-zabbix.git
cd pingdom-to-zabbix
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the root directory and add your environment variables as mentioned in the Prerequisites section.

Configuration

Ensure the .env file contains valid credentials and IDs required for accessing Pingdom and Zabbix APIs.

Usage

To run the script, use Python 3.7+:

python script_name.py

The script will continuously fetch Pingdom checks, create Zabbix hosts and items if necessary, and update Zabbix with the latest statuses.

Logging

  • INFO: Detailed execution steps, successful operations.
  • WARNING: Retries during HTTP requests.
  • ERROR: Critical errors and exceptions.

Logs are printed to the console. Redirect or append logs to a file for long-term storage.

To append logs to a file, you can run the script with output redirection:

python3 pingdom-zabbix-integration.py >> python3 /path/to/logfile.log 2>&1

Error Handling

The script handles various exceptions (e.g., HTTP errors, API request failures) and logs detailed error messages for troubleshooting.

Cronjob Setup

To automate script execution, set up a cronjob:

  1. Edit your crontab:
crontab -e
  1. Add a cronjob to run the script at your desired interval (e.g., every minute):
* * * * * /usr/bin/python3 /path/to/pingdom-zabbix-integration.py >> /path/to/logfile.log 2>&1

This example runs the script every hour (* * * * *) and appends both stdout and stderr to script_logs.log.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Notes:

  • Replace <placeholders> with actual values relevant to your environment.
  • Ensure all dependencies are installed from requirements.txt before running the script.
  • Adjust the sleep interval (await asyncio.sleep(60)) in the main_async() function as per your monitoring requirements.

About

Automates the integration of Pingdom checks into Zabbix for centralized monitoring. Fetches Pingdom check statuses, creates Zabbix hosts, items, and triggers, and updates statuses via APIs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages