GithubHelp home page GithubHelp logo

pawgajda / zabbix_ec2_meta-data_check Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bodziek666/zabbix_ec2_meta-data_check

0.0 0.0 0.0 134 KB

Automatically delete host of Zabbix server when in-scaling occurs at AWS EC2

License: MIT License

Python 100.00%

zabbix_ec2_meta-data_check's Introduction

Zabbix EC2 meta-data check

Automatically delete host configuration from Zabbix server when in-scaling occurs at AWS EC2.

Requirements

  • Zabbix 3.0
  • Python 2.7 or 3.6
  • Zabbix remote command must be allowed on each instances

Install templates & scripts to Zabbix server

  1. Import template files (templates/3.0/*.xml) to Zabbix server
  2. Place script files (externalscripts/*.py) at externalscripts directory of Zabbix server
    • ref. default directory: /usr/lib/zabbix/externalscripts/
  3. Modify Zabbix API parameters of delete_host.py and register_ec2_instanceid.py
    • ZABBIX_SERVER: your Zabbix web URL
    • ZABBIX_USER: your Zabbix web account username (super admin required)
    • ZABBIX_PASSWORD your Zabbix web account password
  4. Grant execution privilege to script files
    • eg. chmod +rx /usr/lib/zabbix/externalscripts/*.py

Configure Auto Scaling master AMI

Modify /etc/zabbix/zabbix_agentd.conf

  • Enable remote commands: # EnableRemoteCommands=0 -> EnableRemoteCommands=1
  • Enable remote log commands: # LogRemoteCommands=0 -> LogRemoteCommands=1
  • Modify server address (passive): ServerActive=127.0.0.1 -> ServerActive=<YOUR ZABBIX SERVER OR PROXY>
  • Modify server address (active): ServerActive=127.0.0.1 -> ServerActive=<YOUR ZABBIX SERVER OR PROXY>
  • Remove hostname: Hostname=Zabbix server -> # Hostname=Zabbix server
  • Enable hostname-item: # HostnameItem=system.hostname -> HostnameItem=system.hostname
  • Set host-metadata: # HostMetadata= -> HostMetadata=<SOMETHING>

Setup Zabbix auto registration (for scale-out)

Fill in template-macros

Fill in following template macros of AWS EC2 meta-data check

  • {$REGION}: EC2 region (eg. us-east-1)
  • {$KEY}: IAM Access key
  • {$SECRET}: IAM Secret access key

Note: If you separates AWS accounts or region, please make templates and link to AWS EC2 meta-data check

child templates

Create auto registration action

  • Conditions:
    • Host metadata like
  • Operations:
    • Add host
    • Link to templates: AWS EC2 meta-data check (or child template)
    • and your liking...

auto registration action

Setup Zabbix auto unregistration (for scale-in)

trigger action

Create instance-id registration action

  • Conditions:
    • Trigger value = OK
    • Trigger = AWS EC2 meta-data check: AWS EC2 meta-data check EC2 instance-id was changed
  • Operations:
    • Run remote commands on current host
      • Operation type: Remote command
      • Target list: Current host
      • Type: Custom script
      • Execute on: Zabbix server
      • Commands:
/usr/lib/zabbix/externalscripts/register_ec2_instanceid.py --hostname {HOST.HOST} --instanceid {ITEM.LASTVALUE}

instance-id registration action (condition)

instance-id registration action (operation)

instance-id registration action (operation)

Create host deleting action

  • Conditions:
    • Maintenance status not in maintenance
    • Trigger value = PROBLEM
    • Trigger = AWS EC2 meta-data check: AWS EC2 meta-data check EC2 instance was terminated
  • Operations:
    • Run remote commands on current host
      • Operation type: Remote command
      • Target list: Current host
      • Type: Custom script
      • Execute on: Zabbix server
      • Commands:
/usr/lib/zabbix/externalscripts/delete_host.py -n "{HOST.HOST}"

deleting host action (condition)

deleting host action action (operation)

License

  • MIT

zabbix_ec2_meta-data_check's People

Contributors

miyahan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.