Skip to main content

Programa de monitoramento de código python, desenvolvido para ser utilizado pelas funcionário da Agência de dados

Project description

Monit

Instalação:

pip install pymonit

Atualização:

pip install -U pymonit

Exemplo arquivo .monit:

PROJECT='project_name'
COMPANY='company_name'
DEV='coder'
LOCATION='location_name'
HANDLER_URL='https://example.com'
PHONE='556199999999'

Exemplo de Uso:

Utilização simples

import time

from monit.core import Monitor as monit

def main():

    try:
        time.sleep(5)
        raise ValueError("This is a sample error.")

    except Exception as e:
        monit.notify_and_exit(e) # para o script

    monit.end() # manda sinal de fim sem erros


if __name__ == "__main__":
    main()

Utilização avançada

from time import sleep

from monit.core import Monitor as monit
from monit.logger import Logger
from monit.log2file import Log2File

Log2File() # Salva todo o log em um arquivo
log = Logger()

def main():

    try:
        log.info("Hello, World!")

        sleep(2)
        raise ValueError("This is a sample error.")

    except Exception as e:
        monit.msg("Ocorreu um erro, tentando de novo...") # Whatsapp
        monit.notify(e) # não para o script

        try:
            log.info("Tentando novamente...")

            sleep(2)
            raise ValueError("This is another error.")

        except Exception as e:
            monit.msg("Script terminou com erros.")
            monit.notify_and_exit(e)

    monit.end()


if __name__ == "__main__":
    main()

Soluções De Problemas

PdhAddEnglishCounterW failed. Performance counters may be disabled.

O erro ocorre porque os contadores de desempenho do Windows estão desativados ou corrompidos, causando a falha da função PdhAddEnglishCounterW. Execute os seguintes comandos em um CMD com privilégios administrativos:

lodctr /r
winmgmt /resyncperf

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

pymonit-1.5.4.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

pymonit-1.5.4-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

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