bundles/sshmon: add check_pypi_for_new_release
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
0ac0fe072d
commit
7cfe080e6f
6 changed files with 72 additions and 6 deletions
|
@ -62,7 +62,7 @@ def icinga_check_for_new_release(metadata):
|
|||
'mautrix-telegram': {
|
||||
'services': {
|
||||
'MAUTRIX-TELEGRAM UPDATE': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_github_for_new_release mautrix/telegram {}'.format(metadata.get('mautrix-telegram/version')),
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_pypi_for_new_release mautrix-telegram {}'.format(metadata.get('mautrix-telegram/version')),
|
||||
'vars.notification.mail': True,
|
||||
'check_interval': '60m',
|
||||
},
|
||||
|
|
|
@ -55,7 +55,7 @@ def icinga_check_for_new_release(metadata):
|
|||
'pretalx': {
|
||||
'services': {
|
||||
'PRETALX UPDATE': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_github_for_new_release pretalx/pretalx {}'.format(metadata.get('pretalx/version')),
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_pypi_for_new_release pretalx {}'.format(metadata.get('pretalx/version')),
|
||||
'vars.notification.mail': True,
|
||||
'check_interval': '60m',
|
||||
},
|
||||
|
|
|
@ -59,7 +59,7 @@ try:
|
|||
else:
|
||||
exit(2)
|
||||
else:
|
||||
print("Currently installed version matches newest release on github")
|
||||
print("Currently installed version {} matches newest release on github".format(current_version))
|
||||
exit(0)
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
|
|
58
bundles/sshmon/files/check_pypi_for_new_release
Normal file
58
bundles/sshmon/files/check_pypi_for_new_release
Normal file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
from sys import argv, exit
|
||||
|
||||
from requests import get
|
||||
|
||||
try:
|
||||
# Arch Linux (possibly future Ubuntu releases)
|
||||
from packaging.version import parse
|
||||
except ModuleNotFoundError:
|
||||
# Debian
|
||||
from setuptools._vendor.packaging.version import parse
|
||||
|
||||
|
||||
assert (
|
||||
len(argv) >= 3
|
||||
), "Usage: check_pypi_for_new_release <project> <version> [tag prefix]"
|
||||
|
||||
repo = argv[1]
|
||||
current_version = argv[2]
|
||||
if len(argv) >= 4:
|
||||
tag_prefix = argv[3]
|
||||
else:
|
||||
tag_prefix = ""
|
||||
|
||||
try:
|
||||
r = get(
|
||||
"https://pypi.org/pypi/{}/json".format(repo),
|
||||
headers={"Accept": "application/json"},
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
releases = r.json()['releases']
|
||||
|
||||
newest_release = None
|
||||
|
||||
for version, info in releases.items():
|
||||
if version.startswith(tag_prefix):
|
||||
if newest_release is None or parse(version) > parse(newest_release):
|
||||
newest_release = version
|
||||
|
||||
assert newest_release is not None, "Could not determine latest release"
|
||||
|
||||
if parse(newest_release) > parse(current_version):
|
||||
print(
|
||||
"There is a newer version available: {} (currently installed: {})".format(
|
||||
newest_release, current_version
|
||||
)
|
||||
)
|
||||
|
||||
exit(2)
|
||||
else:
|
||||
print("Currently installed version {} matches newest release on PyPI".format(current_version))
|
||||
exit(0)
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
exit(3)
|
|
@ -50,12 +50,13 @@ files = {
|
|||
|
||||
for check in {
|
||||
'cpu_stats',
|
||||
'mounts',
|
||||
'ram',
|
||||
'github_for_new_release',
|
||||
'http_url_for_string',
|
||||
'https_certificate_at_url',
|
||||
'http_wget',
|
||||
'https_certificate_at_url',
|
||||
'mounts',
|
||||
'pypi_for_new_release',
|
||||
'ram',
|
||||
'systemd_unit',
|
||||
}:
|
||||
files["/usr/local/share/icinga/plugins/check_{}".format(check)] = {
|
||||
|
|
7
bundles/sysctl/metadata.py
Normal file
7
bundles/sysctl/metadata.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
defaults = {
|
||||
'sysctl': {
|
||||
'options': {
|
||||
'vm.overcommit_memory': 1,
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue