Compare commits
3 Commits
a4ca98e79e
...
325f483a26
Author | SHA1 | Date |
---|---|---|
Franzi | 325f483a26 | |
Franzi | 4f5e462c94 | |
Franzi | 91f2fd839b |
|
@ -65,3 +65,19 @@ def nginx(metadata):
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def icinga_check_for_new_release(metadata):
|
||||
return {
|
||||
'icinga2_api': {
|
||||
'gitea': {
|
||||
'services': {
|
||||
'GITEA UPDATE': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_github_for_new_release go-gitea/gitea v{}'.format(metadata.get('gitea/version')),
|
||||
'retry_interval': '60m',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -42,3 +42,18 @@ defaults = {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def icinga_check_for_new_release(metadata):
|
||||
return {
|
||||
'icinga2_api': {
|
||||
'mautrix-telegram': {
|
||||
'services': {
|
||||
'MAUTRIX-TELEGRAM UPDATE': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_github_for_new_release tulir/mautrix-telegram {}'.format(metadata.get('mautrix-telegram/version')),
|
||||
'retry_interval': '60m',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from requests import get
|
||||
from sys import exit
|
||||
|
||||
api_key = '${api_key}'
|
||||
|
||||
try:
|
||||
json = get('http://[::1]:22030/plugin/softwareupdate/check', headers={'X-Api-Key': api_key}).json()
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
exit(3)
|
||||
|
||||
updates = set()
|
||||
errors = set()
|
||||
|
||||
for identifier, info in json['information'].items():
|
||||
if info['updateAvailable']:
|
||||
updates.add(info['displayName'])
|
||||
|
||||
if not json['environment']['supported']:
|
||||
errors.add('OctoPrint runs in an unsupported environment!')
|
||||
|
||||
if not json['storage']['sufficient']:
|
||||
errors.add('OctoPrint reports insufficient storage!')
|
||||
|
||||
|
||||
for error in sorted(errors):
|
||||
print(error)
|
||||
|
||||
if len(updates) > 0:
|
||||
print('Updates available: {}'.format(', '.join(sorted(updates))))
|
||||
|
||||
|
||||
if len(errors) > 0:
|
||||
exit(2)
|
||||
elif len(updates) > 0:
|
||||
exit(1)
|
||||
else:
|
||||
print('OK')
|
||||
exit(0)
|
|
@ -35,4 +35,11 @@ files = {
|
|||
'/opt/octoprint/systemd-wrapper': {
|
||||
'mode': '0755',
|
||||
},
|
||||
'/usr/local/share/icinga/plugins/check_octoprint_update': {
|
||||
'mode': '0755',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'api_key': node.metadata.get('octoprint', {}).get('api_key', ''),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -18,3 +18,22 @@ defaults = {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def icinga(metadata):
|
||||
if not metadata.get('octoprint/api_key', None):
|
||||
return {}
|
||||
|
||||
return {
|
||||
'icinga2_api': {
|
||||
'octoprint': {
|
||||
'services': {
|
||||
'OCTOPRINT UPDATE': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_octoprint_update',
|
||||
'retry_interval': '60m',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -38,6 +38,9 @@ nodes['home.octoprint-vielschichtigkeit'] = {
|
|||
},
|
||||
},
|
||||
},
|
||||
'octoprint': {
|
||||
'api_key': vault.decrypt('encrypt$gAAAAABfuWtDp0xeUSNZwi8PzhgxvheK1rdhThlPwZSweXZaUNzDF2BlfOwuMvW-vSxHjTJoyCnxzCAAytIBf0iXgdyeCafvbB43ogBaQK52HAahQNP4506-h02BKgiMdIghUmc1ZOUT'),
|
||||
},
|
||||
'raspberrypi': {
|
||||
'camera': True,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue