Git Product home page Git Product logo

python-protobix's Issues

Examples out of date

The examples as given don't seem to work - zbx_container.debug = True causes an error.
A guide on the module would be helpful to us beginners trying to use it.

The module does work well though, but required considerable trial and error and a good amount of perserverance.

AttributeError: 'dict' object has no attribute 'data_type'

I'm struggling with getting this to work properly.

Traceback (most recent call last):
  File "/etc/salt/eventsd_workers/Zabbix_Return_Worker.py", line 170, in _store
    self.zbx_datacontainer.add(data)
  File "/usr/local/lib/python2.7/dist-packages/protobix/datacontainer.py", line 69, in add
    self.add_item(host, key, data[host][key])
  File "/usr/local/lib/python2.7/dist-packages/protobix/datacontainer.py", line 48, in add_item
    if self._config.data_type == "items":
AttributeError: 'dict' object has no attribute 'data_type'

The datacontainer is setup like this:

            config = {
                # Protobix specific options
                'data_type': None,
                'dryrun': False,

                # Zabbix Agent options
                'ServerActive': self.creds['server'],
                'ServerPort': 10051,
                'LogType': 'file',
                'LogFile': '/dev/null',
                'DebugLevel': 3,
                'Timeout': 3,
                'Hostname': getfqdn(),
                'TLSConnect': 'unencrypted',
                'TLSCAFile': None,
                'TLSCertFile': None,
                'TLSCRLFile': None,
                'TLSKeyFile': None,
                'TLSServerCertIssuer': None,
                'TLSServerCertSubject': None,
                'TLSPSKIdentity': None,
                'TLSPSKFile': None,
            }

        config['data_type'] = 'items'

        log.debug('[Zabbix] Creating data container with config {0}'.format(config))

        self.zbx_datacontainer = protobix.DataContainer(config=config)

Later on we try to send data:

            data = {
                minion: {
                    self.creds['failed_key']: failed_counter,
                    self.creds['changed_key']: changed_counter
                }
            }
            log.debug('[Zabbix] Dataset to send: {0}'.format(data))

            self.zbx_datacontainer.add(data)

            response = self.zbx_datacontainer.send()

Previously I was using add_item but this was affected by the same.

I also tried to set it like self.zbx_datacontainer.data_type = 'items' and self.zbx_datacontainer.data_type('items') but had no luck with those either.

Am I doing something wrong? This is (more or less) also in the tests so ISTM this should work?

Error installing protobix

Upon doing pip install protobix I get the following error:

(logster)$ pip install functools
Downloading/unpacking functools
  Downloading functools-0.5.tar.gz
  Running setup.py (path:/home/jeune/.virtualenvs/logster/build/functools/setup.py) egg_info for package functools
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/home/jeune/.virtualenvs/logster/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
        from setuptools.extension import Extension
      File "/home/jeune/.virtualenvs/logster/local/lib/python2.7/site-packages/setuptools/extension.py", line 3, in <module>
        import functools
      File "functools.py", line 72, in <module>
        globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
    AttributeError: 'module' object has no attribute 'compose'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/home/jeune/.virtualenvs/logster/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>

    from setuptools.extension import Extension

  File "/home/jeune/.virtualenvs/logster/local/lib/python2.7/site-packages/setuptools/extension.py", line 3, in <module>

    import functools

  File "functools.py", line 72, in <module>

    globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)

AttributeError: 'module' object has no attribute 'compose'

Downloading from github and doing python setup.py install works. Please update the documentation. Installing via pip seems to be broken.

ZBX_RESP_REGEX for Zabbix 2.0

Correct REGEXP for both 2.2 & 2.4 is:
ZBX_RESP_REGEX = r'processed: (\d+); failed: (\d+); total: (\d+); seconds spent: (\d\.\d+)'

Check wether it's the same with Zabbix 2.0 or not. Could be:
ZBX_RESP_REGEX = r'Processed (\d+) Failed (\d+) Total (\d+) Seconds spent (\d\.\d+)'

Reading ServerActive from zabbix_agentd.conf is broken

It looks like reading ServerActive from zabbix_agentd.conf is broken in my environment.

On CentOS 6:

Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import protobix
>>> zbx_items = protobix.DataContainer(data_type = 'items')
>>> zbx_items._config
{'dryrun': False, 'data_type': 'items', 'server': '1', 'log_output': '/var/log/zabbix/zabbix_agentd.log', 'timeout': 3, 'log_level': 3, 'port': 10051}

On CentOS 7:

Python 2.7.5 (default, Nov 20 2015, 02:00:19) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import protobix
>>> zbx_items = protobix.DataContainer(data_type = 'items')
>>> zbx_items._config
{'dryrun': False, 'data_type': 'items', 'server': '1', 'log_output': '/var/log/zabbix/zabbix_agentd.log', 'timeout': 3, 'log_level': 3, 'port': 10051}

That's what my Zabbix Agent config looks like:

$ fgrep ServerActive /etc/zabbix/zabbix_agentd.conf
ServerActive=192.1.1.1

To me it looks like d88e2cd broke it, but my Python is not really good enough to judge.

Parsing failed with several errors.

Running protobix with it automatically reading the zabbix_agentd.conf results in traceback:

Traceback (most recent call last):
  File "./aamv2.py", line 168, in <module>
    ret = AAMv2().run()
  File "/usr/local/lib/python2.7/dist-packages/protobix/sampleprobe.py", line 281, in run
    self.zbx_config = self._init_config()
  File "/usr/local/lib/python2.7/dist-packages/protobix/sampleprobe.py", line 204, in _init_config
    zbx_config = ZabbixAgentConfig(self.options.config_file)
  File "/usr/local/lib/python2.7/dist-packages/protobix/zabbixagentconfig.py", line 56, in __init__
    tmp_config = configobj.ConfigObj(config_file, list_values=False)
  File "/usr/lib/python2.7/dist-packages/configobj.py", line 1229, in __init__
    self._load(infile, configspec)
  File "/usr/lib/python2.7/dist-packages/configobj.py", line 1318, in _load
    raise error
configobj.ConfigObjError: Parsing failed with several errors.
First error at line 202.

Line 202 of the /etc/zabbix/zabbix_agentd.conf is a userparameter:

UserParameter=updates.count.security,/usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f 2

This is actually the second userparameter in the file. If I uncomment this particular line (the 2nd), the next one complain and so on. Parsing only completes whenever all UserParameters have been commented out.

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.