{ "info": { "author": "Matthew Kalnins", "author_email": "pybix@matthewkalnins.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: System :: Monitoring" ], "description": "# pybix\n\n**NOTE: This module is still in development and may not be fully stable. Use at own risk.**\n\n## Description\n\nPython based Zabbix API utility containing helper functions and CLI capabilities.\n\nTakes inspiration from existing Python-Zabbix API modules like [lukecyca/pyzabbix](https://github.com/lukecyca/pyzabbix) and [adubkov/py-zabbix](https://github.com/adubkov/py-zabbix).\n\nWhile this module can be used in a similar way, the aim is to add a few out of the box helper functions and CLI handling for a more \"batteries included\" module. For example GraphImage as described in usage which enables saving Zabbix graphs which is not possible via the API at this time.\n\n## Install\n\n### Pip\n\n```\npip install pybix\n```\n\n### Docker\n\nTODO - not yet available.\n\n## Requirements\n\n* Python 3.6 or greater\n* Zabbix 2.0 or greater\n * Only tested on >4.0\n\n## Usage\n\n### Zabbix API\n\nRefer to [Zabbix Offical API object](https://www.zabbix.com/documentation/4.2/manual/api/reference) references for objects that can be queried and their parameters.\n\nAPI structure all uses format like `ZAPI..()` e.g. `ZAPI.host.get(output='extend')`.\n\n#### Import as Python module\n\n##### Directly\n\n```python\nfrom pybix import ZabbixAPI\nZAPI = ZabbixAPI(url=\"http://localhost/zabbix\")\nZAPI.login(user=\"Admin\", password=\"zabbix\")\n\n# Print all monitored hosts\nfor host in ZAPI.host.get(output=\"extend\",monitored_hosts=1):\n print(host['host'])\n\nZAPI.logout() # Explicitly logout to clear Zabbix session\n```\n\n##### With context manager to handle logout\n\nNote: Login still must be done manually (as in the future we may allow passing existing session, hence might not need to login everytime).\n\n```python\nfrom pybix import ZabbixAPI\n\nwith ZabbixAPI() as ZAPI: # using defaults for server\n ZAPI.login() # using defaults for user, password\n\n # Print all monitored hosts\n for host in ZAPI.host.get(output=\"extend\",monitored_hosts=1):\n print(host['host'])\n```\n\n#### Zabbix API CLI\n\n##### Zabbix API CLI Usage\n\n```bash\nUsage:\n pybix.py [--zabbix-server=ZABBIX_SERVER] [--zabbix-user=ZABBIX_USER]\n [--zabbix-password=ZABBIX_PASSWORD] [--ssl-verify] [(-v | --verbose)] [ ...]\n pybix.py (-h | --help)\n pybix.py --version\n\nArguments:\n method either Zabbix API reference as '.' or GraphImage API as 'graphimage.' (e.g. 'host.get' or 'graphimage.graph_id')\n args what arguments to pass to API call\n\nOptions:\n -h, --help\n --version\n -v, --verbose Whether to use verbose logging [default: False]\n --output-path=PATH Where to save graphs to default: cwd\n --zabbix-server=ZABBIX_SERVER [default: https://localhost/zabbix]\n --zabbix-user=ZABBIX_USER [default: Admin]\n --zabbix-password=ZABBIX_PASSWORD [default: zabbix]\n --ssl-verify Whether to use SSL verification for API [default: True]\n```\n\n##### Zabbix API CLI Example\n\n```bash\npython -m pybix host.get filter=\"{host:server1}\" # Get host server1\npython -m pybix host.get filter=\"{host:[server1,server2]}\" # Get host server1 and server2\npython -m pybix user.get # Get all Users\n```\n\n### Graph Image Export\n\nZabbix does not let you export graphs via API (only the configuration for them). Instead of using `ZabbixAPI` class, use included `GraphImage`.\n\n#### GraphImage Python Example\n\n```python\nfrom pybix import GraphImageAPI\ngraph = GraphImageAPI(url=\"http://localhost/zabbix\",\n user=\"Admin\",\n password=\"zabbix\")\ngraph.get_by_graphid(\"4038\") # will save to png file in current working directory\ngraph.get_by_graphname(\"CPU\") # will save any \"CPU\" graph png images to file in current working directory\n```\n\n#### GraphImage CLI\n\n##### GraphImage CLI Usage\n\nRefer to [ZabbixAPI usage](#####zabbix-api-cli-usage).\n\n`search_types` include `graph_id, graph_name, item_names, item_keys, item_ids`\n\n##### GraphImage CLI Examples\n\n```bash\npython -m pybix graphimage.graph_name graph_name=CPU host_names=server1\npython -m pybix graphimage.graph_name graph_name=CPU host_names=[server1,server2]\npython -m pybix graphimage.item_names item_names=CPU host_names=server1\npython -m pybix graphimage.item_keys item_keys=availability.agent.available host_names=server1\n\n# Not as useful, but is what above methods call after calculating id\npython -m pybix graphimage.graph_id graph_id=4038 host_names=server1\npython -m pybix graphimage.item_ids item_ids=138780,138781 host_names=server1\n```\n\n## Known Issues\n\n### SSL Verification\n\n* If server using a self signed cert or serving on HTTPS, will need to use `ssl_verify` overide\n\n### User configuration\n\n* Zabbix user used during API calls must have viewing rights to queried Zabbix object\n * i.e. appropriate hostgroup read rights to user/usergroup OR super admin\n * If it does not, it will simply return empty results without warning\n\n### Graph Items Usage\n\n* User used to login must have frontend access (i.e. in Zabbix user group, set frontend access to true)\n* No error messages or warnings if graph is invalid (i.e. wrong values used to call it)\n\n## Contributing\n\nFeel free to raise any feature requests/problems/improvements as issue or pull request via [GitHub](https://github.com/mattykay/pybix).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mattykay/pybix", "keywords": "zabbix,monitoring,api", "license": "", "maintainer": "", "maintainer_email": "", "name": "pybix", "package_url": "https://pypi.org/project/pybix/", "platform": "", "project_url": "https://pypi.org/project/pybix/", "project_urls": { "Homepage": "https://github.com/mattykay/pybix" }, "release_url": "https://pypi.org/project/pybix/0.0.7/", "requires_dist": [ "requests (>=2.22.0)", "docopt (>=0.6.2)" ], "requires_python": ">=3.6", "summary": "Python based Zabbix API utility with helper functions", "version": "0.0.7" }, "last_serial": 5701403, "releases": { "0.0.7": [ { "comment_text": "", "digests": { "md5": "1221a227453bca739df01470c34af81b", "sha256": "cedddc773ba6b2bce157d969b43ac66febe04b9d32507b6d31d5a7a05afeecab" }, "downloads": -1, "filename": "pybix-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "1221a227453bca739df01470c34af81b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 12421, "upload_time": "2019-08-20T03:59:59", "url": "https://files.pythonhosted.org/packages/dc/05/f94e706796ce976df6e491dbb037978717144ea27e872f1b8b33f87e74f9/pybix-0.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21ac7dfb86ec8cf1436c85c511c5e40f", "sha256": "48bf94983a20c560d157f525f944591a2cee5ed15005c2f6ec2a0086e32113d1" }, "downloads": -1, "filename": "pybix-0.0.7.tar.gz", "has_sig": false, "md5_digest": "21ac7dfb86ec8cf1436c85c511c5e40f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 12316, "upload_time": "2019-08-20T04:00:01", "url": "https://files.pythonhosted.org/packages/c0/07/111986509553b1b7ff55ce3e3cfd5df4ca2fb63ce65a534bf0ec0780028c/pybix-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1221a227453bca739df01470c34af81b", "sha256": "cedddc773ba6b2bce157d969b43ac66febe04b9d32507b6d31d5a7a05afeecab" }, "downloads": -1, "filename": "pybix-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "1221a227453bca739df01470c34af81b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 12421, "upload_time": "2019-08-20T03:59:59", "url": "https://files.pythonhosted.org/packages/dc/05/f94e706796ce976df6e491dbb037978717144ea27e872f1b8b33f87e74f9/pybix-0.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21ac7dfb86ec8cf1436c85c511c5e40f", "sha256": "48bf94983a20c560d157f525f944591a2cee5ed15005c2f6ec2a0086e32113d1" }, "downloads": -1, "filename": "pybix-0.0.7.tar.gz", "has_sig": false, "md5_digest": "21ac7dfb86ec8cf1436c85c511c5e40f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 12316, "upload_time": "2019-08-20T04:00:01", "url": "https://files.pythonhosted.org/packages/c0/07/111986509553b1b7ff55ce3e3cfd5df4ca2fb63ce65a534bf0ec0780028c/pybix-0.0.7.tar.gz" } ] }