-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monitor backups with Cronitor hook integration.
- Loading branch information
Showing
9 changed files
with
97 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
import requests | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def ping_cronitor(ping_url, config_filename, dry_run, append): | ||
''' | ||
Ping the given Cronitor URL, appending the append string. Use the given configuration filename | ||
in any log entries. If this is a dry run, then don't actually ping anything. | ||
''' | ||
if not ping_url: | ||
logger.debug('{}: No Cronitor hook set'.format(config_filename)) | ||
return | ||
|
||
dry_run_label = ' (dry run; not actually pinging)' if dry_run else '' | ||
ping_url = '{}/{}'.format(ping_url, append) | ||
|
||
logger.info('{}: Pinging Cronitor {}{}'.format(config_filename, append, dry_run_label)) | ||
logger.debug('{}: Using Cronitor ping URL {}'.format(config_filename, ping_url)) | ||
|
||
logging.getLogger('urllib3').setLevel(logging.ERROR) | ||
requests.get(ping_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from setuptools import find_packages, setup | ||
|
||
VERSION = '1.4.2' | ||
VERSION = '1.4.3' | ||
|
||
|
||
setup( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from flexmock import flexmock | ||
|
||
from borgmatic.hooks import cronitor as module | ||
|
||
|
||
def test_ping_cronitor_hits_ping_url(): | ||
ping_url = 'https://example.com' | ||
append = 'failed-so-hard' | ||
flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, append)) | ||
|
||
module.ping_cronitor(ping_url, 'config.yaml', dry_run=False, append=append) | ||
|
||
|
||
def test_ping_cronitor_without_ping_url_does_not_raise(): | ||
flexmock(module.requests).should_receive('get').never() | ||
|
||
module.ping_cronitor(ping_url=None, config_filename='config.yaml', dry_run=False, append='oops') |