GithubHelp home page GithubHelp logo

zbx-rc's Introduction

zbx-rc

Utility to send message from Zabbix into Rocket.Chat. alt

alt

Program run with Python > 3.4

Latest stable versions: 0.3

Original code: https://github.com/asand3r/zbx-rc/wiki/Configure-media-type-in-Zabbix

https://share.zabbix.com/cat-notifications/zabbix-to-rocket-chat

How to add alert script in Zabbix: https://www.zabbix.com/documentation/3.4/manual/config/notifications/media/script

How to install zbx-rc:

Dependencies

  • requests

Feautres

Common:

  • Send simple text message
  • HTTPS support
  • Update config file in place
  • Update message if problem resolved (id message get by triggerid/eventid)
  • Attach images to message

TODO

  • Clear old messages

Supported arguments

Please, read help message first, it always actual.

Common:

-h|--help
Print help message
-v|--version
Print version number
-c|--config
Path to config file (default: zbx-rc.conf near executable file)
--debug
Turn on debug output to console

Positional:

install
Prepate environment. Create config directory and config example.

-c|--conf-dir
Path to conig directory (Default: /etc/zbx-rc)
-g|--group
System group, who will be own config directory (Default: zabbix)

auth
Authenticate to Rocket.Chat

-u|--username
Rocket.Chat username
-p|--password
Rocket.Chat password

send
Send message to Rocket.Chat

to Recipient
subject Subject
message Text body

Usage examples

Install script to your system. In fact, it's just creates config directory with config example:

[root@server ~]# ./zbx-rc.py install
INFO: Script installed successfully. Please, correct /etc/zbx-rc/zbx-rc.conf file for your environment.
[root@server ~]# cat ./zbx-rc/zbx-rc.conf
[RCHAT]
protocol = https
server = rocketchat.mts-nn.ru
port = 443
uid = 
token = 
[ZABBIX]
zbx_server = https://zabbix
zbx_api_user = user
zbx_api_pass = password
zbx_api_verify = False
zbx_tmp_dir = /tmp

Graphs get by template in messages

zbx;itemid:(\d+)

In action messages must be

zbx;itemid:{ITEM.ID1}

to send graph

At startup, it will check if there is a database along the path

/opt/zbx-rc/

and if not, it will be created. If an error occurs with rights, run the script with root rights. If it fails, create a directory '/opt/zbx-rc/' and give write permissions to the user/group the zabbix.

Authenticate to Rocket.Chat with REST API:

[root@server ~]# ./zbx-rc.py auth -u 'asand3r' -p 'secretPa$$word'
id:     '1234567890'
token:  'c68019f8c6e613180ac296d5870e9cdb4b46f29c'

You can provide '--update' parameter to update your config file with received values:

[root@server ~]# ./zbx-rc.py auth -u 'asand3r' -p 'secretPa$$word' --update

Use 'send' parameter to send simple text message:

[root@server ~]# ./zbx-rc.py send '@asand3r' 'PROBLEM: Free space is low (5%)' 'Free space on disk C:\ too low - 5%'

When using the URL https://<zabbix/tr_events.php?triggerid=3349067&eventid=4026100586, the message id with triggerid eventid will be saved in the sqlite database. If a message is received with the same triggerid eventid it will be updated.

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.