zabbix-utils 2.0.2__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/PKG-INFO +6 -5
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/README.md +4 -4
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/setup.py +78 -77
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/__init__.py +55 -55
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/aioapi.py +19 -9
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/aiosender.py +3 -1
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/api.py +1 -2
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/common.py +331 -331
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/getter.py +145 -145
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/sender.py +3 -2
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/version.py +3 -3
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils.egg-info/PKG-INFO +6 -5
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/LICENSE +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/setup.cfg +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/aiogetter.py +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/exceptions.py +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/logger.py +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils/types.py +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils.egg-info/SOURCES.txt +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils.egg-info/dependency_links.txt +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils.egg-info/requires.txt +0 -0
- {zabbix_utils-2.0.2 → zabbix_utils-2.0.4}/zabbix_utils.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: zabbix_utils
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: A library with modules for working with Zabbix (Zabbix API, Zabbix sender, Zabbix get)
|
|
5
5
|
Home-page: https://github.com/zabbix/python-zabbix-utils
|
|
6
6
|
Author: Zabbix SIA
|
|
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
24
|
Classifier: License :: OSI Approved :: MIT License
|
|
24
25
|
Classifier: Operating System :: OS Independent
|
|
25
26
|
Classifier: Topic :: System :: Monitoring
|
|
@@ -40,10 +41,10 @@ License-File: LICENSE
|
|
|
40
41
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml)
|
|
41
42
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml)
|
|
42
43
|
|
|
43
|
-
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml)
|
|
44
44
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml)
|
|
45
45
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml)
|
|
46
46
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_72.yaml)
|
|
47
|
+
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_74.yaml)
|
|
47
48
|
|
|
48
49
|
**zabbix_utils** is a Python library for working with [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference) as well as with [Zabbix sender](https://www.zabbix.com/documentation/current/manpages/zabbix_sender) and [Zabbix get](https://www.zabbix.com/documentation/current/manpages/zabbix_get) protocols.
|
|
49
50
|
|
|
@@ -51,13 +52,13 @@ License-File: LICENSE
|
|
|
51
52
|
|
|
52
53
|
Supported versions:
|
|
53
54
|
|
|
54
|
-
* Zabbix
|
|
55
|
+
* Zabbix 6.0+
|
|
55
56
|
* Python 3.8+
|
|
56
57
|
|
|
57
58
|
Tested on:
|
|
58
59
|
|
|
59
|
-
* Zabbix
|
|
60
|
-
* Python 3.8, 3.9, 3.10, 3.11 and 3.
|
|
60
|
+
* Zabbix 6.0, 7.0, 7.2 and 7.4
|
|
61
|
+
* Python 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13
|
|
61
62
|
|
|
62
63
|
Dependencies:
|
|
63
64
|
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_sender.yaml)
|
|
6
6
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/integration_getter.yaml)
|
|
7
7
|
|
|
8
|
-
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_50.yaml)
|
|
9
8
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_60.yaml)
|
|
10
9
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_70.yaml)
|
|
11
10
|
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_72.yaml)
|
|
11
|
+
[](https://github.com/zabbix/python-zabbix-utils/actions/workflows/compatibility_74.yaml)
|
|
12
12
|
|
|
13
13
|
**zabbix_utils** is a Python library for working with [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference) as well as with [Zabbix sender](https://www.zabbix.com/documentation/current/manpages/zabbix_sender) and [Zabbix get](https://www.zabbix.com/documentation/current/manpages/zabbix_get) protocols.
|
|
14
14
|
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
|
|
25
25
|
Supported versions:
|
|
26
26
|
|
|
27
|
-
* Zabbix
|
|
27
|
+
* Zabbix 6.0+
|
|
28
28
|
* Python 3.8+
|
|
29
29
|
|
|
30
30
|
Tested on:
|
|
31
31
|
|
|
32
|
-
* Zabbix
|
|
33
|
-
* Python 3.8, 3.9, 3.10, 3.11 and 3.
|
|
32
|
+
* Zabbix 6.0, 7.0, 7.2 and 7.4
|
|
33
|
+
* Python 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13
|
|
34
34
|
|
|
35
35
|
Dependencies:
|
|
36
36
|
|
|
@@ -1,77 +1,78 @@
|
|
|
1
|
-
# zabbix_utils
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2001-2023 Zabbix SIA
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person
|
|
6
|
-
# obtaining a copy of this software and associated documentation
|
|
7
|
-
# files (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
# including without limitation the rights to use, copy, modify,
|
|
9
|
-
# merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
-
# of the Software, and to permit persons to whom the Software
|
|
11
|
-
# is furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
# The above copyright notice and this permission notice shall be
|
|
14
|
-
# included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
-
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
-
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
-
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
-
# OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
|
|
25
|
-
import re
|
|
26
|
-
import setuptools
|
|
27
|
-
from zabbix_utils.version import __version__
|
|
28
|
-
|
|
29
|
-
with open("README.md", "r", encoding="utf-8") as fh:
|
|
30
|
-
regexp = r'(?<=##)\s*Get started\n*(^\*.*\n){1,10}\n*##'
|
|
31
|
-
long_description = re.sub(regexp, '', fh.read(), flags=re.M)
|
|
32
|
-
|
|
33
|
-
setuptools.setup(
|
|
34
|
-
name="zabbix_utils",
|
|
35
|
-
version=__version__,
|
|
36
|
-
author="Zabbix SIA",
|
|
37
|
-
author_email="integrationteam@zabbix.com",
|
|
38
|
-
maintainer="Aleksandr Iantsen",
|
|
39
|
-
maintainer_email="aleksandr.iantsen@zabbix.com",
|
|
40
|
-
description="A library with modules for working with Zabbix (Zabbix API, Zabbix sender, Zabbix get)",
|
|
41
|
-
long_description=long_description,
|
|
42
|
-
long_description_content_type="text/markdown",
|
|
43
|
-
keywords="monitoring zabbix api sender get utils tools",
|
|
44
|
-
url="https://github.com/zabbix/python-zabbix-utils",
|
|
45
|
-
test_suite='tests',
|
|
46
|
-
packages=["zabbix_utils"],
|
|
47
|
-
tests_require=["unittest"],
|
|
48
|
-
install_requires=[],
|
|
49
|
-
extras_require={
|
|
50
|
-
"async": ["aiohttp>=3,<4"],
|
|
51
|
-
},
|
|
52
|
-
python_requires='>=3.8',
|
|
53
|
-
project_urls={
|
|
54
|
-
'Zabbix': 'https://www.zabbix.com/documentation/current',
|
|
55
|
-
'Source': 'https://github.com/zabbix/python-zabbix-utils',
|
|
56
|
-
'Changes': 'https://github.com/zabbix/python-zabbix-utils/blob/main/CHANGELOG.md',
|
|
57
|
-
'Bug Tracker': 'https://github.com/zabbix/python-zabbix-utils/issues'
|
|
58
|
-
},
|
|
59
|
-
classifiers=[
|
|
60
|
-
"Development Status :: 5 - Production/Stable",
|
|
61
|
-
"Programming Language :: Python",
|
|
62
|
-
"Programming Language :: Python :: 3",
|
|
63
|
-
"Programming Language :: Python :: 3.8",
|
|
64
|
-
"Programming Language :: Python :: 3.9",
|
|
65
|
-
"Programming Language :: Python :: 3.10",
|
|
66
|
-
"Programming Language :: Python :: 3.11",
|
|
67
|
-
"Programming Language :: Python :: 3.12",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"Topic :: System ::
|
|
72
|
-
"Topic :: System ::
|
|
73
|
-
"
|
|
74
|
-
"Intended Audience ::
|
|
75
|
-
"Intended Audience ::
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
# zabbix_utils
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2001-2023 Zabbix SIA
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person
|
|
6
|
+
# obtaining a copy of this software and associated documentation
|
|
7
|
+
# files (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
# including without limitation the rights to use, copy, modify,
|
|
9
|
+
# merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
# of the Software, and to permit persons to whom the Software
|
|
11
|
+
# is furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
# The above copyright notice and this permission notice shall be
|
|
14
|
+
# included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
|
|
25
|
+
import re
|
|
26
|
+
import setuptools
|
|
27
|
+
from zabbix_utils.version import __version__
|
|
28
|
+
|
|
29
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
30
|
+
regexp = r'(?<=##)\s*Get started\n*(^\*.*\n){1,10}\n*##'
|
|
31
|
+
long_description = re.sub(regexp, '', fh.read(), flags=re.M)
|
|
32
|
+
|
|
33
|
+
setuptools.setup(
|
|
34
|
+
name="zabbix_utils",
|
|
35
|
+
version=__version__,
|
|
36
|
+
author="Zabbix SIA",
|
|
37
|
+
author_email="integrationteam@zabbix.com",
|
|
38
|
+
maintainer="Aleksandr Iantsen",
|
|
39
|
+
maintainer_email="aleksandr.iantsen@zabbix.com",
|
|
40
|
+
description="A library with modules for working with Zabbix (Zabbix API, Zabbix sender, Zabbix get)",
|
|
41
|
+
long_description=long_description,
|
|
42
|
+
long_description_content_type="text/markdown",
|
|
43
|
+
keywords="monitoring zabbix api sender get utils tools",
|
|
44
|
+
url="https://github.com/zabbix/python-zabbix-utils",
|
|
45
|
+
test_suite='tests',
|
|
46
|
+
packages=["zabbix_utils"],
|
|
47
|
+
tests_require=["unittest"],
|
|
48
|
+
install_requires=[],
|
|
49
|
+
extras_require={
|
|
50
|
+
"async": ["aiohttp>=3,<4"],
|
|
51
|
+
},
|
|
52
|
+
python_requires='>=3.8',
|
|
53
|
+
project_urls={
|
|
54
|
+
'Zabbix': 'https://www.zabbix.com/documentation/current',
|
|
55
|
+
'Source': 'https://github.com/zabbix/python-zabbix-utils',
|
|
56
|
+
'Changes': 'https://github.com/zabbix/python-zabbix-utils/blob/main/CHANGELOG.md',
|
|
57
|
+
'Bug Tracker': 'https://github.com/zabbix/python-zabbix-utils/issues'
|
|
58
|
+
},
|
|
59
|
+
classifiers=[
|
|
60
|
+
"Development Status :: 5 - Production/Stable",
|
|
61
|
+
"Programming Language :: Python",
|
|
62
|
+
"Programming Language :: Python :: 3",
|
|
63
|
+
"Programming Language :: Python :: 3.8",
|
|
64
|
+
"Programming Language :: Python :: 3.9",
|
|
65
|
+
"Programming Language :: Python :: 3.10",
|
|
66
|
+
"Programming Language :: Python :: 3.11",
|
|
67
|
+
"Programming Language :: Python :: 3.12",
|
|
68
|
+
"Programming Language :: Python :: 3.13",
|
|
69
|
+
"License :: OSI Approved :: MIT License",
|
|
70
|
+
"Operating System :: OS Independent",
|
|
71
|
+
"Topic :: System :: Monitoring",
|
|
72
|
+
"Topic :: System :: Networking :: Monitoring",
|
|
73
|
+
"Topic :: System :: Systems Administration",
|
|
74
|
+
"Intended Audience :: Developers",
|
|
75
|
+
"Intended Audience :: System Administrators",
|
|
76
|
+
"Intended Audience :: Information Technology"
|
|
77
|
+
]
|
|
78
|
+
)
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# zabbix_utils
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2001-2023 Zabbix SIA
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person
|
|
6
|
-
# obtaining a copy of this software and associated documentation
|
|
7
|
-
# files (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
# including without limitation the rights to use, copy, modify,
|
|
9
|
-
# merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
-
# of the Software, and to permit persons to whom the Software
|
|
11
|
-
# is furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
# The above copyright notice and this permission notice shall be
|
|
14
|
-
# included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
-
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
-
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
-
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
-
# OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
|
|
25
|
-
from .api import ZabbixAPI
|
|
26
|
-
from .sender import Sender
|
|
27
|
-
from .getter import Getter
|
|
28
|
-
from .types import ItemValue, APIVersion
|
|
29
|
-
from .exceptions import ModuleBaseException, APIRequestError, APINotSupported, ProcessingError
|
|
30
|
-
|
|
31
|
-
from .aiosender import AsyncSender
|
|
32
|
-
from .aiogetter import AsyncGetter
|
|
33
|
-
try:
|
|
34
|
-
__import__('aiohttp')
|
|
35
|
-
except ModuleNotFoundError:
|
|
36
|
-
class AsyncZabbixAPI():
|
|
37
|
-
def __init__(self, *args, **kwargs):
|
|
38
|
-
raise ModuleNotFoundError("No module named 'aiohttp'")
|
|
39
|
-
else:
|
|
40
|
-
from .aioapi import AsyncZabbixAPI
|
|
41
|
-
|
|
42
|
-
__all__ = (
|
|
43
|
-
'ZabbixAPI',
|
|
44
|
-
'AsyncZabbixAPI',
|
|
45
|
-
'APIVersion',
|
|
46
|
-
'Sender',
|
|
47
|
-
'AsyncSender',
|
|
48
|
-
'ItemValue',
|
|
49
|
-
'Getter',
|
|
50
|
-
'AsyncGetter',
|
|
51
|
-
'ModuleBaseException',
|
|
52
|
-
'APIRequestError',
|
|
53
|
-
'APINotSupported',
|
|
54
|
-
'ProcessingError'
|
|
55
|
-
)
|
|
1
|
+
# zabbix_utils
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2001-2023 Zabbix SIA
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person
|
|
6
|
+
# obtaining a copy of this software and associated documentation
|
|
7
|
+
# files (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
# including without limitation the rights to use, copy, modify,
|
|
9
|
+
# merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
# of the Software, and to permit persons to whom the Software
|
|
11
|
+
# is furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
# The above copyright notice and this permission notice shall be
|
|
14
|
+
# included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
|
|
25
|
+
from .api import ZabbixAPI
|
|
26
|
+
from .sender import Sender
|
|
27
|
+
from .getter import Getter
|
|
28
|
+
from .types import ItemValue, APIVersion
|
|
29
|
+
from .exceptions import ModuleBaseException, APIRequestError, APINotSupported, ProcessingError
|
|
30
|
+
|
|
31
|
+
from .aiosender import AsyncSender
|
|
32
|
+
from .aiogetter import AsyncGetter
|
|
33
|
+
try:
|
|
34
|
+
__import__('aiohttp')
|
|
35
|
+
except ModuleNotFoundError:
|
|
36
|
+
class AsyncZabbixAPI():
|
|
37
|
+
def __init__(self, *args, **kwargs):
|
|
38
|
+
raise ModuleNotFoundError("No module named 'aiohttp'")
|
|
39
|
+
else:
|
|
40
|
+
from .aioapi import AsyncZabbixAPI
|
|
41
|
+
|
|
42
|
+
__all__ = (
|
|
43
|
+
'ZabbixAPI',
|
|
44
|
+
'AsyncZabbixAPI',
|
|
45
|
+
'APIVersion',
|
|
46
|
+
'Sender',
|
|
47
|
+
'AsyncSender',
|
|
48
|
+
'ItemValue',
|
|
49
|
+
'Getter',
|
|
50
|
+
'AsyncGetter',
|
|
51
|
+
'ModuleBaseException',
|
|
52
|
+
'APIRequestError',
|
|
53
|
+
'APINotSupported',
|
|
54
|
+
'ProcessingError'
|
|
55
|
+
)
|
|
@@ -34,7 +34,7 @@ from textwrap import shorten
|
|
|
34
34
|
from os import environ as env
|
|
35
35
|
|
|
36
36
|
from urllib.error import URLError
|
|
37
|
-
from typing import Callable, Union, Optional, Any
|
|
37
|
+
from typing import Callable, Union, Optional, Coroutine, Any
|
|
38
38
|
from aiohttp.client_exceptions import ContentTypeError
|
|
39
39
|
|
|
40
40
|
from .types import APIVersion
|
|
@@ -120,7 +120,8 @@ class AsyncZabbixAPI():
|
|
|
120
120
|
__session_id = None
|
|
121
121
|
__internal_client = None
|
|
122
122
|
|
|
123
|
-
def __init__(self, url: Optional[str] = None,
|
|
123
|
+
def __init__(self, url: Optional[str] = None, token: Optional[str] = None,
|
|
124
|
+
user: Optional[str] = None, password: Optional[str] = None,
|
|
124
125
|
http_user: Optional[str] = None, http_password: Optional[str] = None,
|
|
125
126
|
skip_version_check: bool = False, validate_certs: bool = True,
|
|
126
127
|
client_session: Optional[aiohttp.ClientSession] = None, timeout: int = 30):
|
|
@@ -131,6 +132,10 @@ class AsyncZabbixAPI():
|
|
|
131
132
|
self.validate_certs = validate_certs
|
|
132
133
|
self.timeout = timeout
|
|
133
134
|
|
|
135
|
+
self.__token = token
|
|
136
|
+
self.__user = user
|
|
137
|
+
self.__password = password
|
|
138
|
+
|
|
134
139
|
client_params: dict = {}
|
|
135
140
|
|
|
136
141
|
if client_session is None:
|
|
@@ -171,18 +176,21 @@ class AsyncZabbixAPI():
|
|
|
171
176
|
return APIObject(name, self)
|
|
172
177
|
|
|
173
178
|
async def __aenter__(self) -> Callable:
|
|
174
|
-
return self
|
|
179
|
+
return await self.login()
|
|
175
180
|
|
|
176
181
|
async def __aexit__(self, *args) -> None:
|
|
177
182
|
await self.logout()
|
|
178
183
|
|
|
184
|
+
def __await__(self) -> Coroutine:
|
|
185
|
+
return self.login().__await__()
|
|
186
|
+
|
|
179
187
|
async def __aclose_session(self) -> None:
|
|
180
188
|
if self.__internal_client:
|
|
181
189
|
await self.__internal_client.close()
|
|
182
190
|
|
|
183
191
|
async def __exception(self, exc) -> None:
|
|
184
192
|
await self.__aclose_session()
|
|
185
|
-
raise exc
|
|
193
|
+
raise exc
|
|
186
194
|
|
|
187
195
|
def __close_session(self) -> None:
|
|
188
196
|
if self.__internal_client:
|
|
@@ -212,7 +220,7 @@ class AsyncZabbixAPI():
|
|
|
212
220
|
return self.api_version()
|
|
213
221
|
|
|
214
222
|
async def login(self, token: Optional[str] = None, user: Optional[str] = None,
|
|
215
|
-
password: Optional[str] = None) ->
|
|
223
|
+
password: Optional[str] = None) -> Callable:
|
|
216
224
|
"""Login to Zabbix API.
|
|
217
225
|
|
|
218
226
|
Args:
|
|
@@ -221,9 +229,9 @@ class AsyncZabbixAPI():
|
|
|
221
229
|
password (str, optional): Zabbix API user's password. Defaults to `None`.
|
|
222
230
|
"""
|
|
223
231
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
token = token or self.__token or env.get('ZABBIX_TOKEN') or None
|
|
233
|
+
user = user or self.__user or env.get('ZABBIX_USER') or None
|
|
234
|
+
password = password or self.__password or env.get('ZABBIX_PASSWORD') or None
|
|
227
235
|
|
|
228
236
|
if token:
|
|
229
237
|
if self.version < 5.4:
|
|
@@ -237,7 +245,7 @@ class AsyncZabbixAPI():
|
|
|
237
245
|
)
|
|
238
246
|
self.__use_token = True
|
|
239
247
|
self.__session_id = token
|
|
240
|
-
return
|
|
248
|
+
return self
|
|
241
249
|
|
|
242
250
|
if not user:
|
|
243
251
|
await self.__exception(ProcessingError("Username is missing"))
|
|
@@ -263,6 +271,8 @@ class AsyncZabbixAPI():
|
|
|
263
271
|
|
|
264
272
|
log.debug("Connected to Zabbix API version %s: %s", self.version, self.url)
|
|
265
273
|
|
|
274
|
+
return self
|
|
275
|
+
|
|
266
276
|
async def logout(self) -> None:
|
|
267
277
|
"""Logout from Zabbix API."""
|
|
268
278
|
|
|
@@ -69,6 +69,7 @@ Defaults to `None`.
|
|
|
69
69
|
self.use_ipv6 = use_ipv6
|
|
70
70
|
self.tls = {}
|
|
71
71
|
|
|
72
|
+
self.host = None
|
|
72
73
|
self.source_ip = None
|
|
73
74
|
self.chunk_size = chunk_size
|
|
74
75
|
self.compression = compression
|
|
@@ -105,6 +106,7 @@ Defaults to `None`.
|
|
|
105
106
|
for cluster in server_row.split(','):
|
|
106
107
|
self.clusters.append(Cluster(cluster.strip().split(';')))
|
|
107
108
|
|
|
109
|
+
self.host = config.get('Hostname')
|
|
108
110
|
if 'SourceIP' in config:
|
|
109
111
|
self.source_ip = config.get('SourceIP')
|
|
110
112
|
|
|
@@ -310,4 +312,4 @@ It must be a list of ItemValue objects: {json.dumps(chunk)}")
|
|
|
310
312
|
TrapperResponse: Response from Zabbix server/proxy.
|
|
311
313
|
"""
|
|
312
314
|
|
|
313
|
-
return await self.send([ItemValue(host, key, value, clock, ns)])
|
|
315
|
+
return await self.send([ItemValue(host or self.host or '', key, value, clock, ns)])
|
|
@@ -347,7 +347,6 @@ class ZabbixAPI():
|
|
|
347
347
|
headers=headers,
|
|
348
348
|
method='POST'
|
|
349
349
|
)
|
|
350
|
-
req.timeout = self.timeout
|
|
351
350
|
|
|
352
351
|
# Disable SSL certificate validation if needed.
|
|
353
352
|
if not self.validate_certs:
|
|
@@ -360,7 +359,7 @@ class ZabbixAPI():
|
|
|
360
359
|
ctx = None
|
|
361
360
|
|
|
362
361
|
try:
|
|
363
|
-
resp = ul.urlopen(req, context=ctx)
|
|
362
|
+
resp = ul.urlopen(req, context=ctx, timeout=self.timeout)
|
|
364
363
|
resp_json = json.loads(resp.read().decode('utf-8'))
|
|
365
364
|
except URLError as err:
|
|
366
365
|
raise ProcessingError(f"Unable to connect to {self.url}:", err) from None
|