{ "info": { "author": "Andrey Okulov", "author_email": "okulov@ya.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: System :: Archiving :: Backup" ], "description": "# Command line batteries (clb)\nPlugin-driven Python program to improve the functionality of Bash commands without writing a too difficult Bash code.\n\n[![PyPI version](https://badge.fury.io/py/clb.svg)](https://badge.fury.io/py/clb)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/clb.svg)\n[![Requirements Status](https://requires.io/github/sharkman-devops/command_line_batteries/requirements.svg?branch=master)](https://requires.io/github/sharkman-devops/command_line_batteries/requirements/?branch=master)\n\nBash is good for backup pipelines like `mysqldump [options] | pigz [options] > mysqldump.gz` but there is no easy way to collect exit codes for every command in the pipeline, take care about commands environment, check for timeout, notify monitoring system, write awesome logs, send notifications to Slack, upload backups to AWS S3 and so on. With Command line batteries you have all of this stuff out of the box. Just fill the YAML config file and change the Python script file for your needs. These files are designed to be as simple as possible.\n\n## Features:\n- Timeout for every shell command\n- Check for exit code of every shell command, inclusive all commands in the pipeline\n- PATH environment var for shell commands\n- Informative logs\n- Slack notifications\n- Monitoring via influxdb metrics\n- AWS S3 upload with expiration policy\n\n## Usage\n#### Basic usage example:\n[example_simple_script.py](examples/example_simple_script.py) -c [example_simple_config.yml](examples/example_simple_config.yml)\n```\n2019-05-06 13:38:29,930 INFO in clb.config_parser: Reading config file: example_simple_config.yml\n2019-05-06 13:38:29,933 INFO in clb.shell_commands: Running shell command: mkdir -p /tmp/backups\n2019-05-06 13:38:29,943 INFO in clb.shell_commands: Shell command success\n2019-05-06 13:38:29,944 INFO in clb.shell_commands: Running shell command: echo 'THE BACKUP BASH COMMAND' | pigz -p 4 -4 > /tmp/backups/current_backup.gz\n2019-05-06 13:38:29,963 INFO in clb.shell_commands: Shell command success\n2019-05-06 13:38:29,964 INFO in clb: Commands completed\n```\n\n#### Advanced usage example:\n[example_script.py](examples/example_script.py) -c [example_config.yml](examples/example_config.yml)\n```\n2019-05-30 02:02:59,815 INFO in clb.config_parser: Reading config file: /opt/command_line_batteries/example_config.yml\n2019-05-30 02:02:59,822 INFO in clb.shell_commands: Running shell command: mkdir -p /tmp/backups\n2019-05-30 02:02:59,833 INFO in clb.shell_commands: Shell command success\n2019-05-30 02:02:59,834 INFO in clb.shell_commands: Running shell command: echo 'THE BACKUP BASH COMMAND' | pigz -p 4 -4 > /tmp/backups/current_backup.gz\n2019-05-30 02:02:59,846 INFO in clb.shell_commands: Shell command success\n2019-05-30 02:02:59,847 INFO in clb: Backup files created successfully\n2019-05-30 02:02:59,847 INFO in clb.notifiers.slack_client: Sending message \"Backup files created successfully\" to channel: YOUR_SLACK_CHANNEL\n2019-05-30 02:03:00,343 INFO in clb.notifiers.influxdb_client: Adding point to InfluxDB: {'measurement': 'backups', 'tags': {'status': 'Backup files created', 'host': 'YOUR_HOST'}, 'fields': {'value': 0}}\n2019-05-30 02:03:00,420 INFO in clb.storages.aws_s3: Upload /tmp/backups/current_backup.gz to s3/YOUR_AWS_BUCKET_FOR_BACKUPS/YOUR_HOST/2019-05-30-current_backup.gz\n2019-05-30 02:03:01,156 INFO in clb.storages.aws_s3: Update bucket YOUR_AWS_BUCKET_FOR_BACKUPS lifecycle rules\n2019-05-30 02:03:02,184 INFO in clb: Upload to s3 completed successfully\n2019-05-30 02:03:02,184 INFO in clb.notifiers.slack_client: Sending message \"Upload to s3 completed successfully\" to channel: YOUR_SLACK_CHANNEL\n2019-05-30 02:03:02,394 INFO in clb.notifiers.influxdb_client: Adding point to InfluxDB: {'measurement': 'backups', 'tags': {'status': 'Upload to s3 completed', 'host': 'YOUR_HOST'}, 'fields': {'value': 0}}\n2019-05-30 02:03:02,408 INFO in clb: Backup completed successfully\n2019-05-30 02:03:02,408 INFO in clb.notifiers.slack_client: Sending message \"Backup completed successfully\" to channel: YOUR_SLACK_CHANNEL\n2019-05-30 02:03:02,894 INFO in clb.notifiers.influxdb_client: Adding point to InfluxDB: {'measurement': 'backups', 'tags': {'status': 'Backup completed', 'host': 'YOUR_HOST'}, 'fields': {'value': 0}}\n```\n\n#### Grafana visualisation example:\n\n[hosted_snapshot](https://snapshot.raintank.io/dashboard/snapshot/Dw3pSX5NL3yXlZPXMv37872R12mEsTQg)\n\n[exported_json](grafana/backups_dashboard_example.json)\n\n## Installation\n#### The simplest way:\nDownload and run installation script (python2/3):\n```\n$ wget -O /tmp/install_clb.py https://raw.githubusercontent.com/sharkman-devops/command_line_batteries/master/install_clb.py\n$ sudo python /tmp/install_clb.py\n```\n\nCreate a cron job(crontab -e):\n```\n51 23 * * * /opt/command_line_batteries/venv/bin/python /opt/command_line_batteries/example_script.py -c /opt/command_line_batteries/example_config.yml >> /var/log/command_line_batteries/example.log 2>&1\n```\nDon't forget to fill the example_config.yml and check the example_script.py for logic you want!\n\n#### More flexible way:\nCreate an install directory:\n```\nmkdir -p /opt/command_line_batteries\n```\n\nCreate a virtual environment:\n```\npython3 -m venv /opt/command_line_batteries/venv\n```\n\nActivate a virtual environment:\n```\nsource /opt/command_line_batteries/venv/bin/activate\n```\n\nInstall the command line batteries:\n```\npip install clb --upgrade\n```\n\nDownload example script and config:\n```\nwget -O /opt/command_line_batteries/example_script.py https://raw.githubusercontent.com/sharkman-devops/command_line_batteries/master/example_script.py\nwget -O /opt/command_line_batteries/example_config.yml https://raw.githubusercontent.com/sharkman-devops/command_line_batteries/master/example_config.yml\n```\n\nMake the example script executable:\n```\nchmod +x /opt/command_line_batteries/example_script.py\n```\n\nCreate a logs directory:\n```\nmkdir -p /var/log/command_line_batteries\n```\n\nCreate a cron job (crontab -e):\n```\n51 23 * * * /opt/command_line_batteries/venv/bin/python /opt/command_line_batteries/example_script.py -c /opt/command_line_batteries/example_config.yml >> /var/log/command_line_batteries/example.log 2>&1\n```\nDon't forget to fill the example_config.yml and check the example_script.py for logic you want!\n\n\n## Compatibility\nEnvironment should include:\n- BASH Shell\n- Awk\n- Python 3.6 or 3.7\n\nCommand line batteries tested on GNU Linux with GNU bash 4, GNU Awk 4 and Python 3.6 & 3.7\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sharkman-devops/command_line_batteries", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "clb", "package_url": "https://pypi.org/project/clb/", "platform": "", "project_url": "https://pypi.org/project/clb/", "project_urls": { "Homepage": "https://github.com/sharkman-devops/command_line_batteries" }, "release_url": "https://pypi.org/project/clb/0.0.8/", "requires_dist": [ "PyYAML (<6.0,>=5.1)", "influxdb (<6.0,>=5.2.2)", "boto3 (<2.0,>=1.9.120)", "requests (<3.0,>=2.21.0)", "slackclient (<3.0,>=2.0.1)", "mypy (>=0.701<1.0) ; extra == 'devel'", "pylint (>=2.3.1<3.0) ; extra == 'devel'", "pytest (>=4.4.1<5.0) ; extra == 'devel'", "twine (>=1.13.0<2.0) ; extra == 'devel'" ], "requires_python": "", "summary": "Command line batteries (clb) - the way to improve the functionality of Bash commands without writing a too difficult Bash code.", "version": "0.0.8" }, "last_serial": 5334857, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "3af377b47115b604b27160365b9d285f", "sha256": "c6edf221f8c5bee3fcad344120b29f1b248a8b669f289edf45393f9339e540ee" }, "downloads": -1, "filename": "clb-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3af377b47115b604b27160365b9d285f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13198, "upload_time": "2019-05-02T01:20:02", "url": "https://files.pythonhosted.org/packages/bf/a5/dfbe4bb83edacedd8111c7bcda5c689d6f070f3d5e1bf4e37d89bbf0b723/clb-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7c66d0a43459a033b803a9ca272f522a", "sha256": "243fb8dab295ca2cbc36109f67cb1321d70b6186b916a955a75bafa435432e0c" }, "downloads": -1, "filename": "clb-0.0.1.tar.gz", "has_sig": false, "md5_digest": "7c66d0a43459a033b803a9ca272f522a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5380, "upload_time": "2019-05-02T01:20:05", "url": "https://files.pythonhosted.org/packages/79/1b/7fec25a01c6655c422d9ec53771d43f3e0d6dbae7fd148ef522a3fe3664e/clb-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "332c9b4093607d80969ea4ebb1d1fe46", "sha256": "7072bf4bf8e9825f63666a3a83f21101a26a60bb2883e1ef538df4910e802387" }, "downloads": -1, "filename": "clb-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "332c9b4093607d80969ea4ebb1d1fe46", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8574, "upload_time": "2019-05-06T14:38:10", "url": "https://files.pythonhosted.org/packages/6e/3b/f7b5aa4383b9e9cc1d9d069b969098ddee2c98b9c9ee5270ab39ba5dc422/clb-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44ae0159fedb1a2ae99e884edacda49e", "sha256": "e2b361b8c23a3194eed98783e2ddc94ce46e5cc87c3d36b1288e6eb8d0dea8da" }, "downloads": -1, "filename": "clb-0.0.2.tar.gz", "has_sig": false, "md5_digest": "44ae0159fedb1a2ae99e884edacda49e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6288, "upload_time": "2019-05-06T14:38:11", "url": "https://files.pythonhosted.org/packages/e7/ee/85b35737165c5f9217adfb11a90d34256fdc49ba3c988f05280935bd7dac/clb-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "d783a9df96c3c36be15e872c2a09994b", "sha256": "1065ee0872223c56f2dc0beb8aac58324e67c8fdc32ca16d9f92bfe4d4bd4c48" }, "downloads": -1, "filename": "clb-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d783a9df96c3c36be15e872c2a09994b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10226, "upload_time": "2019-05-07T11:19:01", "url": "https://files.pythonhosted.org/packages/46/e0/3cf5d1e7171cf5f06aa18b8ce54b3a48171d13ebb6c9385c62a7892da477/clb-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7ede3b484fbb01d24155ae49bef36f38", "sha256": "476872111f060fbdfc39ebef37a4710a345bb084c68f5cbdd7a4b6d65f56175d" }, "downloads": -1, "filename": "clb-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7ede3b484fbb01d24155ae49bef36f38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5619, "upload_time": "2019-05-07T11:19:03", "url": "https://files.pythonhosted.org/packages/27/14/daa56be64eb9b102bacfc51a0872be212e4a0faaeb09005f9f0b3cefcf75/clb-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "5f488b1303eb090c0cfb8bc7a63b4c48", "sha256": "466c2f3e2b96c499f3c8cf8dae839fd6b51c3f252ce64d3ca0aa809e56963e3e" }, "downloads": -1, "filename": "clb-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "5f488b1303eb090c0cfb8bc7a63b4c48", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10550, "upload_time": "2019-05-14T23:11:07", "url": "https://files.pythonhosted.org/packages/e7/c3/0739be5eda6515a5ad5c49868b6c3ef99842dbd9a57cee9851bfb25e0c1a/clb-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f4f34b7bde19bcf95351ce1b08cb9cf6", "sha256": "b0b49f90d3de920ed75cd386c91ce04a2451716313f97733d1f267ad7fdd531e" }, "downloads": -1, "filename": "clb-0.0.4.tar.gz", "has_sig": false, "md5_digest": "f4f34b7bde19bcf95351ce1b08cb9cf6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5746, "upload_time": "2019-05-14T23:11:09", "url": "https://files.pythonhosted.org/packages/0d/90/f08759ae720d46be47bb1f7b2ffb4146263357470d0941f4987086d3780d/clb-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "4bef289fc6eea0e1c4bd53790540ab9f", "sha256": "f44a73afe17fef44e8dd24335fa0259e90ab981f838256378d2fc62ac1c2d667" }, "downloads": -1, "filename": "clb-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "4bef289fc6eea0e1c4bd53790540ab9f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10562, "upload_time": "2019-05-20T23:12:45", "url": "https://files.pythonhosted.org/packages/25/56/4270f3c2bf461000bd0a93fd2188ff8c17001075fd8f1d41ccd3e1607d00/clb-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "46a4b4441842d960e77262b9d5299f96", "sha256": "aece9eb206930475ae278c591e6f842b4b30f4772ce5cc38dcb69d8e61fd7f64" }, "downloads": -1, "filename": "clb-0.0.5.tar.gz", "has_sig": false, "md5_digest": "46a4b4441842d960e77262b9d5299f96", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5893, "upload_time": "2019-05-20T23:12:46", "url": "https://files.pythonhosted.org/packages/a9/3a/88ac08720275843df6cb1363a9effd8ea9eb20c3769fb5377246f11a1d55/clb-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "8021010ffdd51e764477bbd8937ce002", "sha256": "2aaee5510afa66c99cce99704f260a98df2c4a9fe1b1f1bada1b36549eb2d5b9" }, "downloads": -1, "filename": "clb-0.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "8021010ffdd51e764477bbd8937ce002", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8238, "upload_time": "2019-05-25T17:46:40", "url": "https://files.pythonhosted.org/packages/6b/e1/6bb415c2da2d20094a423a2db403fe9b07e1b3a8ca80279a3e93b48e5e51/clb-0.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7ecfe0d5c59c0a006a6f9a89d10ee82e", "sha256": "4fccab9074d105162d03f30bbb2b521465785430a04e234db04c7222ec4f161d" }, "downloads": -1, "filename": "clb-0.0.6.tar.gz", "has_sig": false, "md5_digest": "7ecfe0d5c59c0a006a6f9a89d10ee82e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5929, "upload_time": "2019-05-25T17:46:42", "url": "https://files.pythonhosted.org/packages/23/54/3382e31dabaefc0b91b99160e0613c460117047fe305a0177453d9f210f0/clb-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "9d71c7f161d2881ff75a867005bb2f5c", "sha256": "1db60fdd7333cd6c2cbaba3addb01de4d9e2ab70e8c3b19c7b51bf732bcd10ef" }, "downloads": -1, "filename": "clb-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "9d71c7f161d2881ff75a867005bb2f5c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9035, "upload_time": "2019-05-28T11:25:16", "url": "https://files.pythonhosted.org/packages/0c/ca/4f29428cd44c0f3f6e62bc277a265187f5a1155aaf75e7f38e2e8670b498/clb-0.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17f721d2622197798f15d1743df30ff2", "sha256": "6b61097cbc8ec0ed2cc1862253c79466eeae9c3cd6fbd1ebb013b94261c398b9" }, "downloads": -1, "filename": "clb-0.0.7.tar.gz", "has_sig": false, "md5_digest": "17f721d2622197798f15d1743df30ff2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6383, "upload_time": "2019-05-28T11:25:18", "url": "https://files.pythonhosted.org/packages/49/f8/1e2ebfb521322eff15e96ba55a843de0e02a442c9ae97d575ffe588fd392/clb-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "c2b65f59eb317764bdb0977cb5feaf2d", "sha256": "d7750478c94a31cd3cbdb19c16b2b45bee9825677436857ce6a61885fe2d7f9d" }, "downloads": -1, "filename": "clb-0.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "c2b65f59eb317764bdb0977cb5feaf2d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9240, "upload_time": "2019-05-29T23:19:24", "url": "https://files.pythonhosted.org/packages/ba/7e/e5acdf05095fab37bb1bb5647859aa4072150e0fa5a4c5a318951fca0d75/clb-0.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e8db0f38646c7e33b038715a8f1cbc35", "sha256": "a2d75fd022fe9a7f1b4ccfe23076722ad07d8ab63916833f49f902cbeed97534" }, "downloads": -1, "filename": "clb-0.0.8.tar.gz", "has_sig": false, "md5_digest": "e8db0f38646c7e33b038715a8f1cbc35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6660, "upload_time": "2019-05-29T23:19:25", "url": "https://files.pythonhosted.org/packages/3d/c2/7a738a580ef5f07ef6c8c198d9933d9fc38cf577f3f4504228361b780386/clb-0.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2b65f59eb317764bdb0977cb5feaf2d", "sha256": "d7750478c94a31cd3cbdb19c16b2b45bee9825677436857ce6a61885fe2d7f9d" }, "downloads": -1, "filename": "clb-0.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "c2b65f59eb317764bdb0977cb5feaf2d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9240, "upload_time": "2019-05-29T23:19:24", "url": "https://files.pythonhosted.org/packages/ba/7e/e5acdf05095fab37bb1bb5647859aa4072150e0fa5a4c5a318951fca0d75/clb-0.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e8db0f38646c7e33b038715a8f1cbc35", "sha256": "a2d75fd022fe9a7f1b4ccfe23076722ad07d8ab63916833f49f902cbeed97534" }, "downloads": -1, "filename": "clb-0.0.8.tar.gz", "has_sig": false, "md5_digest": "e8db0f38646c7e33b038715a8f1cbc35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6660, "upload_time": "2019-05-29T23:19:25", "url": "https://files.pythonhosted.org/packages/3d/c2/7a738a580ef5f07ef6c8c198d9933d9fc38cf577f3f4504228361b780386/clb-0.0.8.tar.gz" } ] }