No project description provided
Project description
CmkRedisTools
Installation
To install the CmkRedisTools package, you can use pip:
pip install cmk-tools
or
poetry add cmk-tools
Testing
To run tests for CmkRedisTools, use the following command:
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:
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:
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:
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:
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:
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmk_tools-2.0.5.tar.gz.
File metadata
- Download URL: cmk_tools-2.0.5.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.0 CPython/3.13.2 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
199985b7c43deb2a7319cfc7e9069dc8555715c4b702269da84b1e7cd111b23f
|
|
| MD5 |
ed4ba08ba5e3d4d2eba732038661e6fa
|
|
| BLAKE2b-256 |
51f5987841a2835b0e5076c4ae90fa40836cf312715da0f981eda8015bfae8a2
|
File details
Details for the file cmk_tools-2.0.5-py3-none-any.whl.
File metadata
- Download URL: cmk_tools-2.0.5-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.0 CPython/3.13.2 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b69a2669c99dd98a603c078ad3344a5f04208408ccc7aa27c7efb23df6a3bca7
|
|
| MD5 |
7c3e88e791401e32b0f8e204253ed980
|
|
| BLAKE2b-256 |
a0552d2f0ad46702d1858c5bbb5131b023f7f6e4295c233271eeaf68b3ee284d
|