Skip to main content

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.snmp_client 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmk_tools-2.0.10.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmk_tools-2.0.10-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file cmk_tools-2.0.10.tar.gz.

File metadata

  • Download URL: cmk_tools-2.0.10.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for cmk_tools-2.0.10.tar.gz
Algorithm Hash digest
SHA256 74889352c34401925d29ea22c88f54cdd8a16b02b5b01e71b7f3bf407a7c3f95
MD5 5aa93437d19035e6375b0274b616a710
BLAKE2b-256 c25b4c985757e76b51c98cbb7b08026854f427a36f4c1dd3a38b9fd6374a1666

See more details on using hashes here.

File details

Details for the file cmk_tools-2.0.10-py3-none-any.whl.

File metadata

  • Download URL: cmk_tools-2.0.10-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for cmk_tools-2.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 24f590c46d5f31007220e44050d059ac3973d754bfbe93569edd72fb4e8a169c
MD5 f90a2033b3dbaaa03107c1d9c1c80e16
BLAKE2b-256 7ce836b4b9552e5b9d0589a9b1a97cecd9c863c96d7237c3e152507bda17f1c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page