bundles/sshmon: add check_github_for_new_release
This commit is contained in:
parent
a4ca98e79e
commit
91f2fd839b
2 changed files with 32 additions and 0 deletions
31
bundles/sshmon/files/check_github_for_new_release
Normal file
31
bundles/sshmon/files/check_github_for_new_release
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from requests import get
|
||||
from sys import argv, exit
|
||||
|
||||
assert len(argv) == 3, 'Usage: check_github_for_new_release <repo> <version>'
|
||||
|
||||
repo = argv[1]
|
||||
current_version = argv[2]
|
||||
|
||||
try:
|
||||
r = get('https://api.github.com/repos/{}/releases/latest'.format(repo), headers={'Accept': 'application/json'}).json()
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
exit(3)
|
||||
|
||||
newest_release = r['name']
|
||||
|
||||
if newest_release != current_version:
|
||||
print('There is a newer version available: {} (currently installed: {})'.format(newest_release, current_version))
|
||||
|
||||
if r['prerelease'] or r['draft']:
|
||||
print('Please note this is only a prerelease/draft.')
|
||||
|
||||
# Don't alert people for prereleases.
|
||||
exit(0)
|
||||
else:
|
||||
exit(2)
|
||||
else:
|
||||
print('Currently installed version matches newest release on github')
|
||||
exit(0)
|
|
@ -47,6 +47,7 @@ for check in {
|
|||
'cpu_stats',
|
||||
'mounts',
|
||||
'ram',
|
||||
'github_for_new_release',
|
||||
'http_url_for_string',
|
||||
'https_certificate_at_url',
|
||||
'http_wget',
|
||||
|
|
Loading…
Reference in a new issue