Skip to content

Python script which controls Zabbix http tests from yaml file

License

Notifications You must be signed in to change notification settings

OSidorenkov/zabbix-httpcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zabbix-httpcheck

zabbix-httpcheck is Python script which controls Zabbix http tests from yaml file. Create/update/delete http tests and triggers for them.

Requirements:

  • python >= 3.4
  • python libs: pyzabbix, pyyaml

Installation:

  1. Clone repo: https://github.com/OSidorenkov/zabbix-httpcheck.git
  2. Create and configure config.py near httpcheck.py. You can take as an example config.py.example from repo.
  3. Install python libs: pip3 install pyzabbix pyyaml

Configuration:

  1. Create fake host or hosts in Zabbix where you want to see the Web checks, for example:
  • dev
  • qa
  • stage
  • prod
  1. Edit config.py, paste your hosts for web checks into the list zbx_hosts.

Usage:

In order to add new web services addresses to monitoring, you need:

  • Add to the file httpcheck.yaml information about the web check, for example:
- name: GitHub
  url: https://github.com/OSidorenkov
  env: prod
  priority: 4

Required parameters

  • name - name of web check
  • url - web check address
  • env - service environment
  • priority - importance of web check, where
    • 1 - information
    • 2 - warning
    • 3 - average
    • 4 - high
    • 5 - disaster

Extra options

You can also customize your validation by adding the following parameters:

  • delay - Execution interval of the web scenario in seconds. Default: 60.
  • retries - Number of times a web scenario will try to execute each step before failing. Default: 1.
  • timeout - Request timeout in seconds. Default: 15.
  • headers - HTTP headers that will be sent when performing a request. Scenario step headers will overwrite headers specified for the web scenario.

Example:

- name: GitHub
  url: https://github.com/OSidorenkov
  env: qa
  priority: 2
  delay: 120
  timeout: 30
  retries: 3
  headers: "Accept: application/json"

Update and delete

It is allowed to update existing web checks by changing or adding the following parameters:

  • url
  • delay
  • timeout
  • retries
  • headers

To delete a Web check, remove this check from the file and push it into the repository. Do not try to change the name of the verification (name). This will result in the old checkout being deleted and creating a new one, losing the history.

Execute

Go to the script directory and run:
python3 httpcheck.py

The script will check that you need to create, update or delete and perform all actions. Like that:

  • Web scenario:

2017-07-20 15 27 01

  • Steps:

2017-07-20 15 27 20

  • Trigger:

2017-07-20 15 28 46

About

Python script which controls Zabbix http tests from yaml file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages