Skip to main content

Set up cgroup directory tree and add pid to cgroup

Project description

k3cgrouparch

Action-CI Documentation Status Package

This lib is used to set up cgroup directory tree according to configuration saved in zookeeper, and add pid to cgroup accordingly.

k3cgrouparch is a component of pykit3 project: a python3 toolkit set.

Name

cgrouparch

A python lib used to build cgroup directory tree, add set cgroup pid.

Status

This library is considered production ready.

Description

This lib is used to set up cgroup directory tree according to configuration saved in zookeeper, and add pid to cgroup accordingly.

Install

pip install k3cgrouparch

Synopsis

# {
#     'cpu': {
#         'sub_cgroup': {
#             'test_cgroup_a': {
#                 'conf': {
#                     'share': 1024,
#                 },
#             },
#             'test_cgroup_b': {
#                 'conf': {
#                     'share': 100,
#                 },
#                 'sub_cgroup': {
#                     'test_cgroup_b_sub1': {
#                         'conf': {
#                             'share': 200,
#                         },
#                     },
#                 },
#             },
#         },
#     },
# }

from k3cgrouparch import manager


def get_cgroup_pid_file(cgroup_name):
    if cgroup_name == 'test_cgroup_a':
        return ['/tmp/test.pid']
    # ...


def get_zk_host():
    return '127.0.0.1:2181,1.2.3.4:2181'


argkv = {
    'cgroup_dir': '/sys/fs/cgroup',
    'get_cgroup_pid_file': get_cgroup_pid_file,
    'get_zk_host': get_zk_host,
    'zk_prefix': '/cluser_a/service_rank',
    'zk_auth_data': [('digest', 'super:123456')],
    'communicate_ip': '127.0.0.1',
    'communicate_port': '3344',
}

manager.run(**argkv)

argkv = {
    'cgroup_dir': '/sys/fs/cgroup',
    'get_zk_host': get_zk_host,
    'zk_prefix': '/cluser_a/service_rank',
    'zk_auth_data': [('digest', 'super:123456')],
}
cgexec_arg = manager.get_cgexec_arg(['test_cgroup_a'], **argkv)

# return like:
# {
#     'test_cgroup_a': '-g cpu:test_cgroup_a',
# }

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

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

k3cgrouparch-0.1.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

k3cgrouparch-0.1.3-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file k3cgrouparch-0.1.3.tar.gz.

File metadata

  • Download URL: k3cgrouparch-0.1.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3cgrouparch-0.1.3.tar.gz
Algorithm Hash digest
SHA256 76c4d0f2c5e2a4778a7771751a3b1fb167d498636ad896db5953b163a0c04dcd
MD5 61a16b5d35bb16d6f534fcf8d58aa17d
BLAKE2b-256 97cf23abf37a78e10c84688ac46950267655133fb1b0cf2b0526b6134caff857

See more details on using hashes here.

File details

Details for the file k3cgrouparch-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: k3cgrouparch-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3cgrouparch-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79ed3be67b343d6c863ff6f448ebe539d24b66b86f91103ee138c4e097dcbc2c
MD5 53ed9090ba0c2cd268f5d4a4d491208c
BLAKE2b-256 3ccbe83864c09b33f2d44d9731e7ac45e92d26648f90de6b6f0bce2217591ac9

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