Name | cmk-tools JSON |
Version |
2.0.8
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2025-02-21 07:33:10 |
maintainer | None |
docs_url | None |
author | NhanDD3 |
requires_python | <4.0,>=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# CmkRedisTools
## Installation
To install the CmkRedisTools package, you can use pip:
```sh
pip install cmk-tools
```
or
```sh
poetry add cmk-tools
```
## Testing
To run tests for CmkRedisTools, use the following command:
```sh
pytest
```
## Example
All connector must provide `unique stage_id` for testing purrpose
### Using `redis semaphore`
Here is a simple example of how to use CmkRedisTools:
```python
from cmk_tools import RedisSemaphore, run_with_semaphore
semaphore = RedisSemaphore(
'redis://localhost:6379/0',
name="my_semaphore",
limit=3, # limit concurrent running task
timeout=10 # accquire timeout
)
run_with_semaphore(
your_func,
func_args,
func_kwargs,
execute_when_timeout=True # execute function if accquired timeout
)
```
For more detailed documentation, email me.
### Using `make_request_v2`
Here is an example of how to use the `make_request_v2` function:
```python
from cmk_tools import make_request_v2
response = make_request_v2(
url='https://api.example.com/data',
method='GET',
headers={'Authorization': 'Bearer YOUR_TOKEN'},
params={'key': 'value'},
data={'key': 'value'},
stage_id='unique-id',
)
print(response.json())
```
### Using `es_client`
Here is an example of how to use the `es_client` function:
```python
from cmk_tools import new_elk_client, elk_search
es_client = new_elk_client('host', 'port', 'username', 'password')
body = {"query": {}, "sort": []}
search_res = elk_search(
es_client,
'index', body,
with_scroll=False,
stage_id='unique-id'
)
# search_res should be an arrays of inner hits
print(search_res)
```
Here is an example of how to use the `es_client` search `with scroll` for get many data:
```python
from cmk_tools import new_elk_client, elk_search
es_client = new_elk_client('host', 'port', 'username', 'password')
body = {"query": {}, "sort": []}
search_res = elk_search(
es_client,
'index', body,
with_scroll=True,
stage_id='unique-id'
)
# search_res should be an arrays of inner hits
print(search_res)
```
### Using `snmp_get`
Here is an example of how to use the `snmp_get` function:
```python
from cmk_tools import snmp_get
data = netsnmp.VarList(
'....',
)
result = snmp_get(
host='192.168.1.1',
community='public',
data=data,
stage_id='unique-id'
)
print(result)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "cmk-tools",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "NhanDD3",
"author_email": "nhandd3@fpt.com",
"download_url": "https://files.pythonhosted.org/packages/be/26/b0511b37076aa10c48764b5afba100ad29da9b5bd7a89c646fc437406b92/cmk_tools-2.0.8.tar.gz",
"platform": null,
"description": "# CmkRedisTools\n\n## Installation\n\nTo install the CmkRedisTools package, you can use pip:\n\n```sh\npip install cmk-tools\n```\nor\n\n```sh\npoetry add cmk-tools\n```\n\n## Testing\n\nTo run tests for CmkRedisTools, use the following command:\n\n```sh\npytest\n```\n\n## Example \nAll connector must provide `unique stage_id` for testing purrpose\n\n### Using `redis semaphore`\nHere is a simple example of how to use CmkRedisTools:\n\n```python\nfrom cmk_tools import RedisSemaphore, run_with_semaphore\n\nsemaphore = RedisSemaphore(\n 'redis://localhost:6379/0',\n name=\"my_semaphore\",\n limit=3, # limit concurrent running task\n timeout=10 # accquire timeout\n)\n\nrun_with_semaphore(\n your_func,\n func_args,\n func_kwargs,\n execute_when_timeout=True # execute function if accquired timeout\n)\n```\n\nFor more detailed documentation, email me.\n\n\n### Using `make_request_v2`\n\nHere is an example of how to use the `make_request_v2` function:\n\n```python\nfrom cmk_tools import make_request_v2\n\nresponse = make_request_v2(\n url='https://api.example.com/data',\n method='GET',\n headers={'Authorization': 'Bearer YOUR_TOKEN'},\n params={'key': 'value'},\n data={'key': 'value'},\n stage_id='unique-id',\n)\nprint(response.json())\n```\n\n### Using `es_client`\n\nHere is an example of how to use the `es_client` function:\n\n```python\nfrom cmk_tools import new_elk_client, elk_search\n\nes_client = new_elk_client('host', 'port', 'username', 'password')\nbody = {\"query\": {}, \"sort\": []}\nsearch_res = elk_search(\n es_client, \n 'index', body, \n with_scroll=False, \n stage_id='unique-id'\n)\n\n# search_res should be an arrays of inner hits\nprint(search_res)\n```\n\nHere is an example of how to use the `es_client` search `with scroll` for get many data:\n\n```python\nfrom cmk_tools import new_elk_client, elk_search\n\nes_client = new_elk_client('host', 'port', 'username', 'password')\nbody = {\"query\": {}, \"sort\": []}\nsearch_res = elk_search(\n es_client, \n 'index', body, \n with_scroll=True, \n stage_id='unique-id'\n)\n\n# search_res should be an arrays of inner hits\nprint(search_res)\n```\n\n\n### Using `snmp_get`\n\nHere is an example of how to use the `snmp_get` function:\n\n```python\nfrom cmk_tools import snmp_get\n\ndata = netsnmp.VarList(\n '....',\n)\nresult = snmp_get(\n host='192.168.1.1',\n community='public',\n data=data,\n stage_id='unique-id'\n)\n\nprint(result)\n```",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "2.0.8",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "91619a14d71b9f2138f114b34305814e8e3b2b0c85a5717863d7561b7e254f00",
"md5": "6aabc48481d48bfb6dcac16ab1543ae4",
"sha256": "f7204b5877b0abaa7578d7a487cd276fa25360ebe943049c9b73802394b68aa8"
},
"downloads": -1,
"filename": "cmk_tools-2.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6aabc48481d48bfb6dcac16ab1543ae4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 15224,
"upload_time": "2025-02-21T07:33:08",
"upload_time_iso_8601": "2025-02-21T07:33:08.880926Z",
"url": "https://files.pythonhosted.org/packages/91/61/9a14d71b9f2138f114b34305814e8e3b2b0c85a5717863d7561b7e254f00/cmk_tools-2.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be26b0511b37076aa10c48764b5afba100ad29da9b5bd7a89c646fc437406b92",
"md5": "03a17e2666625fac783194e65de4de75",
"sha256": "bc046420e3fd53a1cf4a09ab5ab7c20826a9766e3bf50edc6943cd08d4480a25"
},
"downloads": -1,
"filename": "cmk_tools-2.0.8.tar.gz",
"has_sig": false,
"md5_digest": "03a17e2666625fac783194e65de4de75",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 11068,
"upload_time": "2025-02-21T07:33:10",
"upload_time_iso_8601": "2025-02-21T07:33:10.778952Z",
"url": "https://files.pythonhosted.org/packages/be/26/b0511b37076aa10c48764b5afba100ad29da9b5bd7a89c646fc437406b92/cmk_tools-2.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-21 07:33:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cmk-tools"
}