jamesoff / simplemonitor

A Python-based network and host monitor
https://simplemonitor.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
407 stars 166 forks source link

Adding healthchecks.io alerter plus some other stuff #1464

Closed filak closed 1 month ago

filak commented 1 month ago

Firstly thank you for a great project !

I needed to implement push notifications to https://healthchecks.io/ using their Pinging API

I have also dived into some other features - not breaking any compatibility hopefully. Sorry for the fat PR - it just happend.

Major:

Minor:

I have run flake8, black and finally tox - with only:

envlist=py310,py311,py312

I have got the same results as with the current develop branch:

================================================================================================= short test summary info ==================================================================================================
FAILED tests/test_alerter.py::TestAlerter::test_should_not_alert_ooh - AssertionError: <AlertType.FAILURE: 'failure'> != <AlertType.NONE: 'none'>
FAILED tests/test_alerter.py::TestMessageBuilding::test_full_format_failure - AssertionError: '\nMo[47 chars]3-10 09:00:00+00:00 (down 0+00:00:00)\nVirtual[104 chars]s.\n' != '\nMo[47 chars]3-10 10:00:00+01:00 (down 0+...
FAILED tests/test_alerter.py::TestMessageBuilding::test_full_format_failure_docs - AssertionError: '\nMo[47 chars]3-10 09:00:00+00:00 (down 0+00:00:00)\nVirtual[127 chars]ps\n' != '\nMo[47 chars]3-10 10:00:00+01:00 (do...
FAILED tests/test_alerter.py::TestMessageBuilding::test_full_format_success - AssertionError: '\nMo[56 chars]3-10 09:00:00+00:00 (was down for 0+00:00:00)\[73 chars].)\n' != '\nMo[56 chars]3-10 10:00:00+01:00 (was down...
FAILED tests/test_alerter.py::TestMessageBuilding::test_oneline_format_failure - AssertionError: 'fail[34 chars]-03-10 09:00:00+00:00 (0+00:00:00): This monitor always fails.' != 'fail[34 chars]-03-10 10:00:00+01:00 (0...
FAILED tests/test_alerter.py::TestMessageBuilding::test_sms_format_failure - AssertionError: 'fail[34 chars]-03-10 09:00:00+00:00 (0+00:00:00): This monitor always fails.' != 'fail[34 chars]-03-10 10:00:00+01:00 (0+00:...
FAILED tests/test_monitor.py::TestMonitor::test_recovered - FileNotFoundError: [WinError 2] The system cannot find the file specified: 'did_recovered'
FAILED tests/test_monitor.py::TestMonitor::test_recovery - FileNotFoundError: [WinError 2] The system cannot find the file specified: 'did_recovery'
========================================================================================= 8 failed, 152 passed, 5 skipped in 4.57s =========================================================================================
py312: exit 1 (5.09 seconds) F:\Decko\simplemonitor> pytest tests/ pid=17400
.pkg: _exit> python f:\Decko\simplemonitor\venv\Lib\site-packages\pyproject_api\_backend.py True poetry.core.masonry.api
  py38: SKIP (0.28 seconds)
  py39: SKIP (0.05 seconds)
  py310: FAIL code 1 (17.45=setup[9.16]+cmd[8.30] seconds)
  py311: FAIL code 1 (17.31=setup[9.02]+cmd[8.30] seconds)
  py312: FAIL code 1 (11.80=setup[6.70]+cmd[5.09] seconds)
  evaluation failed :( (47.03 seconds)

The last two might be some Windows issues.

filak commented 1 month ago

Please let me know if you want to update/correct something. When you are OK with the PR I will mark it as ready.

jamesoff commented 1 month ago

Amazing, thanks! I will try to find the time to look though this properly ASAP :)

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 59.84252% with 51 lines in your changes missing coverage. Please review.

Project coverage is 72.44%. Comparing base (a740a66) to head (4e6087c). Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
simplemonitor/Alerters/healthchecks.py 59.37% 26 Missing :warning:
simplemonitor/Monitors/network.py 50.00% 19 Missing :warning:
simplemonitor/Alerters/telegram.py 0.00% 3 Missing :warning:
simplemonitor/simplemonitor.py 76.92% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1464 +/- ## =========================================== - Coverage 72.91% 72.44% -0.48% =========================================== Files 45 46 +1 Lines 4206 4308 +102 =========================================== + Hits 3067 3121 +54 - Misses 1139 1187 +48 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jamesoff commented 1 month ago

Thanks again! :)