8000 GitHub - PerchunPak/apykuma: Small library to notify Uptime Kuma that the service is up.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PerchunPak/apykuma

Repository files navigation

apykuma

Support Ukraine

Build Status Code style: black Python support versions badge (from pypi)

Small library to notify Uptime Kuma that the service is up. Only async applications are supported.

Usage

Create a new Push monitor on your Kuma instance:

image

Then, install the library:

pip install apykuma

And include it in your code:

import logging
import apykuma

await apykuma.start(
    # Required; URL copied from the image above
    url="https://kuma.example.com/api/push/63MlSOY4CM?status=up&msg=OK&ping=",
    # Optional; default is 60 seconds
    interval=60,
    # Optional; sleeps for N seconds before pinging Kuma, in case if you run `apykuma` right before starting your service
    #           (if service fails, `apykuma` won't start as well). The recommended value is 10 seconds
    delay=0,
    # Optional; function that is called when during ping we encourage an error
    #           it is done to notify you about (e.g.) network errors, and to not
    #           stop the process of pinging kuma on such errors
    #
    #           by default, it logs an error using `logging` library (default value is shown below),
    #           also supports async functions
    handle_exception=lambda e: logging.getLogger("apykuma").exception(e),
)

It is important to start apykuma after your service starts.

Differences from pykuma

https://github.com/oliverstech/pykuma

That library is great, but it has some problems:

  • It uses globals, which I personally don't like
  • It blocks the loop every time it sends a request, because it uses requests library instead of aiohttp. See also oliverstech/pykuma#2.

Installing for local developing

git clone https://github.com/PerchunPak/apykuma.git
cd apykuma

Installing poetry

Next we need install poetry with recommended way.

If you use Linux, use command:

curl -sSL https://install.python-poetry.org | python -

If you use Windows, open PowerShell with admin privileges and use:

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

Installing dependencies

poetry install --no-dev

Configuration

All configuration happens in config.yml, or with enviroment variables.

If something is not clear

You can always write me!

Thanks

This project was generated with python-template.

About

Small library to notify Uptime Kuma that the service is up.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0