Module: check_mk
Branch: master
Commit: c0cded62fc53437019c067a1f2a2f45a8d2ff873
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c0cded62fc5343…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Aug 10 07:00:09 2017 +0200
5094 lnx_distro: Prefers /etc/os-release if available which is systemd-supported
Change-Id: I64f8f10a9c65fe0663beb6d3cb087493ab063a3d
---
.werks/5094 | 10 ++++++++++
agents/plugins/mk_inventory.linux | 5 +++--
inventory/lnx_distro | 23 ++++++++++++++++++++++-
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/.werks/5094 b/.werks/5094
new file mode 100644
index 0000000..0cebd82
--- /dev/null
+++ b/.werks/5094
@@ -0,0 +1,10 @@
+Title: lnx_distro: Prefers /etc/os-release if available which is systemd-supported
+Level: 1
+Component: inv
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1502340795
+Class: feature
+
+
diff --git a/agents/plugins/mk_inventory.linux b/agents/plugins/mk_inventory.linux
index c8ab766..6428a61 100755
--- a/agents/plugins/mk_inventory.linux
+++ b/agents/plugins/mk_inventory.linux
@@ -58,9 +58,10 @@ then
# Information about distribution
echo "<<<lnx_distro:sep(124):persist($UNTIL)>>>"
- for f in
{/etc/{oracle-release,debian_version,gentoo-release,lsb-release,redhat-release,SuSE-release},/usr/share/cma/version}
; do
+ for f in
{/etc/{oracle-release,debian_version,gentoo-release,lsb-release,redhat-release,SuSE-release,os-release},/usr/share/cma/version}
; do
if [ -e $f ] ; then
- echo -n "$f|" ; tr \\n \| < $f | sed 's/|$//' ; echo
+ echo "[[[$f]]]"
+ tr \\n \| < $f | sed 's/|$//' ; echo
fi
done
diff --git a/inventory/lnx_distro b/inventory/lnx_distro
index 1ab82a2..4bbfccf 100644
--- a/inventory/lnx_distro
+++ b/inventory/lnx_distro
@@ -46,13 +46,21 @@
def inv_lnx_distro(info):
parsed = {}
+ filename = None
for line in info:
- parsed.setdefault(line[0], line[1:])
+ if line[0].startswith("[[[") and line[0].endswith("]]]"):
+ filename = line[0][3:-3]
+ elif filename is not None:
+ parsed.setdefault(filename, line)
+ elif filename is None:
+ # stay compatible to older versions of output
+ parsed.setdefault(line[0], line[1:])
node = inv_tree("software.os.")
node["type"] = "Linux"
for file_name, handler in [
("/usr/share/cma/version", inv_lnx_parse_cma),
+ ("/etc/os-release", inv_lnx_parse_os),
("/etc/gentoo-release", inv_lnx_parse_gentoo),
("/etc/SuSE-release", inv_lnx_parse_suse),
("/etc/oracle-release", inv_lnx_parse_oracle_vm_server),
@@ -65,6 +73,19 @@ def inv_lnx_distro(info):
break
+def inv_lnx_parse_os(node, line):
+ for entry in line:
+ k, v = map(lambda x: x.replace('"', ''),
entry.split("=", 1))
+ if k == "VERSION_ID":
+ node["version"] = v
+ elif k == "PRETTY_NAME":
+ node["name"] = v
+ elif k == "VERSION_CODENAME":
+ node["code_name"] = v.title()
+ elif k == "ID":
+ node["vendor"] = v.title()
+
+
def inv_lnx_parse_suse(node, line):
version = line[1].split()[-1]
if len(line) >= 3: