Python send to zabbix

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Very simple python module implementing Zabbix Sender protocol.

License

MattParr/simplezabbixsender

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Very simple python module implementing Zabbix Sender protocol.
It allows one to build list of items and send them as trapper. It currently supports items as well as Low Level Discovery .

Once module is installed, you can use it as follow

#!/usr/bin/env python ''' import module ''' from simplezabbixsender import Item ''' create Item, providing item_host, item_key, and item_value with option item_clock_value ''' item = Item(host = 'my_host', key = 'trap.key[32]', value = 3.3333, clock=None) result = item.send(server='172.0.0.1', port=10051) try: result.raise_for_failure() except ZabbixTotalSendError: print 'failed to submit item' else: print 'item submitted' ## Send multiple items ''' set dryrun for testing purpose. Won't send anything to Zabbix ''' zbx_container.dryrun = True ''' Add items one after the other ''' hostname="myhost" item="my.zabbix.item" value=0 zbx_container.add_item( hostname, item, value) ''' or use bulk insert ''' data = < "myhost1": < "my.zabbix.item1": 0, "my.zabbix.item2": "item string" >, "myhost2": < "my.zabbix.item1": 0, "my.zabbix.item2": "item string" > > zbx_container.add(data) ''' Send data to zabbix ''' try: zbx_container.send() except SendException as e: print str(e) print "Everything is OK"

Send Low Level Discovery as trappers

Читайте также:  Php строка в нижнему регистру

#!/usr/bin/env python ''' import module ''' import zabbixsender ''' create DataContainer, providing data_type, zabbix server and port ''' zbx_container = zabbixsender.DataContainer(data_type = "lld", zbx_host = '127.0.0.1', zbx_port = 10051, debug = False, dryrun = False) ''' set debug ''' zbx_container.debug = True ''' Add items one after the other ''' hostname="myhost" item="my.zabbix.lld_item1" value=[ < 'my.zabbix.ldd_key1': 0, 'my.zabbix.ldd_key2': 'lld string' >, < 'my.zabbix.ldd_key3': 1, 'my.zabbix.ldd_key4': 'another lld string' > ] zbx_container.add_item( hostname, item, value) ''' or use bulk insert ''' data = < 'myhost1': < 'my.zabbix.lld_item1': [ < '': 0, '': 'lld string' >, < '': 1, '': 'another lld string' > ] 'myhost2': 'my.zabbix.lld_item2': [ < '': 10, '': 'yet an lld string' >, < '': 2, '': 'yet another lld string' > ] > zbx_container.add(data) ''' Send data to zabbix ''' try: zbx_container.send() except SendException as e: print str(e) print "Everything is OK"

About

Very simple python module implementing Zabbix Sender protocol.

Источник

Module pyzabbix.sender ¶

The ZabbixMetric contain one metric for zabbix server.

>>> from pyzabbix import ZabbixMetric >>> ZabbixMetric('localhost', 'cpu[usage]', 20) 

The ZabbixResponse contains the parsed response from Zabbix.

class pyzabbix.sender. ZabbixSender ( zabbix_server=’127.0.0.1′, zabbix_port=10051, use_config=None, chunk_size=250 ) ¶

The ZabbixSender send metrics to Zabbix server.

  • zabbix_server (str) – Zabbix server ip address. Default: 127.0.0.1
  • zabbix_port (int) – Zabbix server port. Default: 10051
  • use_config (str) – Path to zabbix_agentd.conf file to load settings from. If value is True then default config path will used: /etc/zabbix/zabbix_agentd.conf
  • chunk_size (int) – Number of metrics send to the server at one time
>>> from pyzabbix import ZabbixMetric, ZabbixSender >>> metrics = [] >>> m = ZabbixMetric('localhost', 'cpu[usage]', 20) >>> metrics.append(m) >>> zbx = ZabbixSender('127.0.0.1') >>> zbx.send(metrics) 

Send the metrics to zabbix server.

Читайте также:  Java call class files
Parameters: metrics (list) – List of zabbix.sender.ZabbixMetric to send to Zabbix
Return type: pyzabbix.sender.ZabbixResponse
Returns: Parsed response from Zabbix Server

© Copyright 2016, Alexey Dubkov. Revision 1d70c81f .

Versions latest stable Downloads htmlzip On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Источник

Quickstart guide¶

If your box already have zabbix_agent installed. Py-zabbix can use zabbix server from zabbix_agentd.conf file.

from pyzabbix import ZabbixMetric, ZabbixSender packet = [ ZabbixMetric('centos', 'test[cpu_usage]', 2), ZabbixMetric('centos', 'test[system_status]', "OK"), ZabbixMetric('centos', 'test[disk_io]', '0.1'), ZabbixMetric('centos', 'test[cpu_usage]', 20, 1411598020), ZabbixMetric('centos', 'test[cpu_usage]', 30, 1411598120), ZabbixMetric('centos', 'test[cpu_usage]', 40, 1411598240), ] sender = ZabbixSender(use_config=True) sender.send(packet) 

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

I was not happy with any of the existing pure Python senders for Zabbix, so I decided to write my own (based on zsend). And then I decided to add other features..

License

mumu520/python-zabbix

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Читайте также:  Функция лапласа python numpy

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

123456780123456789012345678901234567890123456789012345678901234567890123456890
This package implements vartious pure Python tools for Zabbix monitor development. This package provides the following;

I was not happy with any of the existing pure Python senders for Zabbix, so I decided to write my own. And then I decided to add other features.

Send a single item to the Zabbix server;

from zabbix import Sender zabbix = Sender(zabbix_serv='localhost',zabbix_port=10051) zabbix.add_item(key='myKey1',value='16535') zabbix.send()

Send multiple items to the Zabbix server;

from zabbix import Sender zabbix = Sender() zabbix.add_item(key='myKey1',value='16535') zabbix.add_item(key='myKey2',value='16534') zabbix.add_item(key='myKey3',value='16533') zabbix.send()

Build zabbix data with multiple items, but display it instead of sending;

from zabbix import Sender zabbix = Sender() zabbix.add_item(key='myKey1',value='16535') zabbix.add_item(key='myKey2',value='16534') zabbix.add_item(key='myKey3',value='16533') zabbix.send(print_values=True)

Send multiple items to Zabbix iteratively;

from zabbix import Sender zabbix = Sender() zabbix.add_item(key='myKey1',value='16535') zabbix.add_item(key='myKey2',value='16534') zabbix.add_item(key='myKey3',value='16533') zabbix.send(iterate_values=True)
  • You can also create your own apt or rpm package wth the following;
    • apt python setup.py —command-packages=stdeb.command bdist_deb
    • rpm python setup.py —command-packages=stdeb.command bdist_rpm
    • tar.gz python setup.py sdist
    • pypi package python setup.py bdist_wheel

    apt-get install python-zabbix

    Источник

Оцените статью