Module: check_mk
Branch: master
Commit: dbd4b915155cc22d4773f4e39e06a2448f9983e2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dbd4b915155cc2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 24 11:55:40 2014 +0100
Inventory: make agent caching dependent on remote address
---
agents/check_mk_agent.linux | 9 ++++++++-
agents/plugins/mk_inventory.linux | 2 +-
web/plugins/icons/inventory.py | 3 ++-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index d8105a7..c5f6ac9 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -30,6 +30,14 @@ unset LANG
export MK_LIBDIR="/usr/lib/check_mk_agent"
export MK_CONFDIR="/etc/check_mk"
+# Provide information about the remote host. That helps when data
+# is being sent only once to each remote host.
+if [ "$REMOTE_HOST" ] ; then
+ export REMOTE=$REMOTE_HOST
+elif [ "$SSH_CLIENT" ] ; then
+ export REMOTE=${SSH_CLIENT%% *}
+fi
+
# Make sure, locally installed binaries are found
PATH=$PATH:/usr/local/bin
@@ -47,7 +55,6 @@ LOCALDIR=$MK_LIBDIR/local
# output if they are not outdated (see below)
SPOOLDIR=$MK_CONFDIR/spool
-
# close standard input (for security reasons) and stderr
if [ "$1" = -d ]
then
diff --git a/agents/plugins/mk_inventory.linux b/agents/plugins/mk_inventory.linux
index 9e08e07..8fc1c14 100755
--- a/agents/plugins/mk_inventory.linux
+++ b/agents/plugins/mk_inventory.linux
@@ -3,7 +3,7 @@
# Run and *send* only once every 4 hours
INTERVAL=14400
-FLAGFILE=$MK_CONFDIR/mk_inventory.last
+FLAGFILE=$MK_CONFDIR/mk_inventory.last.$REMOTE
LAST_RUN=$(stat -c %Y $FLAGFILE)
NOW=$(date +%s)
UNTIL=$((NOW + INTERVAL))
diff --git a/web/plugins/icons/inventory.py b/web/plugins/icons/inventory.py
index d4b006f..c78a5ed 100644
--- a/web/plugins/icons/inventory.py
+++ b/web/plugins/icons/inventory.py
@@ -25,7 +25,8 @@
# Boston, MA 02110-1301 USA.
def paint_icon_inventory(what, row, tags, customer_vars):
- if what == "host" and inventory.has_inventory(row["host_name"]):
+ if (what == "host" or
row.get("service_check_command","").startswith("check_mk_active-cmk_inv!"))
\
+ and inventory.has_inventory(row["host_name"]):
return link_to_view("<img class=icon title='%s'
src='images/icon_inv.png'>" %
_("Show Hardware/Software-Inventory of this host"),
row, 'inv_host' )