Module: check_mk
Branch: master
Commit: 6029f50b23d32685b3b2c0686605e3848fce45f4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6029f50b23d326…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Sep 10 11:29:55 2014 +0200
#1106 mk_inventory.ps1: now uses the MK_CONFDIR environment variable from the agent (if
available)
The mk_inventory.ps1 needs to create statefile for each host.
The path of this files were hardcoded to <tt>c:\Program Files
(x86)\check_mk\timestamp.$remote_host</tt><br>
This has been changed. The latest check_mk agent now provides additional environment
variables
<ul>
<li>PLUGINSDIR</li>
<li>LOCALDIR</li>
<li>SPOOLDIR</li>
<li>MK_CONFDIR</li>
</ul>
and the script uses them accordingly.
---
.werks/1106 | 20 ++++++++++++++++++++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.ps1 | 10 +++++++++-
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/.werks/1106 b/.werks/1106
new file mode 100644
index 0000000..e85b4f3
--- /dev/null
+++ b/.werks/1106
@@ -0,0 +1,20 @@
+Title: mk_inventory.ps1: now uses the MK_CONFDIR environment variable from the agent (if
available)
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1410341164
+Class: feature
+
+The mk_inventory.ps1 needs to create statefile for each host.
+The path of this files were hardcoded to <tt>c:\Program Files
(x86)\check_mk\timestamp.$remote_host</tt><br>
+This has been changed. The latest check_mk agent now provides additional environment
variables
+
+<ul>
+<li>PLUGINSDIR</li>
+<li>LOCALDIR</li>
+<li>SPOOLDIR</li>
+<li>MK_CONFDIR</li>
+</ul>
+
+and the script uses them accordingly.
diff --git a/ChangeLog b/ChangeLog
index 96f13f2..9243cf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,7 @@
* 1182 bluecat_ha: New Check for HA Status on Bluecat Adonis devices
* 1183 bluecat_commandserver: New Check for bluecat adonis devices
* 1397 juniper_screenos_cpu, juniper_screenos_fan, juniper_screenos_mem,
juniper_screenos_temp, juniper_screenos_vpn: new checks for Juniper ScreenOS Firewalls
+ * 1106 mk_inventory.ps1: now uses the MK_CONFDIR environment variable from the agent
(if available)...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/agents/windows/plugins/mk_inventory.ps1
b/agents/windows/plugins/mk_inventory.ps1
index 97b8b3d..53f76f2 100644
--- a/agents/windows/plugins/mk_inventory.ps1
+++ b/agents/windows/plugins/mk_inventory.ps1
@@ -4,7 +4,15 @@ $name = (Get-Item env:\Computername).Value
$separator = "|"
# filename for timestamp
$remote_host = $env:REMOTE_HOST
-$timestamp = "c:\Program Files (x86)\check_mk\timestamp.$remote_host"
+$agent_dir = $env:MK_CONFDIR
+
+# Fallback if the (old) agent does not provide the MK_CONFDIR
+if (!$agent_dir) {
+ $agent_dir = "c:\Program Files (x86)\check_mk"
+}
+
+$timestamp = $agent_dir + "\timestamp."+ $remote_host
+
# execute agent only every $delay seconds
$delay = 14400