checkmk-monitoring-plugins/release-info/check_release_info

24 lines
672 B
Plaintext
Raw Normal View History

2022-10-16 13:13:36 +02:00
#!/usr/bin/env python3
2022-10-16 15:05:20 +02:00
#
# Prints the debian/ubuntu release info and sets state by codename
# The package 'lsb-release' is required for this check.
2022-10-16 13:13:36 +02:00
import subprocess
ok_list = ['bullseye', 'bookworm', 'trixie', 'forky', 'jammy', 'focal']
warn_list = ['buster', 'bionic', 'xenial']
cmd = ["/usr/bin/lsb_release", "-ircs"]
2022-10-16 15:05:20 +02:00
2022-10-16 13:13:36 +02:00
stdout, stderr = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
dist, version, codename, null = stdout.decode('utf-8').split('\n')
2022-10-16 15:05:20 +02:00
if codename in ok_list:
state = 0
elif codename in warn_list:
state = 1
else:
state = 2
2022-10-16 13:13:36 +02:00
2022-10-16 15:05:20 +02:00
print ('%s "Distribution Info" - %s %s %s' % (state, dist, version, codename))