Module: check_mk
Branch: master
Commit: 165d95e6fa6938a28b77f683d9a8cf208a2770d3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=165d95e6fa6938…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Oct 11 17:23:33 2016 +0200
3946 uptime: added the uptime to inventory
Added uptime of snmp and other agent based devices into
the "Operating System" subtree. Be aware that the check
interval default for the "HW/SW Inventory" is on
"once per day".
---
.werks/3946 | 13 +++++++++++++
ChangeLog | 1 +
inventory/snmp_uptime | 37 +++++++++++++++++++++++++++++++++++++
inventory/uptime | 39 +++++++++++++++++++++++++++++++++++++++
web/plugins/views/inventory.py | 1 +
5 files changed, 91 insertions(+)
diff --git a/.werks/3946 b/.werks/3946
new file mode 100644
index 0000000..7722025
--- /dev/null
+++ b/.werks/3946
@@ -0,0 +1,13 @@
+Title: uptime: added the uptime to inventory
+Level: 1
+Component: inv
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476199109
+Class: feature
+
+Added uptime of snmp and other agent based devices into
+the "Operating System" subtree. Be aware that the check
+interval default for the "HW/SW Inventory" is on
+"once per day".
+
diff --git a/ChangeLog b/ChangeLog
index 26bf1e5..d5529c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@
* 3906 oracle: now version, database creation and startup time, log and open mode,
logins, flashback are inventorised
* 3944 Added OS related information for Cisco, Fireeye and Infoblox devices...
* 3908 winperf_if, lnx_if: new inventory plugins for switch port statistics of linux
and windows hosts
+ * 3946 uptime: added the uptime to inventory...
1.4.0i1:
diff --git a/inventory/snmp_uptime b/inventory/snmp_uptime
new file mode 100644
index 0000000..1289149
--- /dev/null
+++ b/inventory/snmp_uptime
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def inv_snmp_uptime(info):
+ uptime = parse_snmp_uptime(info[0][0])
+ since = time.strftime("%c", time.localtime(time.time() -
float(uptime)))
+ node = inv_tree("software.os.")
+ node["since"] = since
+
+
+inv_info['snmp_uptime'] = {
+ "inv_function" : inv_snmp_uptime,
+ "includes" : [ 'uptime.include' ],
+}
diff --git a/inventory/uptime b/inventory/uptime
new file mode 100644
index 0000000..112c4c9
--- /dev/null
+++ b/inventory/uptime
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Example output from agent:
+# <<<uptime>>>
+# 15876.96 187476.72
+
+def inv_uptime(info):
+ uptime = float(info[0][0])
+ since = time.strftime("%c", time.localtime(time.time() -
float(info[0][0])) )
+ node = inv_tree("software.os.")
+ node["since"] = since
+
+inv_info['uptime'] = {
+ "inv_function" : inv_uptime,
+}
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index b720924..1cb65bb 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -680,6 +680,7 @@ inventory_displayhints.update({
".software.os.service_pack" : { "title" :
_("Service Pack"), "short" : _("Service Pack") },
".software.os.service_packs:" : { "title" :
_("Service Packs"), "render" : render_inv_dicttable,
"keyorder" : [
"name" ] },
+ ".software.os.since" : { "title" :
_("Up since") },
".software.configuration." : { "title" :
_("Configuration"), },
".software.configuration.snmp_info." : { "title" :
_("SNMP Information"), },
".software.configuration.snmp_info.contact" : { "title" :
_("Contact"), },