Giter VIP home page Giter VIP logo

py_add_host_zabbix's Introduction

Sử dụng api để add host trên zabbix server

Nếu bạn muốn add host lên zabbix server để thực hiện giám sát. Thông thường ta sẽ lên web để thực hiện việc này. Nhưng trong trường hợp ta có rất nhiều host cần phải add thì việc thực hiện trên web sẽ mất rất nhiều thời gian. Chính vì vậu chúng ta có thể sử api để làm việc này một cách đơn giản hơn.

Chuẩn bị một trường

Cài đặt python

yum install -y https://centos7.iuscommunity.org/ius-release.rpm

yum update

yum install -y python36u python36u-libs python36u-devel python36u-pip

Tạo virtual environments

python3.6 -m pip install --user virtualenv

python3.6 -m venv venv_zabbix

source venv_zabbix/bin/activate

pip install requests

Download script

mkdir zabbix

cd zabbix

git clone https://github.com/niemdinhtrong/py_add_host_zabbix.git

cd py_add_host_zabbix

Khai báo các host

Khi bạn download thư mục về trong thư mục sẽ gồm các file hosts main.py setting zabbix.py

Trước tiên bạn thực hiện khai báo các host trong muốn thực hiện add trong file hosts

Thực hiện khai báo host trong file hosts cần khai báo đúng định dạng ("name", "address") ví dụ như sau:

("host_1", "192.168.1.2")
("host_2", "192.168.1.3")
("client_3", "10.10.10.10")

Lưu ý mỗi dòng chỉ khai báo một địa chỉ và một host name

Khai báo thông tin của zabbix server

Thực hiện khai báo thông tin của zabbix server trong file setting

[zabbix]
zabbix_addr = 192.168.1.1
zabbix_username = admin
zabbix_password = zabbix
group_name = Linux servers
template_name = Template OS Linux

Trong đó:

  • zabbix_addr: địa chỉ của zabbix server
  • zabbix_username: user để login zabbix server (trên web)
  • zabbix_passwd: password dùng để login zabbix server (trên web)
  • group_name: tên group bạn muốn add các host đó vào(chú ý viết đúng tên group giống trên web)
  • template_name: tên template mà ta muốn sử dụng cho các host (chú ý viết đúng tên giống trên web)

Chạy chương trình

python main.py

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.