patrolify


Namepatrolify JSON
Version 0.1.13 PyPI version JSON
download
home_page
Summary
upload_time2024-02-19 10:51:49
maintainer
docs_urlNone
authorlaixintao
requires_python>=3.10,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # patrolify

Do some checks every day, so that you can read the "news" in the morning while
drinking coffee.

## Install

## How to write a check?

### Define the "target" you want to check

```python
from patrolify import Target

class IPTarget(Target):
    def __init__(self, ip):
        self.ip = ip
```

### Define how to check that "target"

```python
from patrolify import check

@check(IPTarget)
def check_ip(target):
   return True, "it's ok"
```

A check function can:

- generates more targets: as long as the target can be checked by another
  checker;
- or return True/False to indicate the check was passed or not, plus a string
  indicate the extra information

### Test Your Checker

In local environment, you can test your checker from `__main__`. But you need
to fire `local_test_setup()` first.

For example, you can write this in your `checker.py`:

```python
if __name__ == '__main__':
    from patrolify.utils import local_test_setup
    local_test_setup()

    print(check_ip(IPTarget("127.0.0.1")))
```

### How to deploy?

Reporter was written in pure Python, requirements:

- Python 3.11+
- Redis 5.0+

Installation(The name `patrolify` was taken on Pypi):

```shell
pip install patrolify
```

Then you need to run 4 components after installation:

|Component Name|What for?|Dependencies|Command example|Can deploy instances?|
|--------------|---------|------------|---------------|---------------------|
|admin|A portal so that you can see the results|filesystem, Redis|`patrolify --redis-url redis://127.0.0.1:6379 admin --port 8084`|Yes, as long as the result directory exist.|
|scheduler|Trigger the checker jobs|Redis|`rqscheduler --host localhost --port 6379 --db 0` (it's redis' `host` and `port`)| Yes, supports auto fail over|
|worker(for checker)|Get jobs from queue(Redis) and run it|Redis|`patrolify --redis-url redis://127.0.0.1:6379 worker --queue=checker`|Yes, every worker will get jobs from queue and run it, more workers, more work load|
|worker(for patrolify)|Get jobs from queue(Redis) and run it, only works for collecting the results|Redis|`patrolify --redis-url redis://127.0.0.1:6379 worker --queue=patrolify`|Yes, same above. But it must be deployed onto the same server with admin|

- scheduler
- worker (2 types, for running checker jobs and patrolify jobs)
- admin

Architecture:

![](docs/patrolify-diagram.jpg)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "patrolify",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "laixintao",
    "author_email": "laixintaoo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/07/41/227f38c1c09d87db63a20525e9461bfe036960e3f6f6ad1c7db14d309fdf/patrolify-0.1.13.tar.gz",
    "platform": null,
    "description": "# patrolify\n\nDo some checks every day, so that you can read the \"news\" in the morning while\ndrinking coffee.\n\n## Install\n\n## How to write a check?\n\n### Define the \"target\" you want to check\n\n```python\nfrom patrolify import Target\n\nclass IPTarget(Target):\n    def __init__(self, ip):\n        self.ip = ip\n```\n\n### Define how to check that \"target\"\n\n```python\nfrom patrolify import check\n\n@check(IPTarget)\ndef check_ip(target):\n   return True, \"it's ok\"\n```\n\nA check function can:\n\n- generates more targets: as long as the target can be checked by another\n  checker;\n- or return True/False to indicate the check was passed or not, plus a string\n  indicate the extra information\n\n### Test Your Checker\n\nIn local environment, you can test your checker from `__main__`. But you need\nto fire `local_test_setup()` first.\n\nFor example, you can write this in your `checker.py`:\n\n```python\nif __name__ == '__main__':\n    from patrolify.utils import local_test_setup\n    local_test_setup()\n\n    print(check_ip(IPTarget(\"127.0.0.1\")))\n```\n\n### How to deploy?\n\nReporter was written in pure Python, requirements:\n\n- Python 3.11+\n- Redis 5.0+\n\nInstallation(The name `patrolify` was taken on Pypi):\n\n```shell\npip install patrolify\n```\n\nThen you need to run 4 components after installation:\n\n|Component Name|What for?|Dependencies|Command example|Can deploy instances?|\n|--------------|---------|------------|---------------|---------------------|\n|admin|A portal so that you can see the results|filesystem, Redis|`patrolify --redis-url redis://127.0.0.1:6379 admin --port 8084`|Yes, as long as the result directory exist.|\n|scheduler|Trigger the checker jobs|Redis|`rqscheduler --host localhost --port 6379 --db 0` (it's redis' `host` and `port`)| Yes, supports auto fail over|\n|worker(for checker)|Get jobs from queue(Redis) and run it|Redis|`patrolify --redis-url redis://127.0.0.1:6379 worker --queue=checker`|Yes, every worker will get jobs from queue and run it, more workers, more work load|\n|worker(for patrolify)|Get jobs from queue(Redis) and run it, only works for collecting the results|Redis|`patrolify --redis-url redis://127.0.0.1:6379 worker --queue=patrolify`|Yes, same above. But it must be deployed onto the same server with admin|\n\n- scheduler\n- worker (2 types, for running checker jobs and patrolify jobs)\n- admin\n\nArchitecture:\n\n![](docs/patrolify-diagram.jpg)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.13",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c7a626fe5734673b55d6465af89566cd2c19a11da3f70fc9037fd3339836697",
                "md5": "87fa18235ddbbb3575779a895fe2220f",
                "sha256": "5e51ed4abad2e3180e4960a6d5ff382bd44b8ff0c9a4abe4ca6be790a977c04f"
            },
            "downloads": -1,
            "filename": "patrolify-0.1.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "87fa18235ddbbb3575779a895fe2220f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 1214861,
            "upload_time": "2024-02-19T10:51:47",
            "upload_time_iso_8601": "2024-02-19T10:51:47.279071Z",
            "url": "https://files.pythonhosted.org/packages/3c/7a/626fe5734673b55d6465af89566cd2c19a11da3f70fc9037fd3339836697/patrolify-0.1.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0741227f38c1c09d87db63a20525e9461bfe036960e3f6f6ad1c7db14d309fdf",
                "md5": "b7f2817454a6e0fe446823c0f724b523",
                "sha256": "5b4a7aa769efff2d54cea69deadc8f36a13725694556f25bb80790a492394edf"
            },
            "downloads": -1,
            "filename": "patrolify-0.1.13.tar.gz",
            "has_sig": false,
            "md5_digest": "b7f2817454a6e0fe446823c0f724b523",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 1201918,
            "upload_time": "2024-02-19T10:51:49",
            "upload_time_iso_8601": "2024-02-19T10:51:49.359492Z",
            "url": "https://files.pythonhosted.org/packages/07/41/227f38c1c09d87db63a20525e9461bfe036960e3f6f6ad1c7db14d309fdf/patrolify-0.1.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-19 10:51:49",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "patrolify"
}
        
Elapsed time: 0.39957s